|
@@ -3,7 +3,7 @@
|
|
|
<uni-swiper-dot :info="imgUrl" :current="current" field="content" :mode="dotMode">
|
|
<uni-swiper-dot :info="imgUrl" :current="current" field="content" :mode="dotMode">
|
|
|
<swiper class="swiper-box" @change="swiper_change" autoplay :interval="3000" :duration="500">
|
|
<swiper class="swiper-box" @change="swiper_change" autoplay :interval="3000" :duration="500">
|
|
|
<swiper-item v-for="(item ,index) in imgUrl" :key="index">
|
|
<swiper-item v-for="(item ,index) in imgUrl" :key="index">
|
|
|
- <image :src="item.url" mode="aspectFill"></image>
|
|
|
|
|
|
|
+ <image :src="item.url" mode="scaleToFill"></image>
|
|
|
</swiper-item>
|
|
</swiper-item>
|
|
|
</swiper>
|
|
</swiper>
|
|
|
</uni-swiper-dot>
|
|
</uni-swiper-dot>
|
|
@@ -48,15 +48,13 @@
|
|
|
<image src="../static/images/air-pic.png" mode="aspectFit"></image>
|
|
<image src="../static/images/air-pic.png" mode="aspectFit"></image>
|
|
|
</view>
|
|
</view>
|
|
|
</view>
|
|
</view>
|
|
|
- <view class="add-bg">
|
|
|
|
|
- <image src="../static/images/qidong.png" mode="aspectFit"></image>
|
|
|
|
|
- </view>
|
|
|
|
|
</view>
|
|
</view>
|
|
|
<view class="list-air" v-else>
|
|
<view class="list-air" v-else>
|
|
|
<scroll-view scroll-y="true" :style="{height: screenHeight}" @scrolltoupper="scroll_to_upper"
|
|
<scroll-view scroll-y="true" :style="{height: screenHeight}" @scrolltoupper="scroll_to_upper"
|
|
|
@scrolltolower="scroll_to_lower">
|
|
@scrolltolower="scroll_to_lower">
|
|
|
<view class="list-items" v-for="(item, index) in airs" :key="index">
|
|
<view class="list-items" v-for="(item, index) in airs" :key="index">
|
|
|
- <view v-if="item.on === true" class="item-air" @longpress="itemLongPress($event, 1, item.air_ip)">
|
|
|
|
|
|
|
+ <view v-if="item.on === true" class="item-air"
|
|
|
|
|
+ @longpress="itemLongPress($event, item.time, item.air_ip)">
|
|
|
<view class="item-left">
|
|
<view class="item-left">
|
|
|
<view class="item-icon">
|
|
<view class="item-icon">
|
|
|
<view class="circle1"></view>
|
|
<view class="circle1"></view>
|
|
@@ -70,7 +68,7 @@
|
|
|
</view>
|
|
</view>
|
|
|
</view>
|
|
</view>
|
|
|
<view class="item-right"
|
|
<view class="item-right"
|
|
|
- @tap="btn_click(index, item.air_ip, item.name, item.info, item.order_num)">
|
|
|
|
|
|
|
+ @tap="btn_click(index, item.air_ip, item.name, item.info, item.order_num, item.time)">
|
|
|
<view class="item-btn">
|
|
<view class="item-btn">
|
|
|
<image src="../static/images/power-off.png" mode="aspectFit"></image>
|
|
<image src="../static/images/power-off.png" mode="aspectFit"></image>
|
|
|
<view class="item-txt-off">
|
|
<view class="item-txt-off">
|
|
@@ -79,7 +77,8 @@
|
|
|
</view>
|
|
</view>
|
|
|
</view>
|
|
</view>
|
|
|
</view>
|
|
</view>
|
|
|
- <view v-else class="item-air" @longpress="itemLongPress($event, 0, item.air_ip)" :ref="index">
|
|
|
|
|
|
|
+ <view v-else class="item-air" @longpress="itemLongPress($event, item.time, item.air_ip)"
|
|
|
|
|
+ :ref="index">
|
|
|
<view class="item-left">
|
|
<view class="item-left">
|
|
|
<view class="item-icon">
|
|
<view class="item-icon">
|
|
|
<view class="circle1"></view>
|
|
<view class="circle1"></view>
|
|
@@ -94,8 +93,9 @@
|
|
|
<text v-else>未启动</text>
|
|
<text v-else>未启动</text>
|
|
|
</view>
|
|
</view>
|
|
|
</view>
|
|
</view>
|
|
|
- <view class="item-right" v-if="item.abnormal == 1"
|
|
|
|
|
- @tap="btn_click(index, item.air_ip, item.name, item.info, item.order_num)" :ref="index">
|
|
|
|
|
|
|
+ <view class="item-right" v-if="item.abnormal == 1"
|
|
|
|
|
+ @tap="btn_click(index, item.air_ip, item.name, item.info, item.order_num, item.time)"
|
|
|
|
|
+ :ref="index">
|
|
|
<view class="item-btn">
|
|
<view class="item-btn">
|
|
|
<image src="../static/images/power-on.png" mode="aspectFit"></image>
|
|
<image src="../static/images/power-on.png" mode="aspectFit"></image>
|
|
|
<view class="item-txt-on">
|
|
<view class="item-txt-on">
|
|
@@ -149,6 +149,7 @@
|
|
|
isList: false, // 是否显示添加的空调列表
|
|
isList: false, // 是否显示添加的空调列表
|
|
|
screenHeight: '', // 屏幕的高度
|
|
screenHeight: '', // 屏幕的高度
|
|
|
options: 0,
|
|
options: 0,
|
|
|
|
|
+ time_string: '未知(其他人员使用中)',
|
|
|
test: this.$store.state.test
|
|
test: this.$store.state.test
|
|
|
};
|
|
};
|
|
|
},
|
|
},
|
|
@@ -158,10 +159,10 @@
|
|
|
uni.redirectTo({
|
|
uni.redirectTo({
|
|
|
url: '../../pages/index/index'
|
|
url: '../../pages/index/index'
|
|
|
})
|
|
})
|
|
|
-
|
|
|
|
|
|
|
+
|
|
|
return;
|
|
return;
|
|
|
}
|
|
}
|
|
|
-
|
|
|
|
|
|
|
+
|
|
|
this.options = options
|
|
this.options = options
|
|
|
try {
|
|
try {
|
|
|
// 选择绑定了的空调
|
|
// 选择绑定了的空调
|
|
@@ -176,24 +177,27 @@
|
|
|
},
|
|
},
|
|
|
onShow() {
|
|
onShow() {
|
|
|
// 从新计算高度
|
|
// 从新计算高度
|
|
|
- this.calc_screen_height()
|
|
|
|
|
|
|
+ this.calc_screen_height();
|
|
|
// 监听全局的自定义事件,事件由 uni.$emit 触发,但仅触发一次,在第一次触发之后移除该监听器。
|
|
// 监听全局的自定义事件,事件由 uni.$emit 触发,但仅触发一次,在第一次触发之后移除该监听器。
|
|
|
// 绑定空调
|
|
// 绑定空调
|
|
|
|
|
+ var _this = this;
|
|
|
uni.$once('selectAirs', data => {
|
|
uni.$once('selectAirs', data => {
|
|
|
- // console.log(data.airs);
|
|
|
|
|
- let arrAirs = data.airs.trim().split(',')
|
|
|
|
|
|
|
+ // console.log(data.sel_airs);
|
|
|
|
|
+ // 拆分数组元素
|
|
|
|
|
+ let tf = true;
|
|
|
|
|
+ let arrAirs = data.sel_airs.trim().split(',');
|
|
|
for (var i = 0; i < arrAirs.length; i++) {
|
|
for (var i = 0; i < arrAirs.length; i++) {
|
|
|
- let tmpAirs = arrAirs[i].split('|')
|
|
|
|
|
- let t = tmpAirs[1].split('-')
|
|
|
|
|
- let tf = true
|
|
|
|
|
- for (var j = 0; j < this.selectAirs.length; j++) {
|
|
|
|
|
- if (this.selectAirs[j].air_ip == tmpAirs[2]) {
|
|
|
|
|
- tf = false
|
|
|
|
|
|
|
+ let tmpAirs = arrAirs[i].split('|');
|
|
|
|
|
+ let t = tmpAirs[1].split('-');
|
|
|
|
|
+ tf = true;
|
|
|
|
|
+ for (var j = 0; j < _this.selectAirs.length; j++) {
|
|
|
|
|
+ if (_this.selectAirs[j].air_ip == tmpAirs[2]) {
|
|
|
|
|
+ tf = false;
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
// 存在则不添加到数组和缓存
|
|
// 存在则不添加到数组和缓存
|
|
|
if (true === tf) {
|
|
if (true === tf) {
|
|
|
- this.selectAirs.push({
|
|
|
|
|
|
|
+ _this.selectAirs.push({
|
|
|
air_ip: tmpAirs[2],
|
|
air_ip: tmpAirs[2],
|
|
|
name: tmpAirs[0] + ' ' + t[0],
|
|
name: tmpAirs[0] + ' ' + t[0],
|
|
|
info: t[1],
|
|
info: t[1],
|
|
@@ -201,19 +205,19 @@
|
|
|
abnormal: 1,
|
|
abnormal: 1,
|
|
|
on: false, // true开启了,false关闭了
|
|
on: false, // true开启了,false关闭了
|
|
|
order_num: '' // 订单号
|
|
order_num: '' // 订单号
|
|
|
- })
|
|
|
|
|
|
|
+ });
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
// 如果选的空调不为空,则显示添加的空调列表
|
|
// 如果选的空调不为空,则显示添加的空调列表
|
|
|
- if (this.selectAirs.length > 0) {
|
|
|
|
|
|
|
+ if (_this.selectAirs.length > 0) {
|
|
|
// 去重
|
|
// 去重
|
|
|
- const newArr = [...new Set(this.selectAirs.map(e => JSON.stringify(e)))].map(e => JSON.parse(
|
|
|
|
|
|
|
+ var newArr = [...new Set(_this.selectAirs.map(e => JSON.stringify(e)))].map(e => JSON.parse(
|
|
|
e));
|
|
e));
|
|
|
|
|
|
|
|
- this.selectAirs = newArr
|
|
|
|
|
|
|
+ _this.selectAirs = newArr
|
|
|
}
|
|
}
|
|
|
// 存储空调列表
|
|
// 存储空调列表
|
|
|
- uni.setStorageSync('airs_selected', this.selectAirs)
|
|
|
|
|
|
|
+ uni.setStorageSync('airs_selected', _this.selectAirs)
|
|
|
// 移除全局自定义事件监听器。
|
|
// 移除全局自定义事件监听器。
|
|
|
// uni.$off('selectAirs')
|
|
// uni.$off('selectAirs')
|
|
|
});
|
|
});
|
|
@@ -251,7 +255,8 @@
|
|
|
for (var i = 0; i < data.length; i++) {
|
|
for (var i = 0; i < data.length; i++) {
|
|
|
tmpAirs.push({
|
|
tmpAirs.push({
|
|
|
air_ip: data[i].air_ip,
|
|
air_ip: data[i].air_ip,
|
|
|
- name: data[i].school + '-' + data[i].build + '-' + data[i].floors + '-' + data[i].dom +
|
|
|
|
|
|
|
+ name: data[i].school + '-' + data[i].build + '-' + data[i].floors + '-' + data[
|
|
|
|
|
+ i].dom +
|
|
|
'-' + data[i].air_name,
|
|
'-' + data[i].air_name,
|
|
|
info: data[i].air_config,
|
|
info: data[i].air_config,
|
|
|
time: '',
|
|
time: '',
|
|
@@ -336,7 +341,7 @@
|
|
|
// title: '其他人员使用中!',
|
|
// title: '其他人员使用中!',
|
|
|
// duration: 3000
|
|
// duration: 3000
|
|
|
// })
|
|
// })
|
|
|
- tmpAirs[index].time = '未知(其他人员使用中)'
|
|
|
|
|
|
|
+ tmpAirs[index].time = this.time_string;
|
|
|
} else {
|
|
} else {
|
|
|
tmpAirs[index].time = data.start_time
|
|
tmpAirs[index].time = data.start_time
|
|
|
}
|
|
}
|
|
@@ -413,15 +418,16 @@
|
|
|
* 获得code
|
|
* 获得code
|
|
|
*/
|
|
*/
|
|
|
getCode(options, param) {
|
|
getCode(options, param) {
|
|
|
|
|
+ var _this = this;
|
|
|
uni.login({
|
|
uni.login({
|
|
|
success: (res) => {
|
|
success: (res) => {
|
|
|
// console.log('getCode', res);
|
|
// console.log('getCode', res);
|
|
|
if (res.code) {
|
|
if (res.code) {
|
|
|
if (param == 'get_user_info') {
|
|
if (param == 'get_user_info') {
|
|
|
- this.getUserInfo(res.code)
|
|
|
|
|
|
|
+ _this.getUserInfo(res.code)
|
|
|
} else {
|
|
} else {
|
|
|
// 请求服务器,获得openid
|
|
// 请求服务器,获得openid
|
|
|
- this.getOpenId(options, res.code)
|
|
|
|
|
|
|
+ _this.getOpenId(options, res.code)
|
|
|
}
|
|
}
|
|
|
} else {
|
|
} else {
|
|
|
uni.showToast({
|
|
uni.showToast({
|
|
@@ -506,10 +512,9 @@
|
|
|
// 余额
|
|
// 余额
|
|
|
this.balance = res.data.data.balance.toFixed(2)
|
|
this.balance = res.data.data.balance.toFixed(2)
|
|
|
this.id_card = res.data.data.sfzh
|
|
this.id_card = res.data.data.sfzh
|
|
|
- if (this.isList == false) {
|
|
|
|
|
- // 查询绑定的空调
|
|
|
|
|
- this.select_banding_airs()
|
|
|
|
|
- }
|
|
|
|
|
|
|
+
|
|
|
|
|
+ // 查询绑定的空调(更新列表)
|
|
|
|
|
+ this.select_banding_airs()
|
|
|
} else {
|
|
} else {
|
|
|
uni.showToast({
|
|
uni.showToast({
|
|
|
title: res.data.message
|
|
title: res.data.message
|
|
@@ -517,30 +522,35 @@
|
|
|
}
|
|
}
|
|
|
},
|
|
},
|
|
|
/**
|
|
/**
|
|
|
- * 长按可删除
|
|
|
|
|
|
|
+ * 长按可解绑
|
|
|
* @param {Object} e
|
|
* @param {Object} e
|
|
|
- * @param {Object} val
|
|
|
|
|
|
|
+ * @param {Object} time
|
|
|
|
|
+ * @param {Object} air_ip
|
|
|
*/
|
|
*/
|
|
|
- itemLongPress(e, val, air_ip) {
|
|
|
|
|
- // console.log(e, val, air_ip);
|
|
|
|
|
- if (val == 0) {
|
|
|
|
|
|
|
+ itemLongPress(e, time, air_ip) {
|
|
|
|
|
+ // console.log(e, time, air_ip);
|
|
|
|
|
+ var _this = this;
|
|
|
|
|
+ var reg =
|
|
|
|
|
+ /^[1-9]\d{3}-(0[1-9]|1[0-2])-(0[1-9]|[1-2][0-9]|3[0-1])\s+(20|21|22|23|[0-1]\d):[0-5]\d:[0-5]\d$/;
|
|
|
|
|
+ var regExp = new RegExp(reg);
|
|
|
|
|
+ if (regExp.test(time) || time == this.time_string) {
|
|
|
|
|
+ uni.showToast({
|
|
|
|
|
+ title: '使用中不能解绑',
|
|
|
|
|
+ icon: 'error',
|
|
|
|
|
+ duration: 1000
|
|
|
|
|
+ })
|
|
|
|
|
+ } else {
|
|
|
let index = e.currentTarget.dataset.ref
|
|
let index = e.currentTarget.dataset.ref
|
|
|
uni.showModal({
|
|
uni.showModal({
|
|
|
title: '提示',
|
|
title: '提示',
|
|
|
- content: '是否删除该空调?',
|
|
|
|
|
|
|
+ content: '是否解绑该空调?',
|
|
|
success: (res) => {
|
|
success: (res) => {
|
|
|
if (res.confirm) {
|
|
if (res.confirm) {
|
|
|
// 解绑空调
|
|
// 解绑空调
|
|
|
- this.unbangding_airs(air_ip, index)
|
|
|
|
|
|
|
+ _this.unbangding_airs(air_ip, index)
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
- })
|
|
|
|
|
- } else {
|
|
|
|
|
- uni.showToast({
|
|
|
|
|
- title: '使用中不能删除',
|
|
|
|
|
- icon: 'error',
|
|
|
|
|
- duration: 1000
|
|
|
|
|
- })
|
|
|
|
|
|
|
+ });
|
|
|
}
|
|
}
|
|
|
},
|
|
},
|
|
|
/**
|
|
/**
|
|
@@ -560,15 +570,16 @@
|
|
|
sfzh: this.id_card,
|
|
sfzh: this.id_card,
|
|
|
air_ip: air_ip
|
|
air_ip: air_ip
|
|
|
}
|
|
}
|
|
|
- })
|
|
|
|
|
|
|
+ });
|
|
|
|
|
|
|
|
// console.log(res.data);
|
|
// console.log(res.data);
|
|
|
if (res.data.code == 200) {
|
|
if (res.data.code == 200) {
|
|
|
// 删除指定下标的元素
|
|
// 删除指定下标的元素
|
|
|
- this.airs.splice(index, 1)
|
|
|
|
|
|
|
+ this.airs.splice(index, 1);
|
|
|
|
|
+ uni.setStorageSync('airs_selected', this.airs);
|
|
|
|
|
|
|
|
if (this.airs.length == 0) {
|
|
if (this.airs.length == 0) {
|
|
|
- this.isList = false
|
|
|
|
|
|
|
+ this.isList = false;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
uni.showToast({
|
|
uni.showToast({
|
|
@@ -577,23 +588,49 @@
|
|
|
} else {
|
|
} else {
|
|
|
uni.showToast({
|
|
uni.showToast({
|
|
|
title: res.data.message
|
|
title: res.data.message
|
|
|
- })
|
|
|
|
|
|
|
+ });
|
|
|
}
|
|
}
|
|
|
},
|
|
},
|
|
|
/**
|
|
/**
|
|
|
* 单击了启动或关闭按钮
|
|
* 单击了启动或关闭按钮
|
|
|
* @param {Object} e
|
|
* @param {Object} e
|
|
|
*/
|
|
*/
|
|
|
- btn_click(index, air_ip, name, info, order_num) {
|
|
|
|
|
- // console.log(index, air_ip, name, info, order_num);
|
|
|
|
|
|
|
+ btn_click(index, air_ip, name, info, order_num, time) {
|
|
|
|
|
+ // console.log(index, air_ip, name, info, order_num, time);
|
|
|
|
|
+ var _this = this;
|
|
|
|
|
+ if (time === this.time_string) {
|
|
|
|
|
+ uni.showModal({
|
|
|
|
|
+ title: '提示',
|
|
|
|
|
+ content: '其他人员使用中,你不能关闭!',
|
|
|
|
|
+ confirmText: '好的',
|
|
|
|
|
+ showCancel: false
|
|
|
|
|
+ })
|
|
|
|
|
+ return;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
let tmp = name.split('-');
|
|
let tmp = name.split('-');
|
|
|
let build = tmp[1],
|
|
let build = tmp[1],
|
|
|
floors = tmp[2],
|
|
floors = tmp[2],
|
|
|
dom = tmp[3] + '-' + tmp[4].split(' ')[0];
|
|
dom = tmp[3] + '-' + tmp[4].split(' ')[0];
|
|
|
- let air_name = name.split(' ')[1]
|
|
|
|
|
|
|
+ let air_name = tmp[tmp.length - 1];
|
|
|
|
|
+ // console.log(air_name);
|
|
|
// 未获取到索引
|
|
// 未获取到索引
|
|
|
if (typeof index === 'undefined') {
|
|
if (typeof index === 'undefined') {
|
|
|
- return
|
|
|
|
|
|
|
+ uni.showToast({
|
|
|
|
|
+ title: '索引为空!',
|
|
|
|
|
+ icon: 'none'
|
|
|
|
|
+ });
|
|
|
|
|
+
|
|
|
|
|
+ return;
|
|
|
|
|
+ }
|
|
|
|
|
+ // 获取空调名称
|
|
|
|
|
+ if (typeof air_name === 'undefined') {
|
|
|
|
|
+ uni.showToast({
|
|
|
|
|
+ title: '空调名称为空!',
|
|
|
|
|
+ icon: 'none'
|
|
|
|
|
+ });
|
|
|
|
|
+
|
|
|
|
|
+ return;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
if (this.airs[index].on) {
|
|
if (this.airs[index].on) {
|
|
@@ -603,7 +640,7 @@
|
|
|
success: (res) => {
|
|
success: (res) => {
|
|
|
if (res.confirm) {
|
|
if (res.confirm) {
|
|
|
// 【关闭】空调
|
|
// 【关闭】空调
|
|
|
- this.close_airs(index, air_ip, order_num)
|
|
|
|
|
|
|
+ _this.close_airs(index, air_ip, order_num)
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
});
|
|
});
|
|
@@ -619,7 +656,7 @@
|
|
|
// console.log('getCode', res);
|
|
// console.log('getCode', res);
|
|
|
if (res.code) {
|
|
if (res.code) {
|
|
|
// 调用接口,开启空调
|
|
// 调用接口,开启空调
|
|
|
- this.open_airs(res.code, index, air_ip, build, floors,
|
|
|
|
|
|
|
+ _this.open_airs(res.code, index, air_ip, build, floors,
|
|
|
dom, info, air_name)
|
|
dom, info, air_name)
|
|
|
} else {
|
|
} else {
|
|
|
uni.showToast({
|
|
uni.showToast({
|
|
@@ -640,6 +677,7 @@
|
|
|
* @param {Object} air_ip
|
|
* @param {Object} air_ip
|
|
|
*/
|
|
*/
|
|
|
async close_airs(index, air_ip, order_num) {
|
|
async close_airs(index, air_ip, order_num) {
|
|
|
|
|
+ // console.log(index, air_ip, order_num);
|
|
|
if (order_num == '') {
|
|
if (order_num == '') {
|
|
|
uni.showToast({
|
|
uni.showToast({
|
|
|
title: '未获得单号'
|
|
title: '未获得单号'
|
|
@@ -718,6 +756,7 @@
|
|
|
if (res.data.is_on == 0) {
|
|
if (res.data.is_on == 0) {
|
|
|
// 显示已经关闭图标
|
|
// 显示已经关闭图标
|
|
|
this.airs[index].on = false
|
|
this.airs[index].on = false
|
|
|
|
|
+ this.airs[index].time = '未启动'
|
|
|
uni.showToast({
|
|
uni.showToast({
|
|
|
title: '关闭成功!',
|
|
title: '关闭成功!',
|
|
|
duration: 2000
|
|
duration: 2000
|
|
@@ -749,6 +788,7 @@
|
|
|
* @param {Object} air_config
|
|
* @param {Object} air_config
|
|
|
*/
|
|
*/
|
|
|
async open_airs(code, index, air_ip, build, floors, dom, air_config, air_name) {
|
|
async open_airs(code, index, air_ip, build, floors, dom, air_config, air_name) {
|
|
|
|
|
+ // console.log(code, index, air_ip, build, floors, dom, air_config, air_name);
|
|
|
const res = await this.$myRequest({
|
|
const res = await this.$myRequest({
|
|
|
host: this.ceshi,
|
|
host: this.ceshi,
|
|
|
url: '/airManage/consumestart.action',
|
|
url: '/airManage/consumestart.action',
|
|
@@ -965,7 +1005,7 @@
|
|
|
.add-air {
|
|
.add-air {
|
|
|
border-radius: 8rpx;
|
|
border-radius: 8rpx;
|
|
|
padding: 60rpx 10rpx;
|
|
padding: 60rpx 10rpx;
|
|
|
- background-color: #F1F1F1;
|
|
|
|
|
|
|
+ background-color: #ffffff;
|
|
|
|
|
|
|
|
.add-content {
|
|
.add-content {
|
|
|
display: flex;
|
|
display: flex;
|