|
@@ -4,27 +4,29 @@
|
|
|
onLaunch: function() {
|
|
|
let href = location.href;
|
|
|
let code = this.getQueryString('code');
|
|
|
+ /**
|
|
|
+ * 解题思路,由于不可抗因素,导致必须想办法,现有如下想法
|
|
|
+ * (一)如是不带code,则为自然进入,给他用微信加code;
|
|
|
+ * (二)如果带了code,则有可能是分享(非图片分享)或者复制链接进来的
|
|
|
+ * bug: 如果之前去掉code,则会进入(一)进入了死循环;
|
|
|
+ * 想法:先去让他带着code去regist,成功则说明是新的code,失败则去掉code进入(一)
|
|
|
+ */
|
|
|
if(!code){
|
|
|
let url = href.split('#')[0];
|
|
|
url = encodeURIComponent(url);
|
|
|
url = "https://open.weixin.qq.com/connect/oauth2/authorize?appid="+config.appid+"&redirect_uri="+url+"&response_type=code&scope=snsapi_userinfo&state=123&connect_redirect=1#wechat_redirect"
|
|
|
window.location.href = url;
|
|
|
- this.$cache.clear();
|
|
|
}
|
|
|
this.globalData.BASE_URL = config.BASE_URL;
|
|
|
},
|
|
|
onShow: function() {
|
|
|
let shareToken = this.getQueryString('shareToken');
|
|
|
let projectId = this.getQueryString('projectId');
|
|
|
+ let pathName = this.getQueryString('pathName');
|
|
|
this.globalData.projectId = projectId||'';
|
|
|
this.globalData.shareToken = shareToken||'';
|
|
|
- let cacheInfo = this.$cache.get('_user_regist');
|
|
|
- if(cacheInfo){
|
|
|
- this.globalData.userId = cacheInfo.userId;
|
|
|
- this.globalData.token = cacheInfo.token;
|
|
|
- }else{
|
|
|
- this.regist();
|
|
|
- }
|
|
|
+ this.globalData.pathName = pathName||'';
|
|
|
+ this.regist();
|
|
|
document.body.style.setProperty("background-color",this.globalData.color4);
|
|
|
},
|
|
|
onHide: function() {
|
|
@@ -39,7 +41,7 @@
|
|
|
return reg.test(location.href) ? unescape(RegExp.$2.replace(/\+/g, " ")) : ""
|
|
|
},
|
|
|
async regist() {
|
|
|
- let code = this.getQueryString('code');
|
|
|
+ let code = this.getQueryString('code');
|
|
|
let ret = await this.$myRequest({
|
|
|
url: "/regist",
|
|
|
data: {
|
|
@@ -55,11 +57,16 @@
|
|
|
let token = ret.data.single.token;
|
|
|
this.globalData.token = token
|
|
|
}
|
|
|
- this.$cache.set("_user_regist",{
|
|
|
- userId:userId,
|
|
|
- token:this.globalData.token
|
|
|
- })
|
|
|
uni.$emit('request')
|
|
|
+ }else{
|
|
|
+ //注册失败,去掉老的code,会进入onLaunch,重新获取新的code
|
|
|
+ let href = location.href;
|
|
|
+ let hrefs = href.split('#');
|
|
|
+ let shareToken = this.getQueryString('shareToken')
|
|
|
+ let projectId = this.getQueryString('projectId')
|
|
|
+ let state = this.getQueryString('state');
|
|
|
+ let url = href.origin+href.pathname+"?shareToken="+shareToken+"&projectId="+projectId+"&state="+state+"&pathName="+hrefs[1];
|
|
|
+ window.location.href = url;
|
|
|
}
|
|
|
},
|
|
|
},
|
|
@@ -68,6 +75,7 @@
|
|
|
userId:"",
|
|
|
projectId:"",
|
|
|
shareToken:"",
|
|
|
+ pathName:"",
|
|
|
color1: "#F07423",
|
|
|
color2: "#FD8F3C",
|
|
|
color3: "#FFC444",
|