Ver código fonte

登录,查询openid方式修改

guhongwei 2 anos atrás
pai
commit
951f651b02
1 arquivos alterados com 17 adições e 8 exclusões
  1. 17 8
      pages/login/index.vue

+ 17 - 8
pages/login/index.vue

@@ -186,20 +186,29 @@
 				if (system.uniPlatform == "mp-weixin") {
 					uni.login({
 						provider: 'weixin',
-						success: async function(res) {
-							const aee = await that.$api(`/wechat/api/login/app`, 'GET', {
-								config: that.$config.wx_projectkey,
-								js_code: res.code
-							})
-							if (aee.errcode == '0') {
-								that.$set(that, `openid`, aee.data.openid);
-							}
+						success: function(res) {
+							if (res && res.code) that.searchOpenids(res.code)
+						},
+						fail: function(err) {
+							console.log('2');
 						}
 					})
+
 				} else if (system.uniPlatform == "app") {
 					console.log('app');
 				}
 			},
+			async searchOpenids(code) {
+				const that = this;
+				const aee = await that.$api(`/wechat/api/login/app`, 'GET', {
+					config: that.$config.wx_projectkey,
+					js_code: code
+				})
+				if (aee.errcode == '0') {
+					console.log(aee);
+					that.$set(that, `openid`, aee.data.openid);
+				}
+			},
 
 			// 选择登录类型
 			typeChange(e) {