|
|
@@ -34,7 +34,7 @@
|
|
|
<view class="add-air" v-if="isList === false" :style="{height: screenHeight}">
|
|
|
<view class="add-content">
|
|
|
<view class="add-left">
|
|
|
- <navigator url="../addAir/addAir" class="add-btn">
|
|
|
+ <navigator open-type="redirect" url="../addAir/addAir" class="add-btn">
|
|
|
<uni-icons type="plus" color="white" size="30"></uni-icons>
|
|
|
<view>添加</view>
|
|
|
</navigator>
|
|
|
@@ -52,8 +52,7 @@
|
|
|
<view class="list-air" v-else>
|
|
|
<scroll-view scroll-y="true" :style="{height: screenHeight}">
|
|
|
<view class="list-items" v-for="(item, index) in airs" :key="index">
|
|
|
- <view v-if="item.on === true" class="item-air"
|
|
|
- @longpress="itemLongPress($event, item.time, item.air_ip)">
|
|
|
+ <view v-if="item.on === true" class="item-air" @tap="tapHandler(item.air_ip)" @longpress="itemLongPress($event, item.time, item.air_ip)">
|
|
|
<view class="item-left">
|
|
|
<view class="item-icon">
|
|
|
<view class="circle1"></view>
|
|
|
@@ -66,8 +65,7 @@
|
|
|
<text>{{item.status}}</text><text>{{item.time}}</text>
|
|
|
</view>
|
|
|
</view>
|
|
|
- <view class="item-right"
|
|
|
- @tap="btn_click(index, item.air_ip, item.name, item.info, item.order_num, item.time)">
|
|
|
+ <view class="item-right" @tap="btn_click(index, item.air_ip, item.name, item.info, item.order_num, item.time)">
|
|
|
<view class="item-btn">
|
|
|
<image src="../static/images/power-off.png" mode="aspectFit"></image>
|
|
|
<view class="item-txt-off">
|
|
|
@@ -76,8 +74,7 @@
|
|
|
</view>
|
|
|
</view>
|
|
|
</view>
|
|
|
- <view v-else class="item-air" @longpress="itemLongPress($event, item.time, item.air_ip)"
|
|
|
- :ref="index">
|
|
|
+ <view v-else class="item-air" @tap="tapHandler(item.air_ip)" @longpress="itemLongPress($event, item.time, item.air_ip)" :ref="index">
|
|
|
<view class="item-left">
|
|
|
<view class="item-icon">
|
|
|
<view class="circle1"></view>
|
|
|
@@ -87,14 +84,12 @@
|
|
|
<view class="item-title">{{item.name_show}}</view>
|
|
|
<view class="item-info">
|
|
|
<text class="item-info-left">{{item.info}}</text>
|
|
|
- <!-- <image src="../static/images/power-off.png" mode="" class="item-info-icon"></image> -->
|
|
|
<text>{{item.status}}</text>
|
|
|
<text v-if="item.time !== ''">{{item.time}}</text>
|
|
|
<text v-else>未启动</text>
|
|
|
</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, item.time)"
|
|
|
+ <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">
|
|
|
<image src="../static/images/power-on.png" mode="aspectFit"></image>
|
|
|
@@ -113,7 +108,7 @@
|
|
|
</view>
|
|
|
</view>
|
|
|
</view>
|
|
|
- <navigator url="../addAir/addAir" class="add-air-bottom">
|
|
|
+ <navigator open-type="redirect" url="../addAir/addAir" class="add-air-bottom">
|
|
|
<uni-icons type="plus" size="30" color="#4B8DFB"></uni-icons>
|
|
|
<view class="add-btn-bottom">添加</view>
|
|
|
</navigator>
|
|
|
@@ -154,9 +149,8 @@
|
|
|
};
|
|
|
},
|
|
|
onLoad(options) {
|
|
|
- var _this = this;
|
|
|
// 系统正在维护...
|
|
|
- if (_this.test == 'weihuzhong') {
|
|
|
+ if (this.test == 'weihuzhong') {
|
|
|
uni.redirectTo({
|
|
|
url: '../../pages/index/index'
|
|
|
})
|
|
|
@@ -164,27 +158,25 @@
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
- _this.options = options
|
|
|
+ this.options = options
|
|
|
try {
|
|
|
// 选择绑定了的空调
|
|
|
let airs_selected = uni.getStorageSync('airs_selected')
|
|
|
if (airs_selected.length > 0) {
|
|
|
// 使用存储的列表
|
|
|
- _this.selectAirs = airs_selected
|
|
|
+ this.selectAirs = airs_selected
|
|
|
}
|
|
|
} catch (e) {
|
|
|
console.log('读取空调相关信息:' + e.message);
|
|
|
}
|
|
|
-
|
|
|
- // _this._freshing = false;
|
|
|
- // setTimeout(() => {
|
|
|
- // _this.triggered = true;
|
|
|
- // }, 500);
|
|
|
},
|
|
|
onShow() {
|
|
|
- var _this = this;
|
|
|
- // 从新计算高度
|
|
|
- _this.calc_screen_height();
|
|
|
+ uni.showLoading({
|
|
|
+ title: '加载中...',
|
|
|
+ mask: true
|
|
|
+ });
|
|
|
+
|
|
|
+ // var _this = this;
|
|
|
// 监听全局的自定义事件,事件由 uni.$emit 触发,但仅触发一次,在第一次触发之后移除该监听器。
|
|
|
// 绑定空调
|
|
|
uni.$once('selectAirs', data => {
|
|
|
@@ -196,14 +188,14 @@
|
|
|
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]) {
|
|
|
+ for (var j = 0; j < this.selectAirs.length; j++) {
|
|
|
+ if (this.selectAirs[j].air_ip == tmpAirs[2]) {
|
|
|
tf = false;
|
|
|
}
|
|
|
}
|
|
|
// 存在则不添加到数组和缓存
|
|
|
if (true === tf) {
|
|
|
- _this.selectAirs.push({
|
|
|
+ this.selectAirs.push({
|
|
|
air_ip: tmpAirs[2],
|
|
|
name: tmpAirs[0] + ' ' + t[0],
|
|
|
info: t[1],
|
|
|
@@ -215,45 +207,48 @@
|
|
|
}
|
|
|
}
|
|
|
// 如果选的空调不为空,则显示添加的空调列表
|
|
|
- if (_this.selectAirs.length > 0) {
|
|
|
+ if (this.selectAirs.length > 0) {
|
|
|
// 去重
|
|
|
- var newArr = [...new Set(_this.selectAirs.map(e => JSON.stringify(e)))].map(e => JSON.parse(
|
|
|
- e));
|
|
|
+ const newArr = Array.from(new Set(this.selectAirs.map(JSON.stringify))).map(JSON.parse);
|
|
|
|
|
|
- _this.selectAirs = newArr;
|
|
|
+ this.selectAirs = newArr;
|
|
|
}
|
|
|
// 存储空调列表
|
|
|
- uni.setStorageSync('airs_selected', _this.selectAirs);
|
|
|
+ uni.setStorageSync('airs_selected', this.selectAirs);
|
|
|
// 移除全局自定义事件监听器。
|
|
|
- // uni.$off('selectAirs')
|
|
|
+ uni.$off('selectAirs');
|
|
|
});
|
|
|
|
|
|
// 获取基本信息
|
|
|
- _this.get_base_info(_this.options, 'onShow');
|
|
|
-
|
|
|
- setTimeout(() => {
|
|
|
- uni.hideLoading();
|
|
|
- }, 3000);
|
|
|
+ this.get_base_info('onShow');
|
|
|
+
|
|
|
+ // 从新计算高度
|
|
|
+ this.calc_screen_height();
|
|
|
+ // setTimeout(() => {
|
|
|
+ // uni.hideLoading();
|
|
|
+ // }, 3000);
|
|
|
},
|
|
|
// 下拉刷新
|
|
|
onPullDownRefresh() {
|
|
|
- var _this = this;
|
|
|
// 获取基本信息
|
|
|
- _this.get_base_info(_this.options, 'onShow');
|
|
|
+ this.get_base_info(this.options, 'onShow');
|
|
|
// 查询绑定的空调(更新列表)
|
|
|
- _this.select_banding_airs();
|
|
|
+ this.select_banding_airs();
|
|
|
// 停止刷新
|
|
|
uni.stopPullDownRefresh();
|
|
|
},
|
|
|
methods: {
|
|
|
+ // 跳转到电流、电压、功率页面
|
|
|
+ tapHandler(air_ip) {
|
|
|
+ // console.log(air_ip);
|
|
|
+ uni.navigateTo({
|
|
|
+ url: '/pagesAir/figure/figure?airip=' + air_ip
|
|
|
+ });
|
|
|
+ },
|
|
|
/**
|
|
|
* 查询绑定的空调
|
|
|
*/
|
|
|
async select_banding_airs() {
|
|
|
- uni.showLoading({
|
|
|
- title: '加载绑定的空调'
|
|
|
- });
|
|
|
-
|
|
|
var _this = this;
|
|
|
const res = await this.$myRequest({
|
|
|
host: _this.ceshi,
|
|
|
@@ -265,32 +260,25 @@
|
|
|
data: {
|
|
|
sfzh: _this.id_card
|
|
|
}
|
|
|
- })
|
|
|
+ });
|
|
|
|
|
|
// console.log(res.data);
|
|
|
if (res.data.code == 200) {
|
|
|
- let data = res.data.data
|
|
|
+ let data = res.data.data;
|
|
|
if (data.length > 0) {
|
|
|
- _this.airs = []
|
|
|
- let tmpAirs = []
|
|
|
+ _this.airs = [];
|
|
|
+ let tmpAirs = [];
|
|
|
for (var i = 0; i < data.length; i++) {
|
|
|
tmpAirs.push({
|
|
|
air_ip: data[i].air_ip,
|
|
|
- name: data[i].school + '-' + data[i].build + '-' + data[i].floors + '-' + data[
|
|
|
- i].dom + '-' + data[i].air_name,
|
|
|
+ name: data[i].school + '-' + data[i].build + '-' + data[i].floors + '-' + data[i].dom + '-' + data[i].air_name,
|
|
|
name_show: data[i].school + '-' + data[i].dom + '-' + data[i].air_name,
|
|
|
info: data[i].air_config,
|
|
|
time: '',
|
|
|
abnormal: data[i].is_normal,
|
|
|
on: data[i].is_on, // true开启了,false关闭了
|
|
|
order_num: '' // 订单号
|
|
|
- })
|
|
|
- // 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 (tmpAirs.length > 0) {
|
|
|
@@ -300,32 +288,32 @@
|
|
|
(function(t, tmpAirs) { // 注意这里是形参
|
|
|
setTimeout(function() {
|
|
|
_this.readAirsStatus(tmpAirs, t);
|
|
|
- }, 100 * t); // 还是0.1秒执行一次,不是累加的
|
|
|
- })(i, tmpAirs) // 注意这里是实参,这里把要用的参数传进去
|
|
|
+ }, 10 * t); // 还是0.01秒执行一次,不是累加的
|
|
|
+ })(i, tmpAirs); // 注意这里是实参,这里把要用的参数传进去
|
|
|
}
|
|
|
|
|
|
setTimeout(() => {
|
|
|
if (_this.airs.length > 0) {
|
|
|
// 显示添加的空调列表
|
|
|
_this.isList = true;
|
|
|
- uni.hideLoading();
|
|
|
+ // uni.hideLoading();
|
|
|
}
|
|
|
- }, 500);
|
|
|
+ }, 300);
|
|
|
}
|
|
|
} else {
|
|
|
// 隐藏添加的空调列表
|
|
|
- _this.isList = false
|
|
|
+ _this.isList = false;
|
|
|
}
|
|
|
} else if (res.data.code == 205) {
|
|
|
// 隐藏添加的空调列表
|
|
|
- _this.isList = false
|
|
|
+ _this.isList = false;
|
|
|
} else {
|
|
|
// 隐藏添加的空调列表
|
|
|
- _this.isList = false
|
|
|
+ _this.isList = false;
|
|
|
// 提示返回信息
|
|
|
uni.showToast({
|
|
|
title: res.data.message
|
|
|
- })
|
|
|
+ });
|
|
|
}
|
|
|
// 隐藏加载
|
|
|
uni.hideLoading();
|
|
|
@@ -348,7 +336,7 @@
|
|
|
air_ip: tmpAirs[index].air_ip,
|
|
|
sfzh: _this.id_card
|
|
|
}
|
|
|
- })
|
|
|
+ });
|
|
|
|
|
|
// console.log(res.data, tmpAirs[index].air_ip);
|
|
|
if (res.data.code == 200) {
|
|
|
@@ -383,27 +371,23 @@
|
|
|
/**
|
|
|
* 获取基本信息
|
|
|
*/
|
|
|
- get_base_info(options, param) {
|
|
|
+ get_base_info(param) {
|
|
|
// console.log(options);
|
|
|
- uni.showLoading({
|
|
|
- title: '加载中',
|
|
|
- mask: true
|
|
|
- })
|
|
|
-
|
|
|
+ var _this = this;
|
|
|
// 获取学号
|
|
|
- this.stu_number = this.$store.state.userInfo.card_number
|
|
|
+ _this.stu_number = _this.$store.state.userInfo.card_number;
|
|
|
|
|
|
try {
|
|
|
- if (this.stu_number == '' || typeof(this.stu_number) == 'undefined') { // 学号不存在,可以从存储中拿用户信息
|
|
|
+ if (_this.stu_number == '' || typeof(_this.stu_number) == 'undefined') { // 学号不存在,可以从存储中拿用户信息
|
|
|
const userinfo = uni.getStorageSync('userinfo_storage_key')
|
|
|
if (userinfo) { // 拿学号
|
|
|
- this.userinfo = userinfo
|
|
|
- this.stu_number = userinfo.card_number
|
|
|
- this.id_card = userinfo.id_card
|
|
|
+ _this.userinfo = userinfo;
|
|
|
+ _this.stu_number = userinfo.card_number;
|
|
|
+ _this.id_card = userinfo.id_card;
|
|
|
} else { // 还没有需要跳转到首页进行获取
|
|
|
uni.navigateTo({
|
|
|
- url: '../../pages/index/index?from=' + options.from
|
|
|
- })
|
|
|
+ url: '../../pages/index/index?from=' + _this.options.from
|
|
|
+ });
|
|
|
|
|
|
uni.showToast({
|
|
|
icon: 'none',
|
|
|
@@ -411,36 +395,31 @@
|
|
|
duration: 3000
|
|
|
});
|
|
|
|
|
|
- return
|
|
|
+ return;
|
|
|
}
|
|
|
} else { // 学号已经存在,可以从存储中拿用户信息
|
|
|
- this.userinfo = JSON.stringify(uni.getStorageSync('userinfo_storage_key'))
|
|
|
+ _this.userinfo = JSON.stringify(uni.getStorageSync('userinfo_storage_key'));
|
|
|
}
|
|
|
} catch (e) {
|
|
|
console.log('获取基本信息:' + e.message);
|
|
|
}
|
|
|
// 获取code
|
|
|
- this.getCode(options, param)
|
|
|
-
|
|
|
- // if (this.id_card !== '') {
|
|
|
- // // 查询绑定的空调
|
|
|
- // this.select_banding_airs()
|
|
|
- // }
|
|
|
+ _this.getCode(param);
|
|
|
},
|
|
|
/**
|
|
|
* 获得code
|
|
|
*/
|
|
|
- getCode(options, param) {
|
|
|
+ getCode(param) {
|
|
|
var _this = this;
|
|
|
uni.login({
|
|
|
success: (res) => {
|
|
|
// console.log('getCode', res);
|
|
|
if (res.code) {
|
|
|
if (param == 'get_user_info') {
|
|
|
- _this.getUserInfo(res.code)
|
|
|
+ _this.getUserInfo(res.code);
|
|
|
} else {
|
|
|
// 请求服务器,获得openid
|
|
|
- _this.getOpenId(options, res.code)
|
|
|
+ _this.getOpenId(res.code);
|
|
|
}
|
|
|
} else {
|
|
|
uni.showToast({
|
|
|
@@ -449,12 +428,12 @@
|
|
|
});
|
|
|
}
|
|
|
}
|
|
|
- })
|
|
|
+ });
|
|
|
},
|
|
|
/**
|
|
|
* 请求服务器,获得openid
|
|
|
*/
|
|
|
- async getOpenId(options, param_code) {
|
|
|
+ async getOpenId(param_code) {
|
|
|
var _this = this;
|
|
|
if (typeof _this.userinfo === 'object') {
|
|
|
_this.userinfo = JSON.stringify(_this.userinfo)
|
|
|
@@ -475,27 +454,19 @@
|
|
|
// console.log(res.data);
|
|
|
if (res.data.code == 200) {
|
|
|
// 查询用户基本信息
|
|
|
- _this.getCode(options, 'get_user_info')
|
|
|
- // 绑定成功,提示返回信息,但没必要提示
|
|
|
- // uni.showToast({
|
|
|
- // title: res.data.message
|
|
|
- // })
|
|
|
+ _this.getCode('get_user_info')
|
|
|
} else if (res.data.code == 205) {
|
|
|
// 查询用户基本信息
|
|
|
- _this.getCode(options, 'get_user_info')
|
|
|
- // 用户已经存在,但没必要提示
|
|
|
- // uni.showToast({
|
|
|
- // title: res.data.message
|
|
|
- // })
|
|
|
+ _this.getCode('get_user_info')
|
|
|
} else {
|
|
|
// 提示返回信息
|
|
|
uni.showToast({
|
|
|
title: res.data.message
|
|
|
})
|
|
|
|
|
|
- if (options && typeof(options.from) != 'undefined' && typeof(options.from) != '') {
|
|
|
+ if (_this.options && typeof _this.options.from != 'undefined' && typeof _this.options.from != '') {
|
|
|
uni.navigateTo({
|
|
|
- url: '../../pages/index/index?from=' + options.from
|
|
|
+ url: '../../pages/index/index?from=' + _this.options.from
|
|
|
})
|
|
|
} else {
|
|
|
uni.redirectTo({
|
|
|
@@ -865,9 +836,6 @@
|
|
|
}
|
|
|
}
|
|
|
},
|
|
|
- onRestore() {
|
|
|
- this.triggered = true; // 需要重置
|
|
|
- },
|
|
|
/**
|
|
|
* 轮播图发生改变
|
|
|
* @param {Object} e
|
|
|
@@ -1165,4 +1133,4 @@
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
-</style>
|
|
|
+</style>
|