lilei 4 tahun lalu
induk
melakukan
fbd21fc8f8
2 mengubah file dengan 37 tambahan dan 6 penghapusan
  1. 1 1
      libs/axios.js
  2. 36 5
      pages/index/index.vue

+ 1 - 1
libs/axios.js

@@ -55,7 +55,7 @@ const request = (opts, hasToken) => {
 						}
 					}
 					else{
-						if(ret.status == 500){
+						if(ret.status == 500 || ret.status == 900){
 							if(opts.url.indexOf("store/validateStoreAndDevice")<0&&opts.url.indexOf("couponReceives/findUsableCoupon")<0){
 								uni.showToast({
 									icon:'none',

+ 36 - 5
pages/index/index.vue

@@ -37,6 +37,7 @@
 			return {
 				deviceList:[], // 设备列表
 				deviceId: null,
+				iosMac: null,
 				connectedDeviceId: '',
 				services: [],
 				readsId:'',
@@ -51,7 +52,6 @@
 			}
 		},
 		onLoad() {
-			console.log('onload')
 			let _this = this
 			uni.$on('blueReConnect',function(){
 				uni.showLoading({
@@ -60,6 +60,11 @@
 				})
 				_this.connectBlue()
 			})
+			
+			// 系统信息
+			const sysinfo = uni.getSystemInfoSync();
+			this.platform = sysinfo.platform
+			console.log(sysinfo,'sysinfo')
 		},
 		onShow() {
 			// 获取订单状态数据字典
@@ -99,9 +104,32 @@
 				let _this = this
 				// 连接成功
 				if(this.connectStatus){
-					uni.navigateTo({
-						url: '/pages/userAuth/userAuth?deviceId=' + _this.deviceId
-					})
+					// ios 设备无法获取mac地址,请手动扫描电子秤的MAC条形码
+					if(this.platform == 'ios'&&this.iosMac==null){
+						uni.showModal({
+								title:'提示',
+								content: '苹果手机无法获取mac地址,请手动扫描电子秤的MAC条形码',
+								confirmText: '去扫描',
+								complete(e) {
+									if(e.confirm){
+										uni.scanCode({
+											success(res) {
+												console.log(res)
+												_this.iosMac = res.result
+												uni.navigateTo({
+													url: '/pages/userAuth/userAuth?deviceId=' + _this.iosMac
+												})
+											}
+										})
+									}
+								}
+							})
+					}else{
+						// 安卓系统直接跳转
+						uni.navigateTo({
+							url: '/pages/userAuth/userAuth?deviceId=' + (this.platform == 'ios' ? _this.iosMac : _this.deviceId)
+						})
+					}
 				}else{
 					let hasDev = this.deviceList.length
 					if(!this.loading){
@@ -127,7 +155,6 @@
 			// 初始化蓝牙
 			toInit(){
 				let _this = this
-				console.log(this.connectStatus,this.deviceList.length,this.loading)
 				if(this.connectStatus || this.deviceList.length > 0 || this.loading){
 					return
 				}
@@ -216,6 +243,7 @@
 				if(this.connectStatus){
 					return
 				}
+				// ios 的deviceid 不是真正的mac 地址
 				if(item){
 					this.deviceId = item.deviceId
 				}
@@ -416,6 +444,7 @@
 			            success: function(res) {
 							console.log(res)
 							that.deviceId = null
+							that.iosMac = null
 							that.closeBluetoothAdapter()
 			            },
 			            fail(res) {
@@ -436,6 +465,8 @@
 						that.loading = false
 						that.balanceData = ''
 						that.deviceList = []
+						that.deviceId = null
+						that.iosMac = null
 			        },
 			        fail: function(err) {
 			        }