石广澎
2025-11-17 8771da2ccf6f7c3fd2a8c89a1a0e230c6386db7f
common/http.interceptor.js
@@ -3,10 +3,6 @@
    config,
    DEBUG
} from '@/common/config.js';
import {
    getPlat
} from 'common/util.js';
module.exports = (vm) => {
    uni.$u.http.setConfig((x) => {
        return x = {
@@ -17,7 +13,6 @@
            timer: null,
            loadingTime: 800, //多少秒无返回再显示loading
            header: {
                'Clientid': '944c6aade52ebbffc015478e6ce51b5a',
                'Content-Type': 'application/x-www-form-urlencoded;charset=UTF-8',
                'Access-Control-Allow-Origin': '*'
            }
@@ -29,30 +24,9 @@
        // 引用token
        const TOKEN = uni.getStorageSync(ACCESSTOKEN);
        if (TOKEN) {
            x.header[ACCESSTOKEN] = 'Bearer ' + TOKEN;
        }
        const plat = getPlat()
        if (plat == 2) { //微信
            const OPENID = uni.getStorageSync('OPENID') || null
            const UNIONID = uni.getStorageSync('UNIONID') || null
            if (OPENID) {
                x.header['Openid'] = OPENID;
            }
            if (UNIONID) {
                x.header['Unionid'] = UNIONID;
            }
        }
        if (plat == 5) { //支付宝
            const ALIUSERID = uni.getStorageSync('ALIUSERID') || null
            if (ALIUSERID) {
                x.header['Aliuserid'] = ALIUSERID;
            }
        }
        if (plat == 15) { //云闪付
            const UNIONPAYID = uni.getStorageSync('UNIONPAYID') || null
            if (UNIONPAYID) {
                x.header['Unionpayid '] = UNIONPAYID;
            }
         x.header[ACCESSTOKEN] = TOKEN;
      } else {
         delete x.header[ACCESSTOKEN]
        }
        return x;
    }, x => {
@@ -64,10 +38,20 @@
        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: "/pages/pay/scanpay?cid=" + cid
            })
         }, 800);
         return Promise.reject(res)
        } else if (res.code == 10002) {
            return Promise.reject(res)
        } else {
            vm.$u.toast(res.description || res.msg || res.info || "请求异常!"); //错误提示信息
         vm.$u.toast(res.description || "请求异常!"); //错误提示信息
            return Promise.reject(res)
        }
    }, (response) => {