修复渠道代码

This commit is contained in:
邱贞招 2024-02-26 22:47:52 +08:00
parent 481bfba4bc
commit 5bdc301972
6 changed files with 79 additions and 60 deletions

View File

@ -19,12 +19,12 @@ export function getWechatConfig() {
* 获取微信sdk配置
* @returns {*}
*/
export function wechatAuth(code, spread,) {
export function wechatAuth(code, spread,channelId) {
var reg=/^[0-9]+.?[0-9]*$/; //判断字符串是否为数字 ,判断正整数用/^[1-9]+[0-9]*]*$/
spread = reg.test(spread) ? spread : 0;
channelId = reg.test(channelId) ? channelId : 0;
return request.get(
"wechat/authorize/login?code=" + code + "&spread_spid=" + spread , {},
"wechat/authorize/login?code=" + code + "&spread_spid=" + spread+"&channelId="+channelId, {},
{ noAuth: true }
);
}

View File

@ -28,6 +28,7 @@ module.exports = {
SPREAD: 'SPREAD',
CHANNELID: 'CHANNELID',
//缓存经度
CACHE_LONGITUDE: 'LONGITUDE',
//缓存纬度

12
main.js
View File

@ -29,13 +29,13 @@ import {
} from "./utils";
import Auth from './libs/wechat';
import {
SPREAD
SPREAD,CHANNELID
} from './config/cache';
Vue.prototype.$wechat = Auth;
let cookieName = "VCONSOLE",
query = parseQuery(),
urlSpread = query["spread"],
urlChannelId = query["channelId"],
vconsole = query[cookieName.toLowerCase()],
md5Crmeb = "b14d1e9baeced9bb7525ab19ee35f2d2", //CRMEB MD5 加密开启vconsole模式
md5UnCrmeb = "3dca2162c4e101b7656793a1af20295c"; //UN_CREMB MD5 加密关闭vconsole模式
@ -46,7 +46,13 @@ let cookieName = "VCONSOLE",
value: urlSpread,
})
}
if (urlChannelId) {
urlChannelId = parseInt(urlChannelId);
Cache.setItem({
name: 'channelId',
value: urlChannelId,
})
}
if (vconsole !== undefined) {
if (vconsole === md5UnCrmeb && Cache.has(cookieName))
Cache.clear(cookieName);

View File

@ -368,7 +368,7 @@
import shareRedPackets from '@/components/shareRedPackets';
import cusPreviewImg from '@/components/cus-previewImg/cus-previewImg.vue'
import {
silenceBindingSpread,
silenceBindingSpread,silenceBindingChannelId
} from "@/utils";
import parser from "@/components/jyf-parser/jyf-parser";
@ -551,6 +551,8 @@
this.getTokenIsExist();
},
onLoad(options) {
// console.log(JSON.stringify(options),"options.spread")
alert("options.spread"+JSON.stringify(options))
//
this.$set(this, 'theme', this.$Cache.get('theme'));
@ -608,7 +610,7 @@
// #endif
if (options.spread) app.globalData.spread = options.spread;
if (options.channelId) app.globalData.channelId = options.channelId;
this.getGoodsDetails(); //
this.getCouponType(); //
@ -687,7 +689,7 @@
this.getCartCount(true); //
//
if (parseInt(app.globalData.spread) > 0) silenceBindingSpread();
if (parseInt(app.globalData.channelId) > 0) silenceBindingChannelId();
}
});
},

View File

@ -211,7 +211,7 @@
getGroomList
} from '@/api/store.js';
import {
silenceBindingSpread,
silenceBindingSpread,silenceBindingChannelId,
getCityList
} from '@/utils';
import animationType from '@/utils/animationType.js'
@ -419,11 +419,11 @@
let qrCodeValue = this.$util.getUrlParams(decodeURIComponent(options.scene));
let mapeMpQrCodeValue = this.$util.formatMpQrCodeData(qrCodeValue);
app.globalData.spread = mapeMpQrCodeValue.spread;
app.globalData.channelId = mapeMpQrCodeValue.channelId;
}
if (options.spread) app.globalData.spread = options.spread; //urlidglobalDta
if (options.channelId) app.globalData.channelId = options.channelId; //urlidglobalDta
// #endif
// #ifndef MP || APP-PLUS
this.navH = 0;
@ -435,7 +435,12 @@
if (this.isLogin && parseInt(app.globalData.spread) > 0) {
silenceBindingSpread()
}
if (this.isLogin && parseInt(app.globalData.channelId) > 0) {
silenceBindingChannelId()
}
if (this.isLogin && parseInt(options.channelId) > 0) {
silenceBindingChannelId()
}
// ip
this.getip()

View File

@ -144,9 +144,9 @@
//if(!code) location.replace(decodeURIComponent(decodeURIComponent(option.query.back_url)));
if (code && this.options.scope !== 'snsapi_base') {
let spread = app.globalData.spread ? app.globalData.spread : 0;
let channelId = app.globalData.channelId ? app.globalData.channelId : 0;
// wechatAuth(code, Cache.get("spread"), loginType)
wechat.auth(code, spread).then(res => {
wechat.auth(code, spread,channelId).then(res => {
if (res.type === 'register') {
this.authKey = res.key;
this.isUp = true
@ -251,6 +251,7 @@
let userInfo = {};
userInfo.code = code;
userInfo.spread_spid = app.globalData.spread; //广ID
userInfo.channelId = app.globalData.channelId; //ID
userInfo.avatar = '';
userInfo.nickName = '微信用户';
userInfo.type = 'routine'
@ -266,6 +267,7 @@
let userInfo = res.userInfo;
userInfo.code = code;
userInfo.spread_spid = app.globalData.spread; //广ID
userInfo.channelId = app.globalData.channelId; //ID
userInfo.avatar = userInfo.userInfo.avatarUrl;
userInfo.city = userInfo.userInfo.city;
userInfo.country = userInfo.userInfo.country;
@ -305,6 +307,9 @@
if (app.globalData.spread) {
spread(app.globalData.spread).then(res => {}) //spread
}
if (app.globalData.channelId) {
channelId(app.globalData.channelId).then(res => {}) //
}
self.$util.Tips({
title: res,
icon: 'success'