123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128 |
- const ip = 'http://192.168.0.251/obpm';
- const urls = {
- ip: ip,
- home: ip + '/app/home/index',
- login: ip + '/runtime/login/loginWithCiphertext2',
- myprofile: ip + '/runtime/users/myprofile',
- user_register: ip + '/app/user/register',
- accessToken: ip + '/rest/accessToken?secret=11ec-db2f-ca248770-8df3-890eb68cafa4',
-
- wt_list: ip +
- '/runtime/__gAPYBW4YxB3UePM3lqO/views/__km3aURKW95BHxp12XVt/documents?lines=10&isQueryButton=false',
- wt_xqsh: ip +
- '/runtime/__gAPYBW4YxB3UePM3lqO/views/__MhHakFCgVJAm81MFUnt/documents?lines=10&isQueryButton=false',
- wt_sysh: ip +
- '/runtime/__gAPYBW4YxB3UePM3lqO/views/__r4IN5HOqV4HIips1s0Q/documents?lines=10&isQueryButton=false',
- wt_xqpz: ip +
- '/runtime/__gAPYBW4YxB3UePM3lqO/views/__yoOF16IOiZdmrbDOujU/documents?lines=10&isQueryButton=false',
- wt_sypz: ip +
- '/runtime/__gAPYBW4YxB3UePM3lqO/views/__b6gD17cP1g4gFdTq0Ox/documents?lines=10&isQueryButton=false',
- wt_rwfp: ip +
- '/runtime/__gAPYBW4YxB3UePM3lqO/views/__m9w03S06KHbg3KioRIh/documents?lines=10&isQueryButton=false',
- documents: ip + '/runtime/__gAPYBW4YxB3UePM3lqO/documents/',
- empty: ip +
- '/runtime/__gAPYBW4YxB3UePM3lqO/forms/__0FLGNncOS1lz0T9jsFn/empty?formId=__0FLGNncOS1lz0T9jsFn&appId=__gAPYBW4YxB3UePM3lqO',
-
- validate: ip + '/runtime/__gAPYBW4YxB3UePM3lqO/documents',
- borr_empty: ip +
- '/runtime/__gAPYBW4YxB3UePM3lqO/forms/__w9J1gxcIWgXmNw6pE1F/empty?formId=__w9J1gxcIWgXmNw6pE1F&appId=__gAPYBW4YxB3UePM3lqO',
- return_empty: ip +
- '/runtime/__gAPYBW4YxB3UePM3lqO/forms/__LcDaGhYHt5xOSeHMCs0/empty?formId=__LcDaGhYHt5xOSeHMCs0&appId=__gAPYBW4YxB3UePM3lqO',
- eq_list: ip +'/runtime/__gAPYBW4YxB3UePM3lqO/views/__WLVxKX6e0Pq0cTwdNUQ/documents?',
- }
- const request = (opt) => {
- opt = opt || {};
- opt.url = opt.url || '';
- opt.data = opt.data || null;
- opt.method = opt.method || 'GET';
- opt.contentType = opt.contentType || 'application/json;charset=UTF-8'
- opt.header = opt.header || {
- "Content-Type": opt.contentType,
-
- "accessToken": getUser().accessToken || ''
- };
- opt.loading = opt.loading || 'true';
- opt.success = opt.success || function() {};
- console.log("**************************************参数调式***************************************************");
- console.log("请求地址:" + opt.url + " 请求参数:" + JSON.stringify(opt.data));
- console.log("************************************************************************************************");
- if (opt.loading == 'true') {
- uni.showLoading({
- title: '正在加载',
- mask: true
- });
- }
- uni.request({
- url: opt.url,
- data: opt.data,
- method: opt.method,
- header: opt.header,
- dataType: 'json',
- success: res => {
- setTimeout(() => {
- uni.hideLoading();
- }, 500)
-
- if (res.data.code === 500) {
- uni.showModal({
- content: res.data.msg,
- showCancel: false
- });
- return;
- }
- if (res.statusCode === 401) {
- uni.removeStorageSync('user');
- uni.showModal({
- title: '提示',
- content: '登录超时,请先登陆!',
- success: res => {
- if (res.confirm) {
- uni.navigateTo({
- url: '/pages/login'
- })
- }
- }
- });
- return;
- }
- opt.success(res);
- },
- fail: e => {
- uni.hideLoading();
- uni.getNetworkType({
- success: res => {
- if (res.networkType == 'none') {
- uni.showModal({
- content: '当前网络不可用,请检查网络稍后重试',
- showCancel: false
- });
- } else {
- uni.showModal({
- content: '服务异常,请稍后重试',
- showCancel: false
- })
- }
- }
- });
- }
- })
- }
- const getUser = () => {
- return uni.getStorageSync('user');
- }
- module.exports = {
- urls,
- request,
- getUser
- };
|