lilei 4 tahun lalu
induk
melakukan
958c876122
4 mengubah file dengan 82 tambahan dan 17 penghapusan
  1. 9 0
      pages.json
  2. 45 0
      pages/help/help.vue
  3. 20 10
      pages/index/index.vue
  4. 8 7
      pages/userAuth/userAuth.vue

+ 9 - 0
pages.json

@@ -93,6 +93,15 @@
             }
             }
             
             
         }
         }
+        ,{
+            "path" : "pages/help/help",
+            "style" :                                                                                    
+            {
+                "navigationBarTitleText": "蓝牙使用帮助",
+                "enablePullDownRefresh": false
+            }
+            
+        }
     ],
     ],
 	"globalStyle": {
 	"globalStyle": {
 		"navigationBarTextStyle": "black",
 		"navigationBarTextStyle": "black",

+ 45 - 0
pages/help/help.vue

@@ -0,0 +1,45 @@
+<template>
+	<view class="content">
+		<view class="title">使用步骤:</view>
+		<view>1.使用前先打开手机蓝牙开关(苹果手机还需打开系统设置->微信->蓝牙开关)。</view>
+		<view>2.点击投放称重按钮或绑定电子秤按钮。</view>
+		<view>3.开始搜索电子秤,搜索到设备后会显示出来。</view>
+		<view>4.点击开始连接设备。</view>
+		<view>5.等待设备连接成功后,点击投放称重按钮(苹果手机此时需要扫描电子秤的二维码),进入用户认证页面。</view>
+		<view>6.在用户认证页面输入手机号码并选择投递类型,点击下一步到称重页面。</view>
+		<view>7.此时可将物品放在电子秤上,等待数据稳定后,点击提交按钮确认数据无误后确定提交。</view>
+		<view>8.提交成功后,可在我的->投递记录中查看数据。</view>
+		<view class="title">注意事项:</view>
+		<view>1.部分手机需要开启定位服务(苹果手机还需检查系统设置->微信->蓝牙开关是否开启),蓝牙才能连接上。</view>
+		<view>2.如果出现长时间连接不上情况,请检查是否有其它手机已经连接电子秤,或重启电子秤后再点击按钮重新连接。</view>
+		<view>3.如果手机搜索不到电子秤,请检查微信版本是否最新版本,如不是请更新版本后再试。</view>
+		<view>4.如果以上方法都不行,请联系技术人员,请告知手机型号及系统版本,以便查找问题。</view>
+		<view>5.每次称重结束后,记得取下物品,避免重复称重。</view>
+	</view>
+</template>
+
+<script>
+	export default {
+		data() {
+			return {
+				
+			}
+		},
+		methods: {
+			
+		}
+	}
+</script>
+
+<style lang="less">
+.content{
+	padding: 50rpx;
+	background: #F8F8F8;
+	> view{
+		padding: 15rpx 0;
+	}
+	.title{
+		font-weight: 900;
+	}
+}
+</style>

+ 20 - 10
pages/index/index.vue

@@ -5,7 +5,7 @@
 		</view>
 		</view>
 		<!-- 称重 -->
 		<!-- 称重 -->
 		<view class="content">
 		<view class="content">
-			<view @click="toTdRecord" class="tdrecord">投递记录</view>
+			<view @click="toHelp" class="tdrecord">蓝牙使用帮助</view>
 			<view class="cz-box" @click="toWork">
 			<view class="cz-box" @click="toWork">
 				<view :class="loading?'turn':''">
 				<view :class="loading?'turn':''">
 					<u-image width="100rpx" height="100rpx" src="/static/chengzhong.png"></u-image>
 					<u-image width="100rpx" height="100rpx" src="/static/chengzhong.png"></u-image>
@@ -108,10 +108,10 @@
 					}
 					}
 				})
 				})
 			},
 			},
-			// 查看投递记录
-			toTdRecord(){
+			// 使用帮助
+			toHelp(){
 				uni.navigateTo({
 				uni.navigateTo({
-					url: '/pages/tdRecord/tdRecord'
+					url: '/pages/help/help'
 				})
 				})
 			},
 			},
 			// 去认证用户并开始称重
 			// 去认证用户并开始称重
@@ -132,7 +132,7 @@
 												console.log(res)
 												console.log(res)
 												_this.iosMac = res.result
 												_this.iosMac = res.result
 												uni.navigateTo({
 												uni.navigateTo({
-													url: '/pages/userAuth/userAuth?deviceId=' + _this.iosMac
+													url: '/pages/userAuth/userAuth?macAddress=' + _this.iosMac + '&id=' + _this.deviceId
 												})
 												})
 											}
 											}
 										})
 										})
@@ -142,7 +142,7 @@
 					}else{
 					}else{
 						// 安卓系统直接跳转
 						// 安卓系统直接跳转
 						uni.navigateTo({
 						uni.navigateTo({
-							url: '/pages/userAuth/userAuth?deviceId=' + (this.platform == 'ios' ? _this.iosMac : _this.deviceId)
+							url: '/pages/userAuth/userAuth?macAddress=' + (this.platform == 'ios' ? _this.iosMac : _this.deviceId) + '&id=' + _this.deviceId
 						})
 						})
 					}
 					}
 				}else{
 				}else{
@@ -230,8 +230,18 @@
 					// 关闭连接
 					// 关闭连接
 				  	_this.statusStr = '蓝牙已关闭,请开启手机蓝牙'
 				  	_this.statusStr = '蓝牙已关闭,请开启手机蓝牙'
 					_this.loading = false
 					_this.loading = false
-					// _this.connectedDeviceId = null
-					// _this.closeConnect()
+					if(_this.connectedDeviceId){
+						uni.closeBLEConnection({
+						    deviceId: _this.connectedDeviceId,
+						    success: function(res) {
+								console.log(res)
+								_this.connectedDeviceId = null
+						    },
+						    fail(res) {
+								console.log(res)
+						    }
+						})
+					}
 				  }else{
 				  }else{
 					if(!res.discovering && !_this.loading){
 					if(!res.discovering && !_this.loading){
 						_this.statusStr = '蓝牙已启用,请绑定设备'
 						_this.statusStr = '蓝牙已启用,请绑定设备'
@@ -298,7 +308,7 @@
 				  },
 				  },
 				  fail(err) {
 				  fail(err) {
 					  console.log(err,'createBLEConnection error')
 					  console.log(err,'createBLEConnection error')
-					  _this.statusStr = '设备连接失败,请检查后重试'
+					  _this.statusStr = '设备连接失败,请检查蓝牙是否开启后重试'
 					  _this.connectStatus = false
 					  _this.connectStatus = false
 					  _this.loading = false
 					  _this.loading = false
 					  uni.$emit('blueConnectCallback',0)
 					  uni.$emit('blueConnectCallback',0)
@@ -381,7 +391,7 @@
 						
 						
 						/*用来监听手机蓝牙设备的数据变化*/
 						/*用来监听手机蓝牙设备的数据变化*/
 						uni.onBLECharacteristicValueChange(function(res) {
 						uni.onBLECharacteristicValueChange(function(res) {
-							console.log(res,'read data')
+							// console.log(res,'read data')
 							that.balanceData = that.buf2string(res.value)
 							that.balanceData = that.buf2string(res.value)
 							that.$u.vuex('vuex_balanceData',that.balanceData)
 							that.$u.vuex('vuex_balanceData',that.balanceData)
 						})
 						})

+ 8 - 7
pages/userAuth/userAuth.vue

@@ -106,6 +106,7 @@
 				currentGold: 0, // 用户乐豆余额
 				currentGold: 0, // 用户乐豆余额
 				blueConnect: true,
 				blueConnect: true,
 				deviceId: null,
 				deviceId: null,
+				id: null,
 				rubbishtype: [],
 				rubbishtype: [],
 				curRubbishType: null,
 				curRubbishType: null,
 				loading: false
 				loading: false
@@ -168,9 +169,10 @@
 		onLoad(options) {
 		onLoad(options) {
 			let _this = this
 			let _this = this
 			// 设备id,去掉冒号并转小写
 			// 设备id,去掉冒号并转小写
-			this.deviceId = options.deviceId.toLowerCase()
+			this.deviceId = options.macAddress.toLowerCase()
 			this.deviceId = this.deviceId.replace(/:/g,'')
 			this.deviceId = this.deviceId.replace(/:/g,'')
-			
+			this.id = options.id
+			this.blueConnect = true
 			// 连接中断
 			// 连接中断
 			uni.$on('blueConnectClose',function(){
 			uni.$on('blueConnectClose',function(){
 				_this.reConnect(1)
 				_this.reConnect(1)
@@ -230,6 +232,7 @@
 			},
 			},
 			// 重连蓝牙设备
 			// 重连蓝牙设备
 			reConnect(type){
 			reConnect(type){
+				console.log(type,'reConnect')
 				this.blueConnect = false
 				this.blueConnect = false
 				uni.showModal({
 				uni.showModal({
 					title: '提示',
 					title: '提示',
@@ -294,11 +297,9 @@
 				// 判断设备蓝牙是否仍然连接中
 				// 判断设备蓝牙是否仍然连接中
 				uni.getBluetoothDevices({
 				uni.getBluetoothDevices({
 				  success(res) {
 				  success(res) {
-					let has = res.devices.find(item => {
-						let deviceId = item.deviceId.toLowerCase()
-						return deviceId.replace(/:/g,'') == that.deviceId
-					})
-					// console.log(has,'判断设备仍然连接中')
+					console.log(res.devices,that.id)
+					let has = res.devices.find(item => item.deviceId == that.id)
+					console.log(has,that.blueConnect,'判断设备仍然连接中')
 					if(that.blueConnect && has){
 					if(that.blueConnect && has){
 						that.showOk = true
 						that.showOk = true
 						that.modelContent = `
 						that.modelContent = `