Commit c7034aad authored by 郭志伟's avatar 郭志伟

feat: 调整vccChannel

parent a05f3314
// tslint:disable
import { isAndroid, isIOS, isWechat } from '@/service/utils.service';
import { isAndroid, isIOS, isWxMp } from '@/service/utils.service';
import localStorage from '@/service/localStorage.service';
import Toast from '@qg/cherry-ui/src/toast';
......@@ -12,12 +12,20 @@ function getURLSearchParams(json) {
return dataArray.filter(item => item !== undefined && item !== null).join('&');
}
function getVccChannel() {
let storageChannel = localStorage.get('vccChannel');
storageChannel = !isNaN(Number(storageChannel)) ? storageChannel : '';
return isWechat
? storageChannel || ''
: (isAndroid ? '159905' : isIOS ? '159904' : storageChannel || '');
function getVccChannel(channelKey = 'vccChannel') {
const localChannel = localStorage.get(channelKey) || '';
if (channelKey === 'sonVccChannel') {
return localChannel;
}
return localChannel
? localChannel
: isWxMp
? '159913'
: isAndroid
? '159905'
: isIOS
? '159904'
: '';
}
export default {
service: {
......@@ -59,6 +67,7 @@ export default {
}
if (!hideVccChannel) {
cfg.headers['vccChannel'] = getVccChannel();
cfg.headers['sonVccChannel'] = getVccChannel('sonVccChannel');
}
if (method === 'post' && cfg.emulateJSON) {
cfg.headers['Content-Type'] = 'application/x-www-form-urlencoded';
......
......@@ -3,7 +3,7 @@ import { isWechat, isApp, errorQueryValues } from './utils.service';
import Cookies from './cookieStorage.service';
import localStorage from './localStorage.service';
// formXcxPage:标识是从小程序跳转过来的;
const localStorageParams = ['creditToken', 'vccToken', 'vccChannel', 'formXcxPage'];
const localStorageParams = ['creditToken', 'vccToken', 'vccChannel', 'sonvccChannel', 'formXcxPage'];
const cookiesParams = ['h', 'vccToken'];
export default {
......
......@@ -140,7 +140,7 @@ export const isIOS = /iphone|ipad|ipod/.test(ua);
export const isAndroid = /android/.test(ua);
// 异常字段
export const errorQueryValues = ['{token}', '{vccToken}', '{registerFrom}', '{vccChannel}', '{h}', '{uuid}', '{}'];
export const errorQueryValues = ['{token}', '{vccToken}', '{registerFrom}', '{vccChannel}', '{sonVccChannel}', '{h}', '{uuid}', '{}'];
export const debounce = (event, time) => {
let timer = null;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment