|
@@ -134,7 +134,8 @@
|
|
|
],
|
|
],
|
|
|
current: 0, // 开始显示第几个
|
|
current: 0, // 开始显示第几个
|
|
|
balance: 0.0.toFixed(2), // 余额
|
|
balance: 0.0.toFixed(2), // 余额
|
|
|
- airs: [], // 已经添加的空调列表数据
|
|
|
|
|
|
|
+ airs: [], // 已经添加成功的空调列表数据
|
|
|
|
|
+ selectAirs: [], // 已经选择的空调列表数据
|
|
|
dotMode: 'round', // 显示控制点样式
|
|
dotMode: 'round', // 显示控制点样式
|
|
|
isList: false, // 是否显示添加的空调列表
|
|
isList: false, // 是否显示添加的空调列表
|
|
|
screenHeight: '' // 屏幕的高度
|
|
screenHeight: '' // 屏幕的高度
|
|
@@ -145,12 +146,8 @@
|
|
|
let airs_selected = uni.getStorageSync('airs_selected')
|
|
let airs_selected = uni.getStorageSync('airs_selected')
|
|
|
if (airs_selected.length > 0) {
|
|
if (airs_selected.length > 0) {
|
|
|
// 使用存储的列表
|
|
// 使用存储的列表
|
|
|
- this.airs = airs_selected
|
|
|
|
|
- // 显示添加的空调列表
|
|
|
|
|
- this.isList = true
|
|
|
|
|
|
|
+ this.selectAirs = airs_selected
|
|
|
}
|
|
}
|
|
|
- // 获取基本信息
|
|
|
|
|
- this.get_base_info(options, 'onLoad')
|
|
|
|
|
},
|
|
},
|
|
|
onShow() {
|
|
onShow() {
|
|
|
// 从新计算高度
|
|
// 从新计算高度
|
|
@@ -164,14 +161,14 @@
|
|
|
let tmpAirs = arrAirs[i].split('|')
|
|
let tmpAirs = arrAirs[i].split('|')
|
|
|
let t = tmpAirs[1].split('-')
|
|
let t = tmpAirs[1].split('-')
|
|
|
let tf = true
|
|
let tf = true
|
|
|
- for (var j = 0; j < this.airs.length; j++) {
|
|
|
|
|
- if (this.airs[j].air_ip == tmpAirs[2]) {
|
|
|
|
|
|
|
+ for (var j = 0; j < this.selectAirs.length; j++) {
|
|
|
|
|
+ if (this.selectAirs[j].air_ip == tmpAirs[2]) {
|
|
|
tf = false
|
|
tf = false
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
// 存在则不添加到数组和缓存
|
|
// 存在则不添加到数组和缓存
|
|
|
if (true === tf) {
|
|
if (true === tf) {
|
|
|
- this.airs.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],
|
|
@@ -181,16 +178,25 @@
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
// 如果选的空调不为空,则显示添加的空调列表
|
|
// 如果选的空调不为空,则显示添加的空调列表
|
|
|
- if (this.airs.length > 0) {
|
|
|
|
|
- this.airs.sort((a, b)=> a.name.localeCompare(b.name))
|
|
|
|
|
- // 显示添加的空调列表
|
|
|
|
|
- this.isList = true
|
|
|
|
|
|
|
+ if (this.selectAirs.length > 0) {
|
|
|
|
|
+ // 去重
|
|
|
|
|
+ const newArr = [...new Set(this.selectAirs.map(e => JSON.stringify(e)))].map(e => JSON.parse(
|
|
|
|
|
+ e));
|
|
|
|
|
+
|
|
|
|
|
+ this.selectAirs = newArr
|
|
|
}
|
|
}
|
|
|
// 存储空调列表
|
|
// 存储空调列表
|
|
|
- uni.setStorageSync('airs_selected', this.airs)
|
|
|
|
|
|
|
+ uni.setStorageSync('airs_selected', this.selectAirs)
|
|
|
// 移除全局自定义事件监听器。
|
|
// 移除全局自定义事件监听器。
|
|
|
uni.$off('selectAirs')
|
|
uni.$off('selectAirs')
|
|
|
- })
|
|
|
|
|
|
|
+ });
|
|
|
|
|
+
|
|
|
|
|
+ // 获取基本信息
|
|
|
|
|
+ this.get_base_info('options', 'onLoad')
|
|
|
|
|
+
|
|
|
|
|
+ setTimeout(() => {
|
|
|
|
|
+ uni.hideLoading();
|
|
|
|
|
+ }, 3000)
|
|
|
},
|
|
},
|
|
|
methods: {
|
|
methods: {
|
|
|
/**
|
|
/**
|
|
@@ -212,36 +218,48 @@
|
|
|
// console.log(res.data);
|
|
// console.log(res.data);
|
|
|
if (res.data.code == 200) {
|
|
if (res.data.code == 200) {
|
|
|
let data = res.data.data
|
|
let data = res.data.data
|
|
|
- // console.log(this.airs);
|
|
|
|
|
- // console.log(data);
|
|
|
|
|
- let len = this.airs
|
|
|
|
|
- for (var i = 0; i < this.airs.length; i++) {
|
|
|
|
|
- let tf = false
|
|
|
|
|
- for (var j = 0; j < data.length; j++) {
|
|
|
|
|
- if (this.airs[i].air_ip == data[j].air_ip) {
|
|
|
|
|
- tf = true
|
|
|
|
|
|
|
+ if (data.length > 0) {
|
|
|
|
|
+ this.airs = []
|
|
|
|
|
+ let tmpAirs = []
|
|
|
|
|
+ for (var i = 0; i < data.length; i++) {
|
|
|
|
|
+ for (var j = 0; j < this.selectAirs.length; j++) {
|
|
|
|
|
+ if (this.selectAirs[j].air_ip == data[i].air_ip) {
|
|
|
|
|
+ tmpAirs.push(this.selectAirs[j])
|
|
|
|
|
+ break
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
- if (tf !== true) {
|
|
|
|
|
- this.airs.slice(i, 1)
|
|
|
|
|
- }
|
|
|
|
|
- }
|
|
|
|
|
- if (len > this.airs.length) {
|
|
|
|
|
- // 存储空调列表
|
|
|
|
|
- uni.setStorageSync('airs_selected', this.airs)
|
|
|
|
|
|
|
+ // 按名称排序
|
|
|
|
|
+ tmpAirs.sort((a, b) => a.name.localeCompare(b.name))
|
|
|
|
|
+ this.airs = tmpAirs
|
|
|
|
|
+ // 显示添加的空调列表
|
|
|
|
|
+ this.isList = true
|
|
|
|
|
+ } else {
|
|
|
|
|
+ // 隐藏添加的空调列表
|
|
|
|
|
+ this.isList = false
|
|
|
}
|
|
}
|
|
|
|
|
+ } else if (res.data.code == 205) {
|
|
|
|
|
+ // 隐藏添加的空调列表
|
|
|
|
|
+ this.isList = false
|
|
|
} else {
|
|
} else {
|
|
|
|
|
+ // 隐藏添加的空调列表
|
|
|
|
|
+ this.isList = false
|
|
|
// 提示返回信息
|
|
// 提示返回信息
|
|
|
uni.showToast({
|
|
uni.showToast({
|
|
|
title: res.data.message
|
|
title: res.data.message
|
|
|
})
|
|
})
|
|
|
}
|
|
}
|
|
|
|
|
+ // 隐藏加载
|
|
|
|
|
+ uni.hideLoading();
|
|
|
},
|
|
},
|
|
|
/**
|
|
/**
|
|
|
* 获取基本信息
|
|
* 获取基本信息
|
|
|
*/
|
|
*/
|
|
|
get_base_info(options, param) {
|
|
get_base_info(options, param) {
|
|
|
// console.log(options);
|
|
// console.log(options);
|
|
|
|
|
+ uni.showLoading({
|
|
|
|
|
+ title: '加载中'
|
|
|
|
|
+ })
|
|
|
try {
|
|
try {
|
|
|
// 获取学号
|
|
// 获取学号
|
|
|
this.stu_number = this.$store.state.userInfo.card_number
|
|
this.stu_number = this.$store.state.userInfo.card_number
|
|
@@ -301,6 +319,9 @@
|
|
|
* 请求服务器,获得openid
|
|
* 请求服务器,获得openid
|
|
|
*/
|
|
*/
|
|
|
async getOpenId(options, param_code) {
|
|
async getOpenId(options, param_code) {
|
|
|
|
|
+ if (JSON.stringify(this.userinfo) === "{}") {
|
|
|
|
|
+ return
|
|
|
|
|
+ }
|
|
|
const res = await this.$myRequest({
|
|
const res = await this.$myRequest({
|
|
|
host: this.ceshi,
|
|
host: this.ceshi,
|
|
|
url: '/airManage/usersopenid.action',
|
|
url: '/airManage/usersopenid.action',
|
|
@@ -368,7 +389,7 @@
|
|
|
// 余额
|
|
// 余额
|
|
|
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
|
|
|
-
|
|
|
|
|
|
|
+ // 查询绑定的空调
|
|
|
this.select_banding_airs()
|
|
this.select_banding_airs()
|
|
|
} else {
|
|
} else {
|
|
|
uni.showToast({
|
|
uni.showToast({
|
|
@@ -390,12 +411,8 @@
|
|
|
content: '是否删除该空调?',
|
|
content: '是否删除该空调?',
|
|
|
success: (res) => {
|
|
success: (res) => {
|
|
|
if (res.confirm) {
|
|
if (res.confirm) {
|
|
|
- // 删除指定下标的元素
|
|
|
|
|
- this.airs.splice(index, 1)
|
|
|
|
|
- // 更新存储
|
|
|
|
|
- uni.setStorageSync('airs_selected', this.airs)
|
|
|
|
|
// 解绑空调
|
|
// 解绑空调
|
|
|
- this.unbangding_airs(air_ip)
|
|
|
|
|
|
|
+ this.unbangding_airs(air_ip, index)
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
})
|
|
})
|
|
@@ -410,8 +427,9 @@
|
|
|
/**
|
|
/**
|
|
|
* 解绑空调
|
|
* 解绑空调
|
|
|
* @param {Object} air_ip
|
|
* @param {Object} air_ip
|
|
|
|
|
+ * @param {Object} index
|
|
|
*/
|
|
*/
|
|
|
- async unbangding_airs(air_ip) {
|
|
|
|
|
|
|
+ async unbangding_airs(air_ip, index) {
|
|
|
const res = await this.$myRequest({
|
|
const res = await this.$myRequest({
|
|
|
host: this.ceshi,
|
|
host: this.ceshi,
|
|
|
url: '/airManage/usersdelAir.action',
|
|
url: '/airManage/usersdelAir.action',
|
|
@@ -427,6 +445,13 @@
|
|
|
|
|
|
|
|
// console.log(res.data);
|
|
// console.log(res.data);
|
|
|
if (res.data.code == 200) {
|
|
if (res.data.code == 200) {
|
|
|
|
|
+ // 删除指定下标的元素
|
|
|
|
|
+ this.airs.splice(index, 1)
|
|
|
|
|
+
|
|
|
|
|
+ if (this.airs.length == 0) {
|
|
|
|
|
+ this.isList = false
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
uni.showToast({
|
|
uni.showToast({
|
|
|
title: res.data.message
|
|
title: res.data.message
|
|
|
})
|
|
})
|
|
@@ -446,6 +471,7 @@
|
|
|
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]
|
|
|
// 未获取到索引
|
|
// 未获取到索引
|
|
|
if (typeof index === 'undefined') {
|
|
if (typeof index === 'undefined') {
|
|
|
return
|
|
return
|
|
@@ -475,8 +501,7 @@
|
|
|
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)
|
|
|
|
|
|
|
+ dom, info, air_name)
|
|
|
} else {
|
|
} else {
|
|
|
uni.showToast({
|
|
uni.showToast({
|
|
|
title: res.errMsg,
|
|
title: res.errMsg,
|
|
@@ -503,7 +528,7 @@
|
|
|
return
|
|
return
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- if (this.this.id_card == '') {
|
|
|
|
|
|
|
+ if (this.id_card == '') {
|
|
|
uni.showToast({
|
|
uni.showToast({
|
|
|
title: '未获得身份证号'
|
|
title: '未获得身份证号'
|
|
|
})
|
|
})
|
|
@@ -547,7 +572,7 @@
|
|
|
* @param {Object} dom
|
|
* @param {Object} dom
|
|
|
* @param {Object} air_config
|
|
* @param {Object} air_config
|
|
|
*/
|
|
*/
|
|
|
- async open_airs(code, index, air_ip, build, floors, dom, air_config) {
|
|
|
|
|
|
|
+ async open_airs(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',
|
|
@@ -561,20 +586,23 @@
|
|
|
build: build,
|
|
build: build,
|
|
|
floors: floors,
|
|
floors: floors,
|
|
|
dom: dom,
|
|
dom: dom,
|
|
|
- air_config: air_config
|
|
|
|
|
|
|
+ air_config: air_config,
|
|
|
|
|
+ air_name: air_name
|
|
|
}
|
|
}
|
|
|
})
|
|
})
|
|
|
|
|
|
|
|
console.log(res.data);
|
|
console.log(res.data);
|
|
|
if (res.data.code == 200) {
|
|
if (res.data.code == 200) {
|
|
|
uni.showToast({
|
|
uni.showToast({
|
|
|
|
|
+ icon: 'none',
|
|
|
title: res.data.message
|
|
title: res.data.message
|
|
|
})
|
|
})
|
|
|
// 显示已经开启图标
|
|
// 显示已经开启图标
|
|
|
this.airs[index].on = true
|
|
this.airs[index].on = true
|
|
|
- this.order_num = res.data.data.order_num
|
|
|
|
|
|
|
+ this.order_num = res.data.order_num
|
|
|
} else {
|
|
} else {
|
|
|
uni.showToast({
|
|
uni.showToast({
|
|
|
|
|
+ icon: 'none',
|
|
|
title: res.data.message
|
|
title: res.data.message
|
|
|
})
|
|
})
|
|
|
}
|
|
}
|