he2802 hace 4 años
padre
commit
a9d105056c
Se han modificado 1 ficheros con 19 adiciones y 0 borrados
  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) {
 				//用户同意授权