Browse Source

bug 修复

lilei 4 years ago
parent
commit
c9a23a0f41
3 changed files with 44 additions and 23 deletions
  1. 2 2
      App.vue
  2. 26 15
      pages/index/index.vue
  3. 16 6
      pages/userAuth/userAuth.vue

+ 2 - 2
App.vue

@@ -1,6 +1,6 @@
 <script>
-	// const uat_URL = 'https://lese.test.sxzxyj.net/gc-channel/' // 预发布
-	const uat_URL = 'http://192.168.16.104:8303/gc-channel/' // 本地
+	const uat_URL = 'https://lese.test.sxzxyj.net/gc-channel/' // 预发布
+	// const uat_URL = 'http://192.168.16.104:8303/gc-channel/' // 本地
 	const pro_URL = 'https://lese.sxzxyj.net/gc-channel/'  // 生产
 	const buildType = 1 // 打包环境对应类型,1 生产 0 预发布
 	const buildURL = buildType ? pro_URL : uat_URL // 打包后实际对应的url

+ 26 - 15
pages/index/index.vue

@@ -150,6 +150,11 @@
 							}
 						})
 					}
+					uni.getBluetoothDevices({
+					  success(res) {
+					    console.log(res,'getBluetoothDevices')
+					  }
+					})
 				}
 			},
 			// 初始化蓝牙
@@ -165,7 +170,7 @@
 					_this.loading = true
 					setTimeout(()=>{
 						_this.toFindDev()
-					},600)
+					},500)
 				  },
 				  fail(err){
 					  console.log(err,'openBluetoothAdapter error')
@@ -209,8 +214,9 @@
 				  if(!res.available){
 					// 关闭连接
 				  	_this.statusStr = '蓝牙已关闭,请开启手机蓝牙'
-					_this.connectedDeviceId = null
-					_this.closeConnect()
+					_this.loading = false
+					// _this.connectedDeviceId = null
+					// _this.closeConnect()
 				  }else{
 					if(!res.discovering && !_this.loading){
 						_this.statusStr = '蓝牙已启用,请绑定设备'
@@ -223,18 +229,23 @@
 				uni.startBluetoothDevicesDiscovery({
 				  services: [],
 				  success(res) {
-				    console.log(res)
-					// 监听寻找到新设备的事件
-					uni.onBluetoothDeviceFound(function (res) {
-					  let devices = res.devices.filter(item => item.name == 'FAYA')
-					  const hasDev = _this.deviceList.find(item => item.deviceId == res.devices[0].deviceId)
-					  console.log(devices,hasDev,'devices list')
-					  if(devices.length&&!hasDev){
-						  _this.statusStr = '已发现设备'
-						  _this.deviceList = _this.deviceList.concat(res.devices)
-						  _this.loading = false
-					  }
-					})
+				    console.log(res,'startBluetoothDevicesDiscovery')
+				  },
+				  fail(res){
+					  console.log(res,'startBluetoothDevicesDiscovery error')
+				  }
+				})
+				
+				// 监听寻找到新设备的事件
+				uni.onBluetoothDeviceFound(function (res) {
+				  console.log(res,'onBluetoothDeviceFound')
+				  let devices = res.devices.filter(item => item.name == 'FAYA')
+				  const hasDev = _this.deviceList.find(item => item.deviceId == res.devices[0].deviceId)
+				  console.log(devices,hasDev,'devices list')
+				  if(devices.length&&!hasDev){
+					  _this.statusStr = '已发现设备'
+					  _this.deviceList = _this.deviceList.concat(res.devices)
+					  _this.loading = false
 				  }
 				})
 			},

+ 16 - 6
pages/userAuth/userAuth.vue

@@ -23,7 +23,7 @@
 						</view>
 						<view class="info">
 							<view>{{item.rubbishTypeDictValue}}</view>
-							<view class="texts">{{item.rubbishWeight}}g/{{item.goleNum}}乐豆</view>
+							<view class="texts">{{item.rubbishWeight||0}}g/{{item.goleNum||0}}乐豆</view>
 						</view>
 					</view>
 				</view>
@@ -42,7 +42,7 @@
 				<view>投递类型</view>
 				<view>
 					{{curRubbishType.rubbishTypeDictValue}}
-					<text class="des">({{curRubbishType.rubbishWeight}}g/{{curRubbishType.goleNum}}乐豆)</text>
+					<text class="des">({{curRubbishType.rubbishWeight||0}}g/{{curRubbishType.goleNum||0}}乐豆)</text>
 				</view>
 			</view>
 			<view class="form-row form-flex">
@@ -115,7 +115,7 @@
 			// 计算可兑换乐豆
 			goldNum(){
 				let ret = 0
-				if(this.curRubbishType){
+				if(this.curRubbishType&&this.curRubbishType.rubbishWeight&&this.curRubbishType.goleNum){
 					ret = this.balanceData / this.curRubbishType.rubbishWeight / this.curRubbishType.goleNum
 				}
 				return Math.floor(ret)
@@ -199,6 +199,10 @@
 		methods: {
 			// 获取网点信息
 			findBySrcDeviceNo(){
+				uni.showLoading({
+				    title: '加载中',
+					mask: true
+				});
 				findBySrcDeviceNo({srcDeviceCode:this.deviceId}).then(res=>{
 					console.log(res,'====')
 					if(res.status == 200){
@@ -207,10 +211,16 @@
 						this.formData.srcDeviceCode = this.deviceId
 						this.formData.operatorNo = this.$store.state.vuex_userData.id
 					}else{
-						setTimeout(()=>{
-							uni.navigateBack()
-						},500)
+						uni.showModal({
+							title: '提示',
+							content: res.message,
+							showCancel: false,
+							complete(e) {
+								 uni.navigateBack()
+							}
+						})
 					}
+					uni.hideLoading()
 				})
 			},
 			// 选择投递类型