he2802 před 4 roky
rodič
revize
a9d105056c
1 změnil soubory, kde provedl 19 přidání a 0 odebrání
  1. 19 0
      pages/login/login.vue

+ 19 - 0
pages/login/login.vue

@@ -16,6 +16,25 @@ export default {
 	mounted() {},
 	methods: {
 		getPhoneNumber(e) {
+			let that = this;
+			uni.checkSession({
+			  success () {
+			    //session_key 未过期,并且在本生命周期一直有效
+				that.putInfo(e)
+			  },
+			  fail () {
+			    // session_key 已经失效,需要重新执行登录流程
+			    uni.login({
+			    	provider: 'weixin',
+			    	success: function(loginRes) {
+			    		that.code = loginRes.code;
+						that.putInfo(e)
+			    	}
+			    });
+			  }
+			})
+		},
+		putInfo(e){
 			let that = this;
 			if (e.detail.encryptedData) {
 				//用户同意授权