| | |
| | | config, |
| | | DEBUG |
| | | } from '@/common/config.js'; |
| | | function appType() { |
| | | let appType = 0 |
| | | // #ifdef MP-WEIXIN |
| | | appType = 3 // 微信小程序 |
| | | // #endif |
| | | // #ifdef MP-ALIPAY |
| | | appType = 1 // 支付宝小程序 |
| | | // #endif |
| | | // #ifdef H5 |
| | | var ua = window.navigator.userAgent.toLowerCase(); |
| | | if (ua.match(/MicroMessenger/i) == 'micromessenger') { |
| | | appType = 4; //是微信公众号 |
| | | } |
| | | if (ua.match(/AlipayClient/i) == 'alipayclient') { |
| | | appType = 2; //支付宝生活号 |
| | | } |
| | | // #endif |
| | | return appType |
| | | } |
| | | import { |
| | | getPlat |
| | | } from 'common/util.js'; |
| | | module.exports = (vm) => { |
| | | uni.$u.http.setConfig((x) => { |
| | | return x = { |
| | |
| | | timer: null, |
| | | loadingTime: 800, //多少秒无返回再显示loading |
| | | header: { |
| | | 'Clientid': '944c6aade52ebbffc015478e6ce51b5a', |
| | | 'Content-Type': 'application/x-www-form-urlencoded;charset=UTF-8', |
| | | 'Access-Control-Allow-Origin': '*' |
| | | } |
| | |
| | | if (TOKEN) { |
| | | x.header[ACCESSTOKEN] = 'Bearer ' + TOKEN; |
| | | } |
| | | x.header['CLIENT-TYPE'] = appType() |
| | | return x; |
| | | }, x => { |
| | | return Promise.reject(x) |
| | |
| | | let res = x.data |
| | | if (res.code == 10000) { |
| | | return res.data; |
| | | } else if (res.code == 20002) { |
| | | const cid = uni.getStorageSync('CID') |
| | | uni.removeStorageSync(ACCESSTOKEN) |
| | | vm.$u.toast("授权过期,请重新登录"); |
| | | setTimeout(() => { |
| | | uni.reLaunch({ |
| | | url: "/pay/login?cid=" + cid |
| | | }) |
| | | }, 800); |
| | | return Promise.reject(res) |
| | | } else if (res.code == 10002) { |
| | | return Promise.reject(res) |
| | | } else { |
| | | vm.$u.toast(res.description || "请求异常!"); //错误提示信息 |
| | | vm.$u.toast(res.description || res.msg ||res.info || "请求异常!"); //错误提示信息 |
| | | return Promise.reject(res) |
| | | } |
| | | }, (response) => { |