石广澎
2024-05-08 b920b4a7e70ffdeb7308131cb3d6a10dff9e3451
feat(支付): 请求头内放置客户端类型
3个文件已修改
32 ■■■■ 已修改文件
common/config.js 8 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
common/http.interceptor.js 20 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
main.js 4 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
common/config.js
@@ -11,10 +11,10 @@
}
// 支付测试
const payTest = {
    webURL: 'https://jmy.jinmingyuan.com/payTest',
    baseURL: 'http://1.14.252.104:7101',
    sftpURL: 'https://echftp.jinmingyuan.com',
    imgUrl: 'https://echftp.jinmingyuan.com/platform/app/',
    webURL: 'https://jmy.jinmingyuan.com/scanPay',
    baseURL: 'http://u2cgg5.natappfree.cc',
    sftpURL: 'https://yqzx.jinmingyuan.com/file',
    imgUrl: 'https://yqzx.jinmingyuan.com/file/platform/app/',
    wx_appid: 'wxad8cc511da676bd4',
    ali_appid:'2021003199690698'
}
common/http.interceptor.js
@@ -3,6 +3,25 @@
    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
}
module.exports = (vm) => {
    uni.$u.http.setConfig((x) => {
        return x = {
@@ -28,6 +47,7 @@
        } else {
            delete x.header[ACCESSTOKEN]
        }
        x.header['CLIENT-TYPE'] = appType()
        return x;
    }, x => {
        return Promise.reject(x)
main.js
@@ -1,7 +1,7 @@
import App from './App'
import Vue from 'vue'
/* import Vconsole from 'vconsole';
new Vconsole(); */
import Vconsole from 'vconsole';
new Vconsole();
import uView from '@/uni_modules/uview-ui'
Vue.use(uView)