张文飞 3 vuotta sitten
vanhempi
commit
8c0e1a0f69
3 muutettua tiedostoa jossa 33 lisäystä ja 21 poistoa
  1. 21 13
      App.vue
  2. 2 2
      components/subComponents/dmWithDrawalRecord.vue
  3. 10 6
      pages/homePage/homePage.vue

+ 21 - 13
App.vue

@@ -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",

+ 2 - 2
components/subComponents/dmWithDrawalRecord.vue

@@ -32,10 +32,10 @@
 							<view class="withDrawal_item_success" v-if="item.cashStatus==1">
 								成功
 							</view>
-							<view class="withDrawal_item_failure" v-if="item.cashStatus==2">
+							<view class="withDrawal_item_failure" v-else-if ="item.cashStatus==2">
 								失败
 							</view>
-							<view class="withDrawal_item_confirmed"  v-if="item.cashStatus==3">
+							<view class="withDrawal_item_confirmed"  v-else>
 								待确认
 							</view>
 						</view>

+ 10 - 6
pages/homePage/homePage.vue

@@ -274,12 +274,8 @@
 				this.$refs.login.hide();
 			})
 			let projectId = this.getQueryString('projectId');
-			if(projectId){
-				let e = {
-					projectId
-				}
-				this.goDetailAction(e,2)
-			}
+			let pathName = this.getQueryString('pathName');
+			this.toPage(pathName,projectId);
 		},
 		onPullDownRefresh() {
 			this.getData();
@@ -292,6 +288,14 @@
 			
 		},
 		methods: {
+			toPage(pathName,projectId){
+				if((projectId&&pathName.indexOf('houseDetail')>-1)||(projectId&&!pathName)){
+					let e = {
+						projectId
+					}
+					this.goDetailAction(e,2)
+				}
+			},
 			getQueryString(name){
 				var reg = new RegExp("(^|\\?|&)"+ name +"=([^&]*)(\\s|&|$)", "i");
 				return reg.test(location.href) ? unescape(RegExp.$2.replace(/\+/g, " ")) : ""