Explorar el Código

修改获取openid

zs hace 1 año
padre
commit
0208e86e5a

+ 1 - 1
App.vue

@@ -21,7 +21,7 @@
 								key: 'openid',
 								success: function(res) {},
 								fail: async function(err) {
-									const aee = await that.$api('/tool/app', 'GET', {
+									const aee = await that.$api('/login/app', 'GET', {
 										js_code: res.code,
 										config: that.$config.wx_projectkey
 									})

+ 20 - 20
pages/index/index.vue

@@ -37,26 +37,26 @@
 			},
 			async searchOpenid() {
 				const that = this;
-				// try {
-				// 	const res = uni.getStorageSync('openid');
-				// 	const aee = await that.$api(`/login/wxapp/${res}`, 'POST', {})
-				// 	if (aee.errcode == '0') {
-				// 		uni.reLaunch({
-				// 			url: `/pages/home/index`
-				// 		})
-				// 	} else {
-				// 		uni.showToast({
-				// 			title: aee.errmsg,
-				// 			icon: 'none'
-				// 		})
-				// 	}
-				// } catch (e) {
-				// 	uni.showToast({
-				// 		title: err.errmsg,
-				// 		icon: 'error',
-				// 		duration: 2000
-				// 	});
-				// }
+				try {
+					const res = uni.getStorageSync('openid');
+					const aee = await that.$api(`/login/app/${res}`, 'POST', {})
+					if (aee.errcode == '0') {
+						uni.reLaunch({
+							url: `/pages/home/index`
+						})
+					} else {
+						uni.showToast({
+							title: aee.errmsg,
+							icon: 'none'
+						})
+					}
+				} catch (e) {
+					uni.showToast({
+						title: err.errmsg,
+						icon: 'error',
+						duration: 2000
+					});
+				}
 				uni.reLaunch({
 					url: `/pages/home/index`
 				})

La diferencia del archivo ha sido suprimido porque es demasiado grande
+ 1 - 1
unpackage/dist/dev/.sourcemap/mp-weixin/common/main.js.map


La diferencia del archivo ha sido suprimido porque es demasiado grande
+ 1 - 1
unpackage/dist/dev/.sourcemap/mp-weixin/pages/index/index.js.map


+ 1 - 1
unpackage/dist/dev/mp-weixin/common/main.js

@@ -143,7 +143,7 @@ var _default = {
                       switch (_context.prev = _context.next) {
                         case 0:
                           _context.next = 2;
-                          return that.$api('/tool/app', 'GET', {
+                          return that.$api('/login/app', 'GET', {
                             js_code: res.code,
                             config: that.$config.wx_projectkey
                           });

+ 31 - 23
unpackage/dist/dev/mp-weixin/pages/index/index.js

@@ -249,40 +249,48 @@ var _default = {
     searchOpenid: function searchOpenid() {
       var _this2 = this;
       return (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee3() {
-        var that;
+        var that, res, aee;
         return _regenerator.default.wrap(function _callee3$(_context3) {
           while (1) {
             switch (_context3.prev = _context3.next) {
               case 0:
-                that = _this2; // try {
-                // 	const res = uni.getStorageSync('openid');
-                // 	const aee = await that.$api(`/login/wxapp/${res}`, 'POST', {})
-                // 	if (aee.errcode == '0') {
-                // 		uni.reLaunch({
-                // 			url: `/pages/home/index`
-                // 		})
-                // 	} else {
-                // 		uni.showToast({
-                // 			title: aee.errmsg,
-                // 			icon: 'none'
-                // 		})
-                // 	}
-                // } catch (e) {
-                // 	uni.showToast({
-                // 		title: err.errmsg,
-                // 		icon: 'error',
-                // 		duration: 2000
-                // 	});
-                // }
+                that = _this2;
+                _context3.prev = 1;
+                res = uni.getStorageSync('openid');
+                _context3.next = 5;
+                return that.$api("/login/app/".concat(res), 'POST', {});
+              case 5:
+                aee = _context3.sent;
+                if (aee.errcode == '0') {
+                  uni.reLaunch({
+                    url: "/pages/home/index"
+                  });
+                } else {
+                  uni.showToast({
+                    title: aee.errmsg,
+                    icon: 'none'
+                  });
+                }
+                _context3.next = 12;
+                break;
+              case 9:
+                _context3.prev = 9;
+                _context3.t0 = _context3["catch"](1);
+                uni.showToast({
+                  title: err.errmsg,
+                  icon: 'error',
+                  duration: 2000
+                });
+              case 12:
                 uni.reLaunch({
                   url: "/pages/home/index"
                 });
-              case 2:
+              case 13:
               case "end":
                 return _context3.stop();
             }
           }
-        }, _callee3);
+        }, _callee3, null, [[1, 9]]);
       }))();
     }
   }