静默保存渠道id
This commit is contained in:
parent
0c4f396599
commit
c5f055cc1c
|
@ -19,11 +19,12 @@ export function getWechatConfig() {
|
||||||
* 获取微信sdk配置
|
* 获取微信sdk配置
|
||||||
* @returns {*}
|
* @returns {*}
|
||||||
*/
|
*/
|
||||||
export function wechatAuth(code, spread) {
|
export function wechatAuth(code, spread,channelId) {
|
||||||
var reg=/^[0-9]+.?[0-9]*$/; //判断字符串是否为数字 ,判断正整数用/^[1-9]+[0-9]*]*$/
|
var reg=/^[0-9]+.?[0-9]*$/; //判断字符串是否为数字 ,判断正整数用/^[1-9]+[0-9]*]*$/
|
||||||
spread = reg.test(spread) ? spread : 0;
|
spread = reg.test(spread) ? spread : 0;
|
||||||
|
channelId = reg.test(channelId) ? channelId : 0;
|
||||||
return request.get(
|
return request.get(
|
||||||
"wechat/authorize/login?code=" + code + "&spread_spid=" + spread, {},
|
"wechat/authorize/login?code=" + code + "&spread_spid=" + spread+"&channelId="+channelId, {},
|
||||||
{ noAuth: true }
|
{ noAuth: true }
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
|
@ -382,7 +382,7 @@ export function spread(puid)
|
||||||
return request.get("user/bindSpread?spreadPid="+ puid);
|
return request.get("user/bindSpread?spreadPid="+ puid);
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
// * 静默绑定推广人
|
// * 静默绑定渠道
|
||||||
// * @param {Object} channelId
|
// * @param {Object} channelId
|
||||||
// */
|
// */
|
||||||
export function channel(channelId)
|
export function channel(channelId)
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
//移动端商城API
|
//移动端商城API
|
||||||
// let domain = 'http://117.50.163.143:20410'
|
// let domain = 'http://117.50.163.143:20410'
|
||||||
// let domain = 'http://117.50.215.20:20410'
|
let domain = 'http://117.50.215.20:20410'
|
||||||
let domain = 'http://192.168.2.14:8081'
|
// let domain = 'http://192.168.2.14:8081'
|
||||||
// let domain = 'http://106.75.49.247:20410'
|
// let domain = 'http://106.75.49.247:20410'
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
|
@ -11,7 +11,7 @@ module.exports = {
|
||||||
HTTP_REQUEST_URL: domain,
|
HTTP_REQUEST_URL: domain,
|
||||||
// H5商城地址
|
// H5商城地址
|
||||||
// HTTP_H5_URL: 'http://106.75.49.247:20410',
|
// HTTP_H5_URL: 'http://106.75.49.247:20410',
|
||||||
HTTP_H5_URL: 'http://192.168.2.14:8081',
|
HTTP_H5_URL: 'http://117.50.215.20:20410',
|
||||||
// #endif
|
// #endif
|
||||||
// #ifdef H5
|
// #ifdef H5
|
||||||
HTTP_REQUEST_URL:domain,
|
HTTP_REQUEST_URL:domain,
|
||||||
|
|
|
@ -27,6 +27,7 @@ module.exports = {
|
||||||
TIPS_KEY: 'TIPS_KEY',
|
TIPS_KEY: 'TIPS_KEY',
|
||||||
|
|
||||||
SPREAD: 'SPREAD',
|
SPREAD: 'SPREAD',
|
||||||
|
CHANNELID: 'CHANNELID',
|
||||||
//缓存经度
|
//缓存经度
|
||||||
CACHE_LONGITUDE: 'LONGITUDE',
|
CACHE_LONGITUDE: 'LONGITUDE',
|
||||||
//缓存纬度
|
//缓存纬度
|
||||||
|
|
|
@ -217,7 +217,7 @@ class AuthWechat {
|
||||||
*/
|
*/
|
||||||
auth(code) {
|
auth(code) {
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
wechatAuth(code, Cache.get('spread'))
|
wechatAuth(code, Cache.get('spread'),Cache.get('channelId'))
|
||||||
.then(({
|
.then(({
|
||||||
data
|
data
|
||||||
}) => {
|
}) => {
|
||||||
|
|
17
main.js
17
main.js
|
@ -29,12 +29,13 @@ import {
|
||||||
} from "./utils";
|
} from "./utils";
|
||||||
import Auth from './libs/wechat';
|
import Auth from './libs/wechat';
|
||||||
import {
|
import {
|
||||||
SPREAD
|
SPREAD,CHANNELID
|
||||||
} from './config/cache';
|
} from './config/cache';
|
||||||
Vue.prototype.$wechat = Auth;
|
Vue.prototype.$wechat = Auth;
|
||||||
let cookieName = "VCONSOLE",
|
let cookieName = "VCONSOLE",
|
||||||
query = parseQuery(),
|
query = parseQuery(),
|
||||||
urlSpread = query["spread"],
|
urlSpread = query["spread"],
|
||||||
|
urlChannelId = query["channelId"],
|
||||||
vconsole = query[cookieName.toLowerCase()],
|
vconsole = query[cookieName.toLowerCase()],
|
||||||
md5Crmeb = "b14d1e9baeced9bb7525ab19ee35f2d2", //CRMEB MD5 加密开启vconsole模式
|
md5Crmeb = "b14d1e9baeced9bb7525ab19ee35f2d2", //CRMEB MD5 加密开启vconsole模式
|
||||||
md5UnCrmeb = "3dca2162c4e101b7656793a1af20295c"; //UN_CREMB MD5 加密关闭vconsole模式
|
md5UnCrmeb = "3dca2162c4e101b7656793a1af20295c"; //UN_CREMB MD5 加密关闭vconsole模式
|
||||||
|
@ -44,13 +45,13 @@ let cookieName = "VCONSOLE",
|
||||||
name: 'spread',
|
name: 'spread',
|
||||||
value: urlSpread,
|
value: urlSpread,
|
||||||
})
|
})
|
||||||
// var spread = Cache.get(SPREAD);
|
}
|
||||||
// urlSpread = parseInt(urlSpread);
|
if (urlChannelId) {
|
||||||
// if (!Number.isNaN(urlSpread) && spread !== urlSpread) {
|
urlChannelId = parseInt(urlChannelId);
|
||||||
// Cache.set("spread", urlSpread || 0);
|
Cache.setItem({
|
||||||
// } else if (spread === 0 || typeof spread !== "number") {
|
name: 'channelId',
|
||||||
// Cache.set("spread", urlSpread || 0);
|
value: urlChannelId,
|
||||||
// }
|
})
|
||||||
}
|
}
|
||||||
if (vconsole !== undefined) {
|
if (vconsole !== undefined) {
|
||||||
if (vconsole === md5UnCrmeb && Cache.has(cookieName))
|
if (vconsole === md5UnCrmeb && Cache.has(cookieName))
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
{
|
{
|
||||||
"name" : "先享后付",
|
"name" : "先享后付",
|
||||||
"appid" : "__UNI__C7D69AA", //wxb74514b47a2f29d4 wx46c3a73d8c4f7051 __UNI__EB8A7B
|
"appid" : "__UNI__E7B7107", //wxb74514b47a2f29d4 wx46c3a73d8c4f7051 __UNI__EB8A7B
|
||||||
"description" : "crmeb商城",
|
"description" : "crmeb商城",
|
||||||
"versionName" : "2.1",
|
"versionName" : "2.1",
|
||||||
"versionCode" : 2,
|
"versionCode" : 2,
|
||||||
|
@ -219,8 +219,7 @@
|
||||||
"async" : {
|
"async" : {
|
||||||
"timeout" : 200000
|
"timeout" : 200000
|
||||||
},
|
},
|
||||||
"title" : "先享后付",
|
"title" : "先享后付"
|
||||||
"template" : "template.html"
|
|
||||||
},
|
},
|
||||||
"plus" : {
|
"plus" : {
|
||||||
"statusbar" : {
|
"statusbar" : {
|
||||||
|
|
|
@ -368,7 +368,7 @@
|
||||||
import shareRedPackets from '@/components/shareRedPackets';
|
import shareRedPackets from '@/components/shareRedPackets';
|
||||||
import cusPreviewImg from '@/components/cus-previewImg/cus-previewImg.vue'
|
import cusPreviewImg from '@/components/cus-previewImg/cus-previewImg.vue'
|
||||||
import {
|
import {
|
||||||
silenceBindingSpread
|
silenceBindingSpread,silenceBindingChannelId
|
||||||
} from "@/utils";
|
} from "@/utils";
|
||||||
import parser from "@/components/jyf-parser/jyf-parser";
|
import parser from "@/components/jyf-parser/jyf-parser";
|
||||||
import {
|
import {
|
||||||
|
@ -550,6 +550,8 @@
|
||||||
this.getTokenIsExist();
|
this.getTokenIsExist();
|
||||||
},
|
},
|
||||||
onLoad(options) {
|
onLoad(options) {
|
||||||
|
// console.log(JSON.stringify(options),"options.spread")
|
||||||
|
alert("options.spread"+JSON.stringify(options))
|
||||||
//用户从分享卡片进入的场景下获取主题色配置
|
//用户从分享卡片进入的场景下获取主题色配置
|
||||||
this.$set(this, 'theme', this.$Cache.get('theme'));
|
this.$set(this, 'theme', this.$Cache.get('theme'));
|
||||||
|
|
||||||
|
@ -607,6 +609,7 @@
|
||||||
// #endif
|
// #endif
|
||||||
|
|
||||||
if (options.spread) app.globalData.spread = options.spread;
|
if (options.spread) app.globalData.spread = options.spread;
|
||||||
|
if (options.channelId) app.globalData.channelId = options.channelId;
|
||||||
|
|
||||||
this.getGoodsDetails(); //商品详情
|
this.getGoodsDetails(); //商品详情
|
||||||
this.getCouponType(); //获取默认的 优惠券类型
|
this.getCouponType(); //获取默认的 优惠券类型
|
||||||
|
@ -683,6 +686,7 @@
|
||||||
this.getCartCount(true); //购物车数量
|
this.getCartCount(true); //购物车数量
|
||||||
//绑定关系
|
//绑定关系
|
||||||
if (parseInt(app.globalData.spread) > 0) silenceBindingSpread();
|
if (parseInt(app.globalData.spread) > 0) silenceBindingSpread();
|
||||||
|
if (parseInt(app.globalData.channelId) > 0) silenceBindingChannelId();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
|
@ -210,7 +210,7 @@
|
||||||
getGroomList
|
getGroomList
|
||||||
} from '@/api/store.js';
|
} from '@/api/store.js';
|
||||||
import {
|
import {
|
||||||
silenceBindingSpread,
|
silenceBindingSpread,silenceBindingChannelId,
|
||||||
getCityList
|
getCityList
|
||||||
} from '@/utils';
|
} from '@/utils';
|
||||||
import animationType from '@/utils/animationType.js'
|
import animationType from '@/utils/animationType.js'
|
||||||
|
@ -418,8 +418,10 @@
|
||||||
let qrCodeValue = this.$util.getUrlParams(decodeURIComponent(options.scene));
|
let qrCodeValue = this.$util.getUrlParams(decodeURIComponent(options.scene));
|
||||||
let mapeMpQrCodeValue = this.$util.formatMpQrCodeData(qrCodeValue);
|
let mapeMpQrCodeValue = this.$util.formatMpQrCodeData(qrCodeValue);
|
||||||
app.globalData.spread = mapeMpQrCodeValue.spread;
|
app.globalData.spread = mapeMpQrCodeValue.spread;
|
||||||
|
app.globalData.channelId = mapeMpQrCodeValue.channelId;
|
||||||
}
|
}
|
||||||
if (options.spread) app.globalData.spread = options.spread; //非小程序扫码进入情况下,直接获取url中的分销员id保存在globalDta中
|
if (options.spread) app.globalData.spread = options.spread; //非小程序扫码进入情况下,直接获取url中的分销员id保存在globalDta中
|
||||||
|
if (options.channelId) app.globalData.channelId = options.channelId; //非小程序扫码进入情况下,直接获取url中的分销员id保存在globalDta中
|
||||||
// #endif
|
// #endif
|
||||||
// #ifndef MP || APP-PLUS
|
// #ifndef MP || APP-PLUS
|
||||||
this.navH = 0;
|
this.navH = 0;
|
||||||
|
@ -431,6 +433,12 @@
|
||||||
if (this.isLogin && parseInt(app.globalData.spread) > 0) {
|
if (this.isLogin && parseInt(app.globalData.spread) > 0) {
|
||||||
silenceBindingSpread()
|
silenceBindingSpread()
|
||||||
}
|
}
|
||||||
|
if (this.isLogin && parseInt(app.globalData.channelId) > 0) {
|
||||||
|
silenceBindingChannelId()
|
||||||
|
}
|
||||||
|
if (this.isLogin && parseInt(options.channelId) > 0) {
|
||||||
|
silenceBindingChannelId()
|
||||||
|
}
|
||||||
},
|
},
|
||||||
onShow() {
|
onShow() {
|
||||||
let self = this;
|
let self = this;
|
||||||
|
|
|
@ -146,8 +146,9 @@
|
||||||
//if(!code) location.replace(decodeURIComponent(decodeURIComponent(option.query.back_url)));
|
//if(!code) location.replace(decodeURIComponent(decodeURIComponent(option.query.back_url)));
|
||||||
if (code && this.options.scope !== 'snsapi_base') {
|
if (code && this.options.scope !== 'snsapi_base') {
|
||||||
let spread = app.globalData.spread ? app.globalData.spread : 0;
|
let spread = app.globalData.spread ? app.globalData.spread : 0;
|
||||||
|
let channelId = app.globalData.channelId ? app.globalData.channelId : 0;
|
||||||
//公众号授权登录回调 wechatAuth(code, Cache.get("spread"), loginType)
|
//公众号授权登录回调 wechatAuth(code, Cache.get("spread"), loginType)
|
||||||
wechat.auth(code, spread).then(res => {
|
wechat.auth(code, spread,channelId).then(res => {
|
||||||
if (res.type === 'register') {
|
if (res.type === 'register') {
|
||||||
this.authKey = res.key;
|
this.authKey = res.key;
|
||||||
this.isUp = true
|
this.isUp = true
|
||||||
|
@ -252,6 +253,7 @@
|
||||||
let userInfo = {};
|
let userInfo = {};
|
||||||
userInfo.code = code;
|
userInfo.code = code;
|
||||||
userInfo.spread_spid = app.globalData.spread; //获取推广人ID
|
userInfo.spread_spid = app.globalData.spread; //获取推广人ID
|
||||||
|
userInfo.channelId = app.globalData.channelId; //渠道ID
|
||||||
userInfo.avatar = '';
|
userInfo.avatar = '';
|
||||||
userInfo.nickName = '微信用户';
|
userInfo.nickName = '微信用户';
|
||||||
userInfo.type = 'routine'
|
userInfo.type = 'routine'
|
||||||
|
@ -267,6 +269,7 @@
|
||||||
let userInfo = res.userInfo;
|
let userInfo = res.userInfo;
|
||||||
userInfo.code = code;
|
userInfo.code = code;
|
||||||
userInfo.spread_spid = app.globalData.spread; //获取推广人ID
|
userInfo.spread_spid = app.globalData.spread; //获取推广人ID
|
||||||
|
userInfo.channelId = app.globalData.channelId; //渠道ID
|
||||||
userInfo.avatar = userInfo.userInfo.avatarUrl;
|
userInfo.avatar = userInfo.userInfo.avatarUrl;
|
||||||
userInfo.city = userInfo.userInfo.city;
|
userInfo.city = userInfo.userInfo.city;
|
||||||
userInfo.country = userInfo.userInfo.country;
|
userInfo.country = userInfo.userInfo.country;
|
||||||
|
@ -306,6 +309,9 @@
|
||||||
if (app.globalData.spread) {
|
if (app.globalData.spread) {
|
||||||
spread(app.globalData.spread).then(res => {}) //登录成功后读取spread绑定分销关系
|
spread(app.globalData.spread).then(res => {}) //登录成功后读取spread绑定分销关系
|
||||||
}
|
}
|
||||||
|
if (app.globalData.channelId) {
|
||||||
|
channelId(app.globalData.channelId).then(res => {}) //登录成功后读取渠道绑定关系
|
||||||
|
}
|
||||||
self.$util.Tips({
|
self.$util.Tips({
|
||||||
title: res,
|
title: res,
|
||||||
icon: 'success'
|
icon: 'success'
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
|
|
||||||
|
|
||||||
import { spread } from "@/api/user";
|
import { spread,channel } from "@/api/user";
|
||||||
import Cache from "@/utils/cache";
|
import Cache from "@/utils/cache";
|
||||||
import { getCity } from '@/api/api.js';
|
import { getCity } from '@/api/api.js';
|
||||||
|
|
||||||
|
@ -35,6 +35,37 @@ export function silenceBindingSpread() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 静默授权绑定渠道,使用在已经登录后扫描了别人的推广二维码
|
||||||
|
* @param {Object} puid
|
||||||
|
*/
|
||||||
|
export function silenceBindingChannelId() {
|
||||||
|
//#ifdef H5
|
||||||
|
let puid = Cache.get('channelId');
|
||||||
|
//#endif
|
||||||
|
//#ifdef MP || APP-PLUS
|
||||||
|
let puid = getApp().globalData.channelId;
|
||||||
|
//#endif
|
||||||
|
|
||||||
|
puid = parseInt(puid);
|
||||||
|
if (Number.isNaN(puid)) {
|
||||||
|
puid = 0;
|
||||||
|
}
|
||||||
|
if (puid) {
|
||||||
|
channel(puid).then(res => {}).catch(res => {
|
||||||
|
//#ifdef H5
|
||||||
|
Cache.clear("channelId");
|
||||||
|
//#endif
|
||||||
|
|
||||||
|
//#ifdef MP || APP-PLUS
|
||||||
|
getApp().globalData.channelId = 0;
|
||||||
|
//#endif
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
Cache.set('channelId', 0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
export function isWeixin() {
|
export function isWeixin() {
|
||||||
return navigator.userAgent.toLowerCase().indexOf("micromessenger") !== -1;
|
return navigator.userAgent.toLowerCase().indexOf("micromessenger") !== -1;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user