浏览代码

扫码修改

twt 2 年之前
父节点
当前提交
f4fa57e5af
共有 4 个文件被更改,包括 60 次插入23 次删除
  1. 2 2
      common/request.js
  2. 9 7
      pages.json
  3. 37 12
      pages/user/scanCode.vue
  4. 12 2
      pages/user/shopidgo.vue

+ 2 - 2
common/request.js

@@ -1,6 +1,6 @@
- //const baseURL = 'https://api.dms.66km.com/'
+const baseURL = 'https://api.dms.66km.com/'
 //const baseURL='http://wx.32che.cn/'
-const baseURL='http://api.dms.66km.com.cn/'
+//const baseURL='http://api.dms.66km.com.cn/'
 
   // baseURL: 'http://192.168.0.140:20187',
 //authorizaURL: 'https://api.dms.66km.com/weixin/authorize',

+ 9 - 7
pages.json

@@ -1,31 +1,33 @@
 {
 	"pages": [ //pages数组中第一项表示应用启动页,参考:https://uniapp.dcloud.io/collocation/pages
 		
+		
 		{
 			"path": "pages/index/index",
 			"style": {
 				"navigationStyle": "custom"
 			}
 		},
-		{
-			"path": "pages/user/scanCode",
-			"style": {
-				"navigationBarTitleText": "扫码"
-			}
-		},
 		{
 			"path": "pages/user/shopidgo",
 			"style": {
 				"navigationStyle": "custom"
 			}
 		},
-		
 		{
 			"path": "pages/login/empower",
 			"style": {
 				"navigationBarTitleText": "授权登录"
 			}
 		},
+		{
+			"path": "pages/user/scanCode",
+			"style": {
+				"navigationBarTitleText": "扫码"
+			}
+		},
+		
+		
 		{
 			"path": "pages/index/signOut",
 			"style": {

+ 37 - 12
pages/user/scanCode.vue

@@ -20,24 +20,49 @@
 			   var that=this;
 			   uni.scanCode({
 			       success: function (res) {
-			           console.log('条码类型:' + res.scanType);
-			           console.log('条码内容:' + res.result);
-					   that.url=res.result;
-					   that.shopId=that.getHashQuery('shopId')
-					   if(that.shopId){
-						    that.gologin()
+					   console.log(res)
+					    console.log('条码类型:' + res.scanType);
+					   if(res.scanType=='WX_CODE'){
+						   that.url=res.path;
+						   that.shopId=that.getHashQuery('scene')
+						   that.shopId=that.insertStr(that.shopId,8,"-");
+						   that.shopId=that.insertStr(that.shopId,13,"-");
+						   that.shopId=that.insertStr(that.shopId,18,"-");
+						   that.shopId=that.insertStr(that.shopId,23,"-");
+						   console.log(that.shopId)
+						   if(that.shopId){
+						   		that.gologin()
+						   }else{
+							   uni.showToast({
+								title: '请扫码正确的二维码',
+								icon: 'none',
+								duration: 3000
+							   });
+						   }
 					   }else{
-						   uni.showToast({
-						   	title: '请扫码正确的二维码',
-						   	icon: 'none',
-						   	duration: 3000
-						   });
+						   console.log('条码内容:' + res.result);
+						   that.url=res.result;
+						   that.shopId=that.getHashQuery('shopId')
+						   if(that.shopId){
+						   		that.gologin()
+						   }else{
+							   uni.showToast({
+								title: '请扫码正确的二维码',
+								icon: 'none',
+								duration: 3000
+							   });
+						   }
 					   }
-					   console.log(that.shopId)
+			          
+			          
+					   
 					  
 			       }
 			   });
 		   },
+		   insertStr(soure, start, newStr){   
+		      return soure.slice(0, start) + newStr + soure.slice(start);
+		   },
 		   gologin(){
 			 uni.navigateTo({
 			 	url:'../login/login?shopId='+this.shopId

+ 12 - 2
pages/user/shopidgo.vue

@@ -13,9 +13,16 @@
 			}
 		},
 		onLoad(opt) {
-            if(opt.shopId){
+            if(opt.scene){
+				var num=opt.scene;
+				//var num = 'AFA7C75619124C70802A19437DDD80A7'
+				var shopId=this.insertStr(num,8,"-");
+					shopId=this.insertStr(shopId,13,"-");
+					shopId=this.insertStr(shopId,18,"-");
+					shopId=this.insertStr(shopId,23,"-");
+					console.log(shopId)
 				uni.reLaunch ({
-					url:'../login/empower?shopId='+opt.shopId
+					url:'../login/empower?shopId='+shopId
 				})
 			}else{
 				//var shopId='1F12DB68-D8E8-4B76-9E20-287ACB72889F'
@@ -25,6 +32,9 @@
 			}
 		},
 		methods: {
+			insertStr(soure, start, newStr){
+			   return soure.slice(0, start) + newStr + soure.slice(start);
+			},
            scan(){
 			   var that=this;
 			   uni.scanCode({