|
|
@@ -32,15 +32,22 @@
|
|
|
</view>
|
|
|
</view>
|
|
|
<view class="start_bot">
|
|
|
- <text class="start_bot_txt" v-if="false">时长:00:00:00</text>
|
|
|
+ <button class="kongzhonglianjie" @click="open">空中连接</button>
|
|
|
<text class="start_bot_txt">当前结算消费:¥{{use_amount}}</text>
|
|
|
</view>
|
|
|
</view>
|
|
|
+ <view v-if="showRoom" style="width: 100%; height: 100%; ">
|
|
|
+ <view style="display: flex; flex-wrap: wrap;">
|
|
|
+ <button v-for="item in rooms" :key="item.id" @tap="clickRoom(item.id)"
|
|
|
+ class="btn_room">{{item.room}}</button>
|
|
|
+ </view>
|
|
|
+ </view>
|
|
|
<view class="start_up_process">
|
|
|
<uni-steps :options="list1" :active-color="colorPrimary" :active="active" />
|
|
|
</view>
|
|
|
<view class="ad">
|
|
|
- <image src="../../static/image/ad_reshui.png" mode="aspectFit" class="ad_img" @tap="ad_redirect"></image>
|
|
|
+ <image src="../../static/image/ad_reshui.png" mode="aspectFit" class="ad_img" @tap="ad_redirect">
|
|
|
+ </image>
|
|
|
</view>
|
|
|
<view class="title">
|
|
|
消费记录
|
|
|
@@ -86,6 +93,7 @@
|
|
|
startDate: this.$getDate('start_date'),
|
|
|
endDate: this.$getDate('end_date'),
|
|
|
flag: false, // 控制说明弹窗
|
|
|
+ showRoom: false,
|
|
|
isUserClose: false, // 是否是用户自己关闭
|
|
|
isChecked: false,
|
|
|
isConnected: false, // 是否连接上
|
|
|
@@ -101,6 +109,7 @@
|
|
|
title: '启动'
|
|
|
}],
|
|
|
devices: [], // 保存设备
|
|
|
+ rooms: [], // 保存水表id及对应的宿舍号
|
|
|
device_code: '', // 设备编号
|
|
|
deviceId: '',
|
|
|
serviceId: '',
|
|
|
@@ -120,7 +129,8 @@
|
|
|
user_name: '',
|
|
|
// compus: '', // 校区
|
|
|
ceshi: 'code',
|
|
|
- changeDate: false // 是否是手动选择日期
|
|
|
+ changeDate: false, // 是否是手动选择日期
|
|
|
+ get_Bluetooth_Bevice: false // 自动获取蓝牙设备,并列表
|
|
|
}
|
|
|
},
|
|
|
onLoad(options) {
|
|
|
@@ -172,12 +182,14 @@
|
|
|
if (!(value == true)) {
|
|
|
this.flag = true
|
|
|
}
|
|
|
+
|
|
|
+ // 获取蓝牙设备,并列表
|
|
|
+ this.openBluetoothAdapter();
|
|
|
},
|
|
|
onShow() {
|
|
|
// 充值后更新金额
|
|
|
- if (this.$store.state.reshui_amount > 0.00) {
|
|
|
- this.amount = this.$store.state.reshui_amount
|
|
|
- }
|
|
|
+ this.amount = this.$store.state.reshui_amount
|
|
|
+
|
|
|
if (this.stu_number && typeof(this.stu_number) != 'undefined') {
|
|
|
// 获取基本信息
|
|
|
this.get_base_info('options', 'onShow')
|
|
|
@@ -185,6 +197,34 @@
|
|
|
},
|
|
|
methods: {
|
|
|
/**
|
|
|
+ * 单击连接热水表
|
|
|
+ */
|
|
|
+ clickRoom(e) {
|
|
|
+ if (this.judgeBalance() == false) {
|
|
|
+ return
|
|
|
+ }
|
|
|
+ // console.log(e);
|
|
|
+ this.device_code = 'K' + e
|
|
|
+ for (var i = 0, len = this.devices.length; i < len; i++) {
|
|
|
+ if (this.devices[i].dname == e) {
|
|
|
+ this.deviceId = this.devices[i].did
|
|
|
+ // console.log(this.deviceId)
|
|
|
+ break
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ this.process_control(0);
|
|
|
+
|
|
|
+ // 开始连接匹配的蓝牙设备
|
|
|
+ this.createBLEConnection()
|
|
|
+ },
|
|
|
+ /**
|
|
|
+ * 空中连接热水表
|
|
|
+ */
|
|
|
+ open() {
|
|
|
+ this.showRoom = !this.showRoom
|
|
|
+ },
|
|
|
+ /**
|
|
|
* 跳转到广告ad页
|
|
|
*/
|
|
|
ad_redirect() {
|
|
|
@@ -195,7 +235,7 @@
|
|
|
/**
|
|
|
* 保留小数点数值后两位,尾数四舍五入
|
|
|
* @param {Object} value
|
|
|
- */
|
|
|
+ */
|
|
|
numFilter(value) {
|
|
|
// 截取当前数据到小数点后两位
|
|
|
let realVal = parseFloat(value).toFixed(2)
|
|
|
@@ -293,8 +333,8 @@
|
|
|
this.user_name = res.data.info[0].user_name
|
|
|
// 剩余金额
|
|
|
this.amount = res.data.info[0].balance.toFixed(2)
|
|
|
- if (this.amount > 0)
|
|
|
- this.$store.state.reshui_amount = this.amount
|
|
|
+ // if (this.amount > 0)
|
|
|
+ this.$store.state.reshui_amount = this.amount
|
|
|
// 组合楼栋宿舍号
|
|
|
this.dorm_number = res.data.info[0].build + res.data.info[0].dom
|
|
|
// 校区
|
|
|
@@ -319,11 +359,11 @@
|
|
|
} else if (res.data.mess == '未查询到用户信息') {
|
|
|
// 数据库中 未查询到用户信息,就清除本地存储
|
|
|
uni.removeStorageSync('userinfo_storage_key');
|
|
|
-
|
|
|
+
|
|
|
uni.showToast({
|
|
|
title: '获取用户信息失败!'
|
|
|
})
|
|
|
-
|
|
|
+
|
|
|
if (options && typeof(options.from) != 'undefined' && typeof(options.from) != '') {
|
|
|
uni.navigateTo({
|
|
|
url: '../index/index?from=' + options.from
|
|
|
@@ -500,64 +540,75 @@
|
|
|
url: '../recharge/recharge'
|
|
|
});
|
|
|
},
|
|
|
-
|
|
|
/**
|
|
|
- * 111111111111111111111111111111
|
|
|
- * 扫码连接设备
|
|
|
+ * 判断余额是否充足
|
|
|
*/
|
|
|
- scan() {
|
|
|
+ judgeBalance() {
|
|
|
+ var limit_amount = parseFloat(this.$store.state.amount)
|
|
|
var amount = parseFloat(this.amount);
|
|
|
// 启动最低金额限制
|
|
|
- if (amount < 2.00) {
|
|
|
+ if (amount < limit_amount) {
|
|
|
uni.showModal({
|
|
|
title: '提示',
|
|
|
- content: '当前余额不足¥2元',
|
|
|
+ content: '当前余额不足¥' + limit_amount + '元',
|
|
|
cancelText: '我知道了',
|
|
|
confirmText: '我要充值',
|
|
|
success: (res) => {
|
|
|
if (res.confirm) {
|
|
|
// 跳转充值页面
|
|
|
this.chongzhi_yemian()
|
|
|
- } else if (res.cancel) {
|
|
|
- return
|
|
|
+ // return false
|
|
|
+ // } else if (res.cancel) {
|
|
|
+ // return false
|
|
|
}
|
|
|
}
|
|
|
})
|
|
|
+ return false
|
|
|
} else {
|
|
|
- // 已经启动扫描连接设备中
|
|
|
- if (this.isScan) {
|
|
|
- uni.showToast({
|
|
|
- icon: 'none',
|
|
|
- title: '正在扫描,请耐心等待',
|
|
|
- })
|
|
|
- return
|
|
|
- }
|
|
|
- // 已经启动设备,不启动扫描
|
|
|
- if (this.isChecked) {
|
|
|
- uni.showToast({
|
|
|
- icon: 'none',
|
|
|
- title: '设备已启动,无需重新扫码',
|
|
|
- })
|
|
|
- return
|
|
|
- }
|
|
|
+ return true
|
|
|
+ }
|
|
|
+ },
|
|
|
+ /**
|
|
|
+ * 111111111111111111111111111111
|
|
|
+ * 扫码连接设备
|
|
|
+ */
|
|
|
+ scan() {
|
|
|
+ if (this.judgeBalance() == false) {
|
|
|
+ return
|
|
|
+ }
|
|
|
+ // 已经启动扫描连接设备中
|
|
|
+ if (this.isScan) {
|
|
|
+ uni.showToast({
|
|
|
+ icon: 'none',
|
|
|
+ title: '正在扫描,请耐心等待',
|
|
|
+ })
|
|
|
+ return
|
|
|
+ }
|
|
|
+ // 已经启动设备,不启动扫描
|
|
|
+ if (this.isChecked) {
|
|
|
+ uni.showToast({
|
|
|
+ icon: 'none',
|
|
|
+ title: '设备已启动,无需重新扫码',
|
|
|
+ })
|
|
|
+ return
|
|
|
+ }
|
|
|
|
|
|
- if (this.deviceId) {
|
|
|
- uni.showModal({
|
|
|
- title: '提示',
|
|
|
- content: '设备已经连接,需要重新连接吗?',
|
|
|
- success: res => {
|
|
|
- if (res.confirm) {
|
|
|
- this.closeBLEConnection()
|
|
|
+ if (this.deviceId) {
|
|
|
+ uni.showModal({
|
|
|
+ title: '提示',
|
|
|
+ content: '设备已经连接,需要重新连接吗?',
|
|
|
+ success: res => {
|
|
|
+ if (res.confirm) {
|
|
|
+ this.closeBLEConnection()
|
|
|
|
|
|
- this.scan_qr()
|
|
|
- } else if (res.cancel) {
|
|
|
- return
|
|
|
- }
|
|
|
+ this.scan_qr()
|
|
|
+ } else if (res.cancel) {
|
|
|
+ return
|
|
|
}
|
|
|
- })
|
|
|
- } else {
|
|
|
- this.scan_qr()
|
|
|
- }
|
|
|
+ }
|
|
|
+ })
|
|
|
+ } else {
|
|
|
+ this.scan_qr()
|
|
|
}
|
|
|
},
|
|
|
/**
|
|
|
@@ -649,10 +700,10 @@
|
|
|
// services: ['FEE7'], // 要搜索但蓝牙设备主 service 的 uuid 列表
|
|
|
allowDuplicatesKey: true,
|
|
|
success: (res) => {
|
|
|
+ if (this.get_Bluetooth_Bevice == true)
|
|
|
+ this.process_control(0)
|
|
|
|
|
|
- this.process_control(0);
|
|
|
-
|
|
|
- this.onBluetoothDeviceFound() //监听搜索到新设备 同时进行
|
|
|
+ this.onBluetoothDeviceFound() // 监听搜索到新设备 同时进行
|
|
|
|
|
|
setTimeout(() => {
|
|
|
if (this.isScan) {
|
|
|
@@ -703,11 +754,15 @@
|
|
|
// title: '停止蓝牙搜索',
|
|
|
// duration: 2000
|
|
|
// })
|
|
|
+ if (this.get_Bluetooth_Bevice == true) {
|
|
|
+ this.process_control(0);
|
|
|
|
|
|
- this.process_control(0);
|
|
|
-
|
|
|
- // 开始连接匹配的蓝牙设备
|
|
|
- this.createBLEConnection()
|
|
|
+ // 开始连接匹配的蓝牙设备
|
|
|
+ this.createBLEConnection()
|
|
|
+ } else {
|
|
|
+ this.get_Bluetooth_Bevice == true
|
|
|
+ }
|
|
|
+ this.get_room()
|
|
|
},
|
|
|
fail: e => {
|
|
|
// console.log('停止搜索蓝牙设备失败,错误码:' + e.errCode);
|
|
|
@@ -726,31 +781,101 @@
|
|
|
*/
|
|
|
onBluetoothDeviceFound() {
|
|
|
uni.onBluetoothDeviceFound((res) => {
|
|
|
+ let dname = ''
|
|
|
+ let i = 0
|
|
|
res.devices.forEach(device => { // 筛选找到的蓝牙中对名称匹配
|
|
|
// 过滤掉没有名字的设备
|
|
|
if (!device.name && !device.localName) {
|
|
|
return
|
|
|
}
|
|
|
|
|
|
+ // 把搜索到的设备存储起来,如有需要可以在页面上展示
|
|
|
+ dname = device.name.substr(1)
|
|
|
+ let d = {
|
|
|
+ did: device.deviceId,
|
|
|
+ dname: dname
|
|
|
+ }
|
|
|
+ if (dname.length == 10 && JSON.stringify(this.devices).indexOf(JSON.stringify(
|
|
|
+ d)) === -1) {
|
|
|
+ this.devices.push(d)
|
|
|
+ i++
|
|
|
+ }
|
|
|
+
|
|
|
if (device.name == this.device_code) {
|
|
|
this.process_control(0);
|
|
|
|
|
|
//data里面建立一个deviceId、device_code,存储起来
|
|
|
// this.device_code = device.name;
|
|
|
this.deviceId = device.deviceId
|
|
|
- // 把搜索到的设备存储起来,如有需要可以在页面上展示
|
|
|
- if (this.devices.indexOf(res.devices[0].deviceId) == -1) {
|
|
|
- this.devices.push(res.devices[0].deviceId)
|
|
|
- }
|
|
|
|
|
|
// 放此位置,苹果手机兼容
|
|
|
this.stopBluetoothDevicesDiscovery()
|
|
|
|
|
|
return
|
|
|
}
|
|
|
+
|
|
|
+ setTimeout(() => {
|
|
|
+ // 放此位置,苹果手机兼容
|
|
|
+ this.stopBluetoothDevicesDiscovery()
|
|
|
+ }, 2000)
|
|
|
})
|
|
|
});
|
|
|
},
|
|
|
+ // 获取水表对应的宿舍号
|
|
|
+ async get_room() {
|
|
|
+ if (this.devices.length > 0) {
|
|
|
+ let devices_str = []
|
|
|
+
|
|
|
+ for (var i = 0, len = this.devices.length; i < len; i++) {
|
|
|
+ devices_str.push(this.devices[i].dname)
|
|
|
+ }
|
|
|
+
|
|
|
+ const res = await this.$myRequest({
|
|
|
+ host: this.ceshi,
|
|
|
+ url: '/HotWaters/waterqueryDom.action',
|
|
|
+ method: 'POST',
|
|
|
+ header: {
|
|
|
+ 'content-type': 'application/x-www-form-urlencoded'
|
|
|
+ },
|
|
|
+ data: {
|
|
|
+ user_id: devices_str.join(',')
|
|
|
+ }
|
|
|
+ });
|
|
|
+
|
|
|
+ // console.log(res);
|
|
|
+ if (res.data.msg == '获取成功') {
|
|
|
+ this.rooms = []
|
|
|
+ // 消费记录
|
|
|
+ let items = res.data.data
|
|
|
+ if (items == 'undefined') {
|
|
|
+ return
|
|
|
+ }
|
|
|
+ for (var i = 0; i < items.length; i++) {
|
|
|
+ let item = {
|
|
|
+ id: items[i].user_id,
|
|
|
+ room: items[i].dom
|
|
|
+ }
|
|
|
+ if (JSON.stringify(this.rooms).indexOf(JSON.stringify(item)) === -1) {
|
|
|
+ this.rooms.push(item); // 进行动态的操作
|
|
|
+ }
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ if (this.changeDate) {
|
|
|
+ uni.showToast({
|
|
|
+ icon: 'success',
|
|
|
+ title: res.data.mess,
|
|
|
+ success: () => {
|
|
|
+ this.changeDate = false
|
|
|
+ }
|
|
|
+ })
|
|
|
+
|
|
|
+ if (res.data.mess == '本月无消费记录') {
|
|
|
+ this.xiaofei_items = []
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ },
|
|
|
|
|
|
/**
|
|
|
* 555555555555555555555555555555555
|
|
|
@@ -863,7 +988,6 @@
|
|
|
* 启用 notify 功能
|
|
|
*/
|
|
|
notifyBLECharacteristicValueChange() {
|
|
|
- // console.log(characteristicId, 'characteristicId')
|
|
|
uni.notifyBLECharacteristicValueChange({
|
|
|
state: true, // 启用 notify 功能
|
|
|
deviceId: this.deviceId,
|
|
|
@@ -1179,6 +1303,7 @@
|
|
|
} else {
|
|
|
this.isChecked = false
|
|
|
uni.showToast({
|
|
|
+ icon: 'none',
|
|
|
title: res.data.mess,
|
|
|
duration: 3000,
|
|
|
})
|
|
|
@@ -1216,6 +1341,7 @@
|
|
|
success: (res1) => {
|
|
|
this.use_amount = res.data.use_amount.toFixed(2)
|
|
|
this.amount = (this.amount - this.use_amount).toFixed(2)
|
|
|
+ this.$store.state.reshui_amount = this.amount
|
|
|
// 刷新选定的月份消费记录
|
|
|
this.request_consumption_records()
|
|
|
}
|
|
|
@@ -1387,10 +1513,19 @@
|
|
|
|
|
|
.start_bot {
|
|
|
display: flex;
|
|
|
- justify-content: flex-end;
|
|
|
+ justify-content: space-between;
|
|
|
height: 100rpx;
|
|
|
align-items: center;
|
|
|
|
|
|
+ .kongzhonglianjie {
|
|
|
+ margin: 0;
|
|
|
+ height: 60rpx;
|
|
|
+ line-height: 60rpx;
|
|
|
+ font-size: 28rpx;
|
|
|
+ background-color: #1296DB;
|
|
|
+ color: #FFFFFF;
|
|
|
+ }
|
|
|
+
|
|
|
.start_bot_txt {
|
|
|
margin-left: 20rpx;
|
|
|
color: #333;
|
|
|
@@ -1399,16 +1534,22 @@
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ .btn_room {
|
|
|
+ font-size: 28rpx;
|
|
|
+ background-color: #41c560;
|
|
|
+ margin: 10rpx auto;
|
|
|
+ }
|
|
|
+
|
|
|
.start_up_process {
|
|
|
padding: 20rpx 0;
|
|
|
color: #007AFF;
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
.ad {
|
|
|
margin: 0 -40rpx;
|
|
|
width: 750rpx;
|
|
|
height: 216rpx;
|
|
|
-
|
|
|
+
|
|
|
.ad_img {
|
|
|
height: 100%;
|
|
|
width: 100%;
|