1. APP增加终端Header[terminal]

2. 订单、会员注册记录来源终端
pull/5/head
owen 2023-10-16 15:06:58 +08:00
parent f41874765a
commit cc94ee7aff
3 changed files with 47 additions and 1 deletions

View File

@ -36,4 +36,24 @@ export const BrokerageWithdrawTypeEnum = {
name: '支付宝',
icon: 'icon-icon34'
}
}
}
/** 终端的枚举 */
export const TerminalEnum = {
WECHAT_MINI_PROGRAM: {
terminal: 10,
name: '微信小程序'
},
WECHAT_WAP: {
terminal: 11,
name: '微信公众号'
},
H5: {
terminal: 20,
name: 'H5 网页'
},
APP: {
terminal: 31,
name: '手机 App'
}
}

View File

@ -9,6 +9,7 @@ import {
checkLogin
} from '../libs/login';
import store from '../store';
import {getTerminal} from "./util";
// TODO 芋艿:临时解决 uniapp 在小程序undefined 会被 tostring 的问题
function deleteUndefinedProperties(obj) {
@ -55,6 +56,9 @@ function baseRequest(url, method, data, {
header['tenant-id'] = 1
}
// 终端
header['terminal'] = getTerminal()
if (store.state.app.token) {
// header[TOKENNAME] = store.state.app.token;
header['Authorization'] = 'Bearer ' + store.state.app.token;

View File

@ -1,4 +1,6 @@
import { HTTP_REQUEST_URL } from '@/config/app.js';
import {TerminalEnum} from "./dict";
import wechat from "../libs/wechat";
export default {
@ -814,3 +816,23 @@ export function handleTree(data, id, parentId, children, rootId) {
});
return treeData !== '' ? treeData : data;
}
/**
* 获取终端类型
* https://uniapp.dcloud.net.cn/tutorial/platform.html#preprocessor
*
* @return {number | null} 终端类型
*/
export function getTerminal() {
let terminal = null;
// #ifdef MP-WEIXIN
terminal = TerminalEnum.WECHAT_MINI_PROGRAM.terminal
// #endif
// #ifdef H5 || WEB
terminal = wechat.isWeixin() ? TerminalEnum.WECHAT_WAP.terminal : TerminalEnum.H5.terminal
// #endif
// #ifdef APP-PLUS || APP
terminal = TerminalEnum.APP.terminal
// #endif
return terminal;
}