|
|
@@ -285,10 +285,10 @@
|
|
|
this.isChecked = true
|
|
|
|
|
|
// 开始连接匹配的蓝牙设备
|
|
|
- // setTimeout(async () => {
|
|
|
- // 请求获取设备启动码
|
|
|
- this.request_device_start_code()
|
|
|
- // }, 1000)
|
|
|
+ setTimeout(async () => {
|
|
|
+ // 请求获取设备启动码
|
|
|
+ this.request_device_start_code()
|
|
|
+ }, 300)
|
|
|
} else if (res.cancel) {
|
|
|
setTimeout(() => {
|
|
|
this.isChecked = false
|
|
|
@@ -666,7 +666,7 @@
|
|
|
},
|
|
|
fail: (err) => {
|
|
|
this.isScan = false
|
|
|
- console.error('获取蓝牙设备特征值失败(getBLEDeviceCharacteristics)', err)
|
|
|
+ // console.error('获取蓝牙设备特征值失败(getBLEDeviceCharacteristics)', err)
|
|
|
}
|
|
|
});
|
|
|
},
|
|
|
@@ -732,12 +732,6 @@
|
|
|
// 关闭蓝牙连接
|
|
|
this.closeBLEConnection()
|
|
|
|
|
|
- // 处理 35字节
|
|
|
- // APP 接收后,根据用户操作情况主要做如下几个方面的处理。
|
|
|
- // 1、向后台提交【结算数据】
|
|
|
- // 2、提交【结算数据】并生成【启动代码】
|
|
|
- // 3、提示:用户进行下面的流程
|
|
|
-
|
|
|
// 请求结算
|
|
|
this.request_pay()
|
|
|
|
|
|
@@ -972,31 +966,32 @@
|
|
|
* 请求获取设备启动码
|
|
|
*/
|
|
|
async request_device_start_code() {
|
|
|
- if (this.byte35 == '' || this.$store.state.stu_number == '') {
|
|
|
- uni.showToast({
|
|
|
- title: '字节码或学号为空!'
|
|
|
- });
|
|
|
- return
|
|
|
- }
|
|
|
- const res = await this.$myRequest({
|
|
|
- host: this.ceshi,
|
|
|
- url: '/HotWaters/wpstart.action',
|
|
|
- data: {
|
|
|
- collect_code: this.byte35,
|
|
|
- stu_number: this.$store.state.stu_number
|
|
|
- }
|
|
|
- })
|
|
|
+ if (this.byte35 != '' && this.$store.state.stu_number != '') {
|
|
|
+ const res = await this.$myRequest({
|
|
|
+ host: this.ceshi,
|
|
|
+ url: '/HotWaters/wpstart.action',
|
|
|
+ data: {
|
|
|
+ collect_code: this.byte35,
|
|
|
+ stu_number: this.$store.state.stu_number
|
|
|
+ }
|
|
|
+ })
|
|
|
|
|
|
- // console.log(res)
|
|
|
- if (res.data.start_code != 'undefined' && res.data.start_code != '') {
|
|
|
- this.start_code = res.data.start_code
|
|
|
- this.send('start')
|
|
|
+ // console.log(res)
|
|
|
+ if (res.data.start_code != 'undefined' && res.data.start_code != '') {
|
|
|
+ this.start_code = res.data.start_code
|
|
|
+ this.send('start')
|
|
|
+ } else {
|
|
|
+ uni.showToast({
|
|
|
+ title: res.data.mess,
|
|
|
+ duration: 3000
|
|
|
+ })
|
|
|
+ }
|
|
|
} else {
|
|
|
uni.showToast({
|
|
|
- icon: 'none',
|
|
|
- title: '未获得启动码',
|
|
|
- duration: 3000
|
|
|
- })
|
|
|
+ title: '字节码或学号为空!'
|
|
|
+ });
|
|
|
+ // 初始化
|
|
|
+ this.setInit()
|
|
|
}
|
|
|
},
|
|
|
|
|
|
@@ -1004,40 +999,42 @@
|
|
|
* 请求结算
|
|
|
*/
|
|
|
async request_pay() {
|
|
|
- if (this.byte35.substring(2) == '') {
|
|
|
- uni.showToast({
|
|
|
- title: '字节码为空!',
|
|
|
- icon: 'success'
|
|
|
- });
|
|
|
- return
|
|
|
- }
|
|
|
- const res = await this.$myRequest({
|
|
|
- host: this.ceshi,
|
|
|
- url: '/HotWaters/wpconsume.action',
|
|
|
- data: {
|
|
|
- collect_code: this.byte35.substring(2)
|
|
|
- }
|
|
|
- })
|
|
|
-
|
|
|
- // console.log(res)
|
|
|
- if (res.data.mess === "支付成功!") {
|
|
|
- uni.showToast({
|
|
|
- icon: 'success',
|
|
|
- title: '结算成功!',
|
|
|
- success: (res1) => {
|
|
|
- this.use_amount = res.data.use_amount.toFixed(2)
|
|
|
- this.amount = (this.amount - this.use_amount).toFixed(2)
|
|
|
-
|
|
|
- // 刷新选定的月份消费记录
|
|
|
- this.request_consumption_records()
|
|
|
+ if (this.byte35 != '') {
|
|
|
+ const res = await this.$myRequest({
|
|
|
+ host: this.ceshi,
|
|
|
+ url: '/HotWaters/wpconsume.action',
|
|
|
+ data: {
|
|
|
+ collect_code: this.byte35.substring(2)
|
|
|
}
|
|
|
})
|
|
|
+
|
|
|
+ // console.log(res)
|
|
|
+ if (res.data.mess == "支付成功") {
|
|
|
+ uni.showToast({
|
|
|
+ icon: 'success',
|
|
|
+ title: '结算成功!',
|
|
|
+ success: (res1) => {
|
|
|
+ this.use_amount = res.data.use_amount.toFixed(2)
|
|
|
+ this.amount = (this.amount - this.use_amount).toFixed(2)
|
|
|
+
|
|
|
+ // 刷新选定的月份消费记录
|
|
|
+ this.request_consumption_records()
|
|
|
+ }
|
|
|
+ })
|
|
|
+ } else {
|
|
|
+ uni.showToast({
|
|
|
+ icon: 'success',
|
|
|
+ title: '结算失败!',
|
|
|
+ duration: 3000
|
|
|
+ })
|
|
|
+ }
|
|
|
} else {
|
|
|
uni.showToast({
|
|
|
- icon: 'success',
|
|
|
- title: '结算失败!',
|
|
|
- duration: 3000
|
|
|
- })
|
|
|
+ title: '字节码为空!',
|
|
|
+ icon: 'success'
|
|
|
+ });
|
|
|
+ // 初始化
|
|
|
+ this.setInit()
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
@@ -1048,7 +1045,7 @@
|
|
|
*/
|
|
|
function str2StrArray(start_code) {
|
|
|
if (start_code.length != 34) {
|
|
|
- console.log('启动码长度错误')
|
|
|
+ // console.log('启动码长度错误')
|
|
|
throw new Error("启动码长度错误");
|
|
|
return
|
|
|
}
|