|
|
@@ -81,7 +81,7 @@
|
|
|
}),
|
|
|
startDate: this.$getDate('start_date'),
|
|
|
endDate: this.$getDate('end_date'),
|
|
|
- flag: false,
|
|
|
+ flag: false, // 控制说明弹窗
|
|
|
isUserClose: false, // 是否是用户自己关闭
|
|
|
isChecked: false,
|
|
|
isConnected: false, // 是否连接上
|
|
|
@@ -113,6 +113,7 @@
|
|
|
amount: 0.0.toFixed(2), // 余额
|
|
|
dorm_number: '', // 宿舍号
|
|
|
stu_number: '', // 学号
|
|
|
+ user_name: '',
|
|
|
// compus: '', // 校区
|
|
|
ceshi: 'code',
|
|
|
changeDate: false // 是否是手动选择日期
|
|
|
@@ -124,19 +125,36 @@
|
|
|
// 获取基本信息
|
|
|
this.get_base_info(options, 'onLoad')
|
|
|
} else if (typeof(options.from) != 'undefined' && options.from != 0) {
|
|
|
- uni.navigateTo({
|
|
|
- url: '../index/index?from=' + options.from
|
|
|
+ // uni.showToast({
|
|
|
+ // icon: 'none',
|
|
|
+ // title: '跳转首页'
|
|
|
+ // })
|
|
|
+ // uni.navigateTo({
|
|
|
+ // url: '../index/index?from=' + options.from
|
|
|
+ // })
|
|
|
+ // } else {
|
|
|
+ uni.showToast({
|
|
|
+ icon: 'none',
|
|
|
+ title: '初始化蓝牙'
|
|
|
})
|
|
|
- } else {
|
|
|
// wxminicode=KB580002652
|
|
|
this.start_code = decodeURIComponent(options.q).split('=')[1]
|
|
|
// 初始化蓝牙
|
|
|
this.openBluetoothAdapter()
|
|
|
}
|
|
|
+
|
|
|
+ const value = uni.getStorageSync('instruction_noshow');
|
|
|
+ if (!(value == true)) {
|
|
|
+ this.flag = true
|
|
|
+ }
|
|
|
},
|
|
|
onShow() {
|
|
|
- // 获取基本信息
|
|
|
- this.get_base_info('options', 'onShow')
|
|
|
+ if (this.stu_number && typeof(this.stu_number) != 'undefined') {
|
|
|
+ return
|
|
|
+ } else {
|
|
|
+ // 获取基本信息
|
|
|
+ this.get_base_info('options', 'onShow')
|
|
|
+ }
|
|
|
},
|
|
|
methods: {
|
|
|
/**
|
|
|
@@ -163,13 +181,6 @@
|
|
|
duration: 3000
|
|
|
});
|
|
|
}
|
|
|
- } else {
|
|
|
- const value = uni.getStorageSync('instruction_noshow');
|
|
|
- if (!value) {
|
|
|
- this.flag = true
|
|
|
- }
|
|
|
- // 获取code
|
|
|
- this.getCode(options, param)
|
|
|
}
|
|
|
} catch (e) {
|
|
|
console.log(e);
|
|
|
@@ -187,10 +198,11 @@
|
|
|
})
|
|
|
|
|
|
// this.amount = this.$store.state.reshui_amount + this.amount
|
|
|
- // 重新调用一次,刷新金额
|
|
|
- this.getCode(options, param)
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
+ // 获取code
|
|
|
+ this.getCode(options, param)
|
|
|
},
|
|
|
/**
|
|
|
* 获得code
|
|
|
@@ -232,8 +244,9 @@
|
|
|
// 判断存储的stu_number与返回的stu_number是否一致
|
|
|
let cardNumber = res.data.info[0].card_number
|
|
|
if (typeof(cardNumber) != 'undefined' && cardNumber != '' && JSON.stringify(cardNumber) != '{}') {
|
|
|
- // 学号
|
|
|
+ // 学号 和 姓名
|
|
|
this.stu_number = res.data.info[0].stu_number
|
|
|
+ this.user_name = res.data.info[0].user_name
|
|
|
// 剩余金额
|
|
|
this.amount = res.data.info[0].balance.toFixed(2)
|
|
|
if (this.amount > 0)
|
|
|
@@ -317,7 +330,7 @@
|
|
|
}
|
|
|
});
|
|
|
|
|
|
- // console.log(res);
|
|
|
+ console.log(res);
|
|
|
if (res.data.mess == '返回成功') {
|
|
|
this.xiaofei_items = []
|
|
|
// 消费记录
|
|
|
@@ -422,7 +435,7 @@
|
|
|
},
|
|
|
|
|
|
/**
|
|
|
- * 跳转到充值页面并传参数
|
|
|
+ * 跳转到充值页面
|
|
|
*/
|
|
|
chongzhi_yemian() {
|
|
|
//在起始页面跳转到recharge.vue页面并传递参数
|
|
|
@@ -505,7 +518,7 @@
|
|
|
// rawData: "aHR0cDovL3Rvb2xzLjlrYnMuY29tLz93eG1pbmljb2RlPUtCNTgwMDAyNjUy"
|
|
|
// result: "http://tools.9kbs.com/?wxminicode=KB580002652"
|
|
|
// scanType: "QR_CODE"
|
|
|
- this.device_code = res.result.split('?')[1].split('=')[1]
|
|
|
+ this.device_code = res.result.split('=')[1]
|
|
|
|
|
|
if (this.device_code === '') {
|
|
|
uni.showToast({
|
|
|
@@ -632,6 +645,10 @@
|
|
|
}
|
|
|
|
|
|
if (device.name == this.device_code) {
|
|
|
+ this.process_control(0);
|
|
|
+
|
|
|
+ this.stopBluetoothDevicesDiscovery()
|
|
|
+
|
|
|
//data里面建立一个deviceId、device_code,存储起来
|
|
|
// this.device_code = device.name;
|
|
|
this.deviceId = device.deviceId
|
|
|
@@ -640,9 +657,7 @@
|
|
|
this.devices.push(res.devices[0].deviceId)
|
|
|
}
|
|
|
|
|
|
- this.process_control(0);
|
|
|
-
|
|
|
- this.stopBluetoothDevicesDiscovery()
|
|
|
+ return
|
|
|
}
|
|
|
})
|
|
|
});
|
|
|
@@ -656,7 +671,7 @@
|
|
|
//连接蓝牙
|
|
|
uni.createBLEConnection({
|
|
|
deviceId: this.deviceId,
|
|
|
- timeout: 3000,
|
|
|
+ timeout: 5000,
|
|
|
success: (res) => {
|
|
|
// console.log(res)
|
|
|
this.connect_BLE()
|
|
|
@@ -665,7 +680,7 @@
|
|
|
// console.log(err)
|
|
|
this.isScan = false
|
|
|
if (err.errMsg.indexOf('already connect') != -1) {
|
|
|
- this.connect_BLE()
|
|
|
+ // this.connect_BLE()
|
|
|
} else {
|
|
|
uni.showToast({
|
|
|
title: '建立连接失败',
|
|
|
@@ -776,7 +791,7 @@
|
|
|
setTimeout(() => {
|
|
|
// 发送 AAABAC,采集数据(会返回 35字节 的数据)
|
|
|
this.send('')
|
|
|
- }, 300)
|
|
|
+ }, 800)
|
|
|
|
|
|
// // 请求设备信息
|
|
|
// this.request_device_info()
|
|
|
@@ -791,6 +806,9 @@
|
|
|
content: err.errMsg,
|
|
|
showCancel: false
|
|
|
})
|
|
|
+
|
|
|
+ // 初始化
|
|
|
+ this.setInit()
|
|
|
}
|
|
|
})
|
|
|
},
|
|
|
@@ -801,7 +819,7 @@
|
|
|
*/
|
|
|
onBLECharacteristicValueChange() {
|
|
|
uni.onBLECharacteristicValueChange((characteristic) => {
|
|
|
- let condition = ab2hex(characteristic.value)
|
|
|
+ let condition = this.ab2hex(characteristic.value)
|
|
|
|
|
|
// console.log(condition)
|
|
|
if (condition.length > 2) {
|
|
|
@@ -964,12 +982,12 @@
|
|
|
// this.createBLEConnection()
|
|
|
// 发送 17字节 启动代码(会返回 35字节 的数据)
|
|
|
// b58000265243eb3dd4bb3c5a2ab9042efcf0d2a30a000000000000000014392a0103bc
|
|
|
- newArr = str2StrArray(this.start_code)
|
|
|
+ newArr = this.str2StrArray(this.start_code)
|
|
|
} else if (val == 'stop') { // 结束当前使用,设备成功返回:AD+35字节 消费结算代码
|
|
|
this.isUserClose = true
|
|
|
// 发送 AAABAD+17字节 启动代码(会返回 ad+35字节 的数据)
|
|
|
// adb58000265243eb3dd4bb3c5a2ab9042efcf0d2a30a000000000000000014392a0104bc
|
|
|
- newArr = ['AA', 'AB', 'AD'].concat(str2StrArray(this.start_code))
|
|
|
+ newArr = ['AA', 'AB', 'AD'].concat(this.str2StrArray(this.start_code))
|
|
|
} else {
|
|
|
// 发送 AAABAC 采集数据(会返回 35字节 的数据)
|
|
|
// b58000265243eb3dd4bb3c5a2ab9042efcf0d2a30a000000000000000014392a0103bc
|
|
|
@@ -979,7 +997,7 @@
|
|
|
buffer = new ArrayBuffer(newArr.length)
|
|
|
dataView = new DataView(buffer)
|
|
|
newArr.forEach((item, i) => {
|
|
|
- dataView.setUint8(i, sixteen_to_ten(item))
|
|
|
+ dataView.setUint8(i, this.sixteen_to_ten(item))
|
|
|
})
|
|
|
|
|
|
// 写特征值数据到设备
|
|
|
@@ -1060,13 +1078,20 @@
|
|
|
})
|
|
|
|
|
|
// console.log(res)
|
|
|
- if (res.data.start_code != 'undefined' && res.data.start_code != '') {
|
|
|
- this.start_code = res.data.start_code
|
|
|
- this.send('start')
|
|
|
+ let sc = res.data.start_code
|
|
|
+ if (typeof(sc) != 'undefined' && sc != '') {
|
|
|
+ this.start_code = sc
|
|
|
+ setTimeout(() => {
|
|
|
+ this.send('start')
|
|
|
+ }, 100)
|
|
|
+
|
|
|
+ // 刷新选定的月份消费记录
|
|
|
+ this.request_consumption_records()
|
|
|
} else {
|
|
|
+ this.isChecked = false
|
|
|
uni.showToast({
|
|
|
title: res.data.mess,
|
|
|
- duration: 3000
|
|
|
+ duration: 3000,
|
|
|
})
|
|
|
}
|
|
|
} else {
|
|
|
@@ -1087,6 +1112,8 @@
|
|
|
host: this.ceshi,
|
|
|
url: '/HotWaters/wpconsume.action',
|
|
|
data: {
|
|
|
+ stu_number: this.stu_number,
|
|
|
+ user_name: this.user_name,
|
|
|
collect_code: this.byte35.substring(2)
|
|
|
}
|
|
|
})
|
|
|
@@ -1118,46 +1145,53 @@
|
|
|
// 初始化
|
|
|
this.setInit()
|
|
|
}
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
+ },
|
|
|
+ /**
|
|
|
+ * 返回字符处理
|
|
|
+ */
|
|
|
+ str2StrArray(start_code) {
|
|
|
+ if (typeof(start_code) == 'undefined' || start_code == '') {
|
|
|
+ uni.showToast({
|
|
|
+ icon: 'none',
|
|
|
+ title: '设备码获取失败'
|
|
|
+ })
|
|
|
|
|
|
- /**
|
|
|
- * 返回字符处理
|
|
|
- */
|
|
|
- function str2StrArray(start_code) {
|
|
|
- if (start_code.length != 34) {
|
|
|
- // console.log('启动码长度错误')
|
|
|
- throw new Error("启动码长度错误");
|
|
|
- return
|
|
|
- }
|
|
|
- var resultArray = new Array()
|
|
|
- for (var i = 0; i < start_code.length; i += 2) {
|
|
|
- resultArray.push(start_code.substr(i, 2));
|
|
|
- }
|
|
|
+ this.setInit()
|
|
|
|
|
|
- return resultArray;
|
|
|
- }
|
|
|
+ return
|
|
|
+ }
|
|
|
+ if (start_code.length != 34) {
|
|
|
+ // console.log('启动码长度错误')
|
|
|
+ throw new Error("启动码长度错误");
|
|
|
+ return
|
|
|
+ }
|
|
|
+ var resultArray = new Array()
|
|
|
+ for (var i = 0; i < start_code.length; i += 2) {
|
|
|
+ resultArray.push(start_code.substr(i, 2));
|
|
|
+ }
|
|
|
|
|
|
- /**
|
|
|
- * ArrayBuffer转16进度字符串
|
|
|
- */
|
|
|
- function ab2hex(buffer) {
|
|
|
- const hexArr = Array.prototype.map.call(
|
|
|
- new Uint8Array(buffer),
|
|
|
- function(bit) {
|
|
|
- // console.log('====================' + bit + '==========================')
|
|
|
- return ('00' + bit.toString(16)).slice(-2)
|
|
|
+ return resultArray;
|
|
|
+ },
|
|
|
+ /**
|
|
|
+ * ArrayBuffer转16进度字符串
|
|
|
+ */
|
|
|
+ ab2hex(buffer) {
|
|
|
+ const hexArr = Array.prototype.map.call(
|
|
|
+ new Uint8Array(buffer),
|
|
|
+ function(bit) {
|
|
|
+ // console.log('====================' + bit + '==========================')
|
|
|
+ return ('00' + bit.toString(16)).slice(-2)
|
|
|
+ }
|
|
|
+ )
|
|
|
+ return hexArr.join('');
|
|
|
+ },
|
|
|
+ /**
|
|
|
+ * 16进制转10进制
|
|
|
+ */
|
|
|
+ sixteen_to_ten(str) {
|
|
|
+ return parseInt(str, 16);
|
|
|
}
|
|
|
- )
|
|
|
- return hexArr.join('');
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
- * 16进制转10进制
|
|
|
- */
|
|
|
- function sixteen_to_ten(str) {
|
|
|
- return parseInt(str, 16);
|
|
|
+ }
|
|
|
}
|
|
|
</script>
|
|
|
|