zs 1 year ago
parent
commit
e77d6dbf64
2 changed files with 38 additions and 20 deletions
  1. 18 18
      pages/index/index.vue
  2. 20 2
      unpackage/dist/dev/mp-weixin/pages/index/index.js

+ 18 - 18
pages/index/index.vue

@@ -45,24 +45,24 @@
 							uni.reLaunch({
 								url: `/pages/home/index`
 							})
-							// const aee = await $app('/wechat/api/login/app', 'GET', {
-							// 	js_code: res.code,
-							// 	config: $config.wx_projectkey
-							// })
-							// if (aee.errcode == '0') {
-							// 	uni.setStorage({
-							// 		key: "openid",
-							// 		data: aee.data.openid
-							// 	})
-							// 	uni.reLaunch({
-							// 		url: `/pages/home/index`
-							// 	})
-							// } else {
-							// 	uni.showToast({
-							// 		title: aee.errmsg,
-							// 		icon: 'none'
-							// 	})
-							// }
+							const aee = await $app('/wechat/api/login/app', 'GET', {
+								js_code: res.code,
+								config: $config.wx_projectkey
+							})
+							if (aee.errcode == '0') {
+								uni.setStorage({
+									key: "openid",
+									data: aee.data.openid
+								})
+								uni.reLaunch({
+									url: `/pages/home/index`
+								})
+							} else {
+								uni.showToast({
+									title: aee.errmsg,
+									icon: 'none'
+								})
+							}
 						} else {
 							uni.showToast({
 								title: res.errMsg,

+ 20 - 2
unpackage/dist/dev/mp-weixin/pages/index/index.js

@@ -5,8 +5,8 @@ const _sfc_main = /* @__PURE__ */ common_vendor.defineComponent({
   setup(__props) {
     var _a, _b, _c;
     const $api = (_a = common_vendor.getCurrentInstance()) == null ? void 0 : _a.appContext.config.globalProperties.$api;
-    (_b = common_vendor.getCurrentInstance()) == null ? void 0 : _b.appContext.config.globalProperties.$app;
-    (_c = common_vendor.getCurrentInstance()) == null ? void 0 : _c.appContext.config.globalProperties.$config;
+    const $app = (_b = common_vendor.getCurrentInstance()) == null ? void 0 : _b.appContext.config.globalProperties.$app;
+    const $config = (_c = common_vendor.getCurrentInstance()) == null ? void 0 : _c.appContext.config.globalProperties.$config;
     const config = common_vendor.ref({ logo: [] });
     common_vendor.onLoad(async () => {
       await searchConfig();
@@ -37,6 +37,24 @@ const _sfc_main = /* @__PURE__ */ common_vendor.defineComponent({
                 common_vendor.index.reLaunch({
                   url: `/pages/home/index`
                 });
+                const aee = await $app("/wechat/api/login/app", "GET", {
+                  js_code: res.code,
+                  config: $config.wx_projectkey
+                });
+                if (aee.errcode == "0") {
+                  common_vendor.index.setStorage({
+                    key: "openid",
+                    data: aee.data.openid
+                  });
+                  common_vendor.index.reLaunch({
+                    url: `/pages/home/index`
+                  });
+                } else {
+                  common_vendor.index.showToast({
+                    title: aee.errmsg,
+                    icon: "none"
+                  });
+                }
               } else {
                 common_vendor.index.showToast({
                   title: res.errMsg,