张文飞 3 年 前
コミット
341f32a99b
1 ファイル変更26 行追加24 行削除
  1. 26 24
      App.vue

+ 26 - 24
App.vue

@@ -42,31 +42,33 @@
 			},
 			async regist() {
 				let code  = this.getQueryString('code'); 
-				let ret = await this.$myRequest({
-					url: "/regist",
-					data: {
-						"code": code,
-						"shareToken":this.globalData.shareToken||"",
-						"projectId":this.globalData.projectId||"",
+				if(code){
+					let ret = await this.$myRequest({
+						url: "/regist",
+						data: {
+							"code": code,
+							"shareToken":this.globalData.shareToken||"",
+							"projectId":this.globalData.projectId||"",
+						}
+					});
+					if (ret.data.success) {
+						let userId = ret.data.single.userId;
+						this.globalData.userId = userId;
+						if (ret.data.single.authed == 1) {
+							let token = ret.data.single.token;
+							this.globalData.token = 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;
 					}
-				});
-				if (ret.data.success) {
-					let userId = ret.data.single.userId;
-					this.globalData.userId = userId;
-					if (ret.data.single.authed == 1) {
-						let token = ret.data.single.token;
-						this.globalData.token = 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+"?shareToken="+shareToken+"&projectId="+projectId+"&state="+state+"&pathName="+hrefs[1];
-					window.location.href = url;
 				}
 			},
 		},