Просмотр исходного кода

fix bug: 解决app无法拉取小程序问题

shizhongqi 4 лет назад
Родитель
Сommit
46023a641d

+ 21 - 29
ghsApp/src/admin/item/components/ItemStock.vue

@@ -66,42 +66,34 @@ export default {
 			// #endif
 
 			// #ifdef APP-PLUS
+			let that = this
 			if(plus.runtime.isApplicationExist({pname:'com.tencent.mm',action:'weixin://'})){
-        uni.login({
-					provider: 'weixin',
-					success: function (loginRes) {
-						var sweixin
+				var sweixin
 
-						plus.share.getServices(function(s){
-							for (var i = 0; i < s.length; i++) {
-								var t = s[i];
-								if (t.id == 'weixin') {
-									sweixin = t;
-								}
-							}
+				plus.share.getServices(function(s){
+					for (var i = 0; i < s.length; i++) {
+						var t = s[i];
+						if (t.id == 'weixin') {
+							sweixin = t;
+						}
+					}
 
-							if (sweixin && sweixin.nativeClient) {
-								sweixin.launchMiniProgram({
-									id: 'gh_73b8b357d19a',
-									path: 'admin/item/list',
-									type: 0
-								});
-							} else {
-								this.$msg('请安装微信');
-								return false;
-							}
-						}, function(e){
-							this.$msg("获取微信失败:" + e.message)
-							console.log("获取微信失败:" + e.message);
+					if (sweixin) { //&& sweixin.nativeClient
+						sweixin.launchMiniProgram({
+							id: 'gh_73b8b357d19a',
+							path: 'admin/item/list',
+							type: 0
 						});
-					},
-					fail: function (res) {
-						this.$msg("当前环境不支持微信操作" + JSON.stringify(res))
-						console.log(res)
+					} else {
+						that.$msg('请安装微信');
+						return false;
 					}
+				}, function(e){
+					that.$msg("获取微信失败:" + e.message)
+					console.log(JSON.stringify(e));
 				});
     	}else{
-        this.$msg("微信应用未安装")
+        that.$msg("微信应用未安装")
 				return false
     	}
 			// #endif

+ 7 - 5
hdApp/src/admin/home/login.vue

@@ -222,12 +222,14 @@ export default {
 								//有几个地方涉及登陆,需要统一方法,请搜索关键词 uni_login
 								if(subRes.code == 1){
 									if (that.$util.isEmpty(subRes)) {
+										uni.showToast({title:'subRes is empty', duration: 3000, icon:'none'})
 										return false
 									}
 									uni.setStorageSync('token', subRes.data.token)
 									uni.setStorageSync('shopId', subRes.data.admin.currentShopId)
 									getDictionaries({ token: subRes.data.token }).then(res => {
 										if (that.$util.isEmpty(res)) {
+											uni.showToast({title:'getDictionaries get empty', duration: 3000, icon:'none'})
 											return false
 										}
 										that.$store.commit('setDictionariesInfo', { ...res.data.dict, ...res.data })
@@ -251,13 +253,11 @@ export default {
 						},
 						fail(res){
 							console.log(res)
+							uni.showToast({title:'univerify fail: ' + JSON.stringify(res), duration: 3000, icon:'none'})
 							// 登录失败
 							//关闭一键登录弹出窗口
 							uni.closeAuthView()
 							//uni.hideLoading()
-							setTimeout(function(){
-								//uni.showToast({ title: '登录失败,请打开流量,关闭wifi,再登录', duration: 3000, icon:'none' })
-							},1000)
 						},
 						complete: (res) => {
 							console.log(res)
@@ -268,12 +268,14 @@ export default {
 				},
 				fail(res){
 					console.log(res)
+
 					// 预登录失败
-					//如果手机没有插入有效的sim卡,或者手机蜂窝数据网络关闭
-					//都有可能造成预登录校验失败
+					//如果手机没有插入有效的sim卡,或者手机蜂窝数据网络关闭,都有可能造成预登录校验失败
 					if (res.code == 30005) {
 						//that.$msg('登录失败,请打开流量,再登录')
 						uni.showToast({title: '登录失败,请打开流量,或安装上手机卡', duration: 3000, icon:'none'})
+					} else {
+						uni.showToast({title: 'preLogin fail: ' + JSON.stringify(res), duration: 3000, icon:'none'})
 					}
 				}
 			})

+ 19 - 28
hdApp/src/admin/home/workbench.vue

@@ -155,38 +155,29 @@ export default {
 
       // #ifdef APP-PLUS
       if(plus.runtime.isApplicationExist({pname:'com.tencent.mm',action:'weixin://'})){
-        uni.login({
-          provider: 'weixin',
-          success: function (loginRes) {
-            var sweixin
+        var sweixin
 
-            plus.share.getServices(function(s){
-              for (var i = 0; i < s.length; i++) {
-                var t = s[i];
-                if (t.id == 'weixin') {
-                    sweixin = t;
-                }
-              }
+        plus.share.getServices(function(s){
+          for (var i = 0; i < s.length; i++) {
+            var t = s[i];
+            if (t.id == 'weixin') {
+                sweixin = t;
+            }
+          }
 
-              if (sweixin && sweixin.nativeClient) {
-                sweixin.launchMiniProgram({
-                  id: 'gh_73b8b357d19a',
-                  path: '/pagesPurchase/order',
-                  type: 0
-                });
-              } else {
-                this.$msg('请安装微信');
-                return false;
-              }
-            }, function(e){
-              this.$msg("获取微信失败:" + e.message)
-              console.log("获取微信失败:" + e.message);
+          if (sweixin && sweixin.nativeClient) {
+            sweixin.launchMiniProgram({
+              id: 'gh_73b8b357d19a',
+              path: '/pagesPurchase/order',
+              type: 0
             });
-          },
-          fail: function (res) {
-            this.$msg("当前环境不支持微信操作" + JSON.stringify(res))
-            console.log(res)
+          } else {
+            this.$msg('请安装微信');
+            return false;
           }
+        }, function(e){
+          this.$msg("获取微信失败:" + e.message)
+          console.log("获取微信失败:" + e.message);
         });
       } else {
         this.$msg("微信应用未安装")