|
|
@@ -65,7 +65,7 @@
|
|
|
return {
|
|
|
index: 0,
|
|
|
roomSelect: '', //房间号
|
|
|
- remainElec: 80.10.toFixed(2), //剩余电量
|
|
|
+ remainElec: 0.00.toFixed(2), //剩余电量
|
|
|
add_class: '', //增加class属性
|
|
|
add_class1: '',
|
|
|
inputMoney: '', //手动输入增加金额
|
|
|
@@ -86,15 +86,9 @@
|
|
|
let item_tmp = decodeURIComponent(options.item)
|
|
|
//将字符串解密转换成对象
|
|
|
let item = JSON.parse(item_tmp);
|
|
|
- // 如果是选择宿舍号返回
|
|
|
- if (options.o == 'select') {
|
|
|
- this.roomSelect = item.roomSelect;
|
|
|
- this.add_class = 1;
|
|
|
- this.dom = item.dom;
|
|
|
-
|
|
|
- // 请求选定的月份消费记录
|
|
|
- this.request_consumption_records()
|
|
|
- }
|
|
|
+
|
|
|
+ // 请求选定的月份消费记录
|
|
|
+ // this.request_consumption_records()
|
|
|
try {
|
|
|
// 获取存储的用户数据
|
|
|
const value = uni.getStorageSync('userinfo_storage_key')
|
|
|
@@ -107,6 +101,10 @@
|
|
|
}
|
|
|
// 如果是选择宿舍号返回
|
|
|
if (options.o == 'index') {
|
|
|
+ this.$store.state.building.roomSelect = '';
|
|
|
+ this.$store.state.building.add_class = 0;
|
|
|
+ this.$store.state.building.dom = '';
|
|
|
+
|
|
|
this.userinfo = item;
|
|
|
// 更新存储的用户信息
|
|
|
uni.setStorageSync('userinfo_storage_key', this.userinfo)
|
|
|
@@ -117,7 +115,7 @@
|
|
|
this.campus = this.userinfo.campus
|
|
|
this.dom = this.userinfo.dorm_number
|
|
|
this.sub_appid = this.userinfo.sub_appid
|
|
|
-
|
|
|
+
|
|
|
this.add_class = 1
|
|
|
} catch (e) {
|
|
|
console.log(e)
|
|
|
@@ -126,12 +124,67 @@
|
|
|
//将缓存中的卡号进行获取
|
|
|
this.card_number = this.userinfo.card_number
|
|
|
|
|
|
- // 获取应用有效凭证
|
|
|
- this.get_valid_credentials()
|
|
|
+ if (this.$store.state.hasUserInfo == false) {
|
|
|
+ // 获取应用有效凭证
|
|
|
+ this.get_valid_credentials()
|
|
|
+ }
|
|
|
},
|
|
|
+ onShow() {
|
|
|
+ if (this.$store.state.building.roomSelect != '') {
|
|
|
+ // 如果是选择宿舍号返回
|
|
|
+ this.roomSelect = this.$store.state.building.roomSelect;
|
|
|
+ this.add_class = this.$store.state.building.add_class;
|
|
|
+ this.dom = this.$store.state.building.dom;
|
|
|
|
|
|
+ if (this.roomSelect != '') {
|
|
|
+ this.getDianLiang()
|
|
|
+ }
|
|
|
+ }
|
|
|
+ },
|
|
|
methods: {
|
|
|
/**
|
|
|
+ * 取得电费额度
|
|
|
+ */
|
|
|
+ async getDianLiang() {
|
|
|
+ let res;
|
|
|
+ if (this.test) { // 测试环境
|
|
|
+ res = await this.$myRequest({
|
|
|
+ host: 'ceshi',
|
|
|
+ url: 'http://tdqdjt.natappfree.cc/HotWaters/buildoverElec.action',
|
|
|
+ method: 'POST',
|
|
|
+ header: {
|
|
|
+ 'content-type': 'application/x-www-form-urlencoded'
|
|
|
+ },
|
|
|
+ data: {
|
|
|
+ 'roomSelect': this.roomSelect
|
|
|
+ }
|
|
|
+ })
|
|
|
+ } else {
|
|
|
+ res = await this.$myRequest({
|
|
|
+ host: 'code',
|
|
|
+ url: '/HotWater/buildoverElec.action',
|
|
|
+ method: 'POST',
|
|
|
+ header: {
|
|
|
+ 'content-type': 'application/x-www-form-urlencoded'
|
|
|
+ },
|
|
|
+ data: {
|
|
|
+ 'roomSelect': this.roomSelect
|
|
|
+ }
|
|
|
+ })
|
|
|
+ }
|
|
|
+ console.log(res.data.amount);
|
|
|
+ if (res.mess != '请选择房间号!') {
|
|
|
+ setTimeout(() => {
|
|
|
+ this.remainElec = res.data.amount.toFixed(2)
|
|
|
+ }, 300);
|
|
|
+ } else {
|
|
|
+ uni.showToast({
|
|
|
+ title: '获取电量失败!',
|
|
|
+ duration: 2000
|
|
|
+ })
|
|
|
+ }
|
|
|
+ },
|
|
|
+ /**
|
|
|
* 获取应用有效凭证
|
|
|
*/
|
|
|
async get_valid_credentials() {
|
|
|
@@ -162,11 +215,11 @@
|
|
|
duration: 2000
|
|
|
})
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
// 查询用户信息
|
|
|
this.select_user_info()
|
|
|
},
|
|
|
-
|
|
|
+
|
|
|
/**
|
|
|
* 查询用户信息
|
|
|
*/
|
|
|
@@ -182,11 +235,11 @@
|
|
|
card_number: this.userinfo.card_number
|
|
|
}
|
|
|
});
|
|
|
-
|
|
|
+
|
|
|
// console.log(res, 'select_user_info');
|
|
|
if (res.data.info) {
|
|
|
let cnumber = this.userinfo.card_number
|
|
|
-
|
|
|
+
|
|
|
if (cnumber == null || cnumber == undefined || cnumber == '') {
|
|
|
// 之前未绑定用户信息,现在去绑定用户信息
|
|
|
this.send_save_user_info()
|
|
|
@@ -198,14 +251,14 @@
|
|
|
})
|
|
|
}
|
|
|
},
|
|
|
-
|
|
|
+
|
|
|
/**
|
|
|
* 请求选定的月份消费记录
|
|
|
*/
|
|
|
async request_consumption_records() {
|
|
|
const userinfo = uni.getStorageInfoSync('userinfo_storage_key')
|
|
|
this.card_number = userinfo.card_number
|
|
|
-
|
|
|
+
|
|
|
if (this.card_number != '') {
|
|
|
this.xiaofei_items = []
|
|
|
const res = await this.$myRequest({
|
|
|
@@ -220,7 +273,7 @@
|
|
|
begin_time: this.date
|
|
|
}
|
|
|
});
|
|
|
-
|
|
|
+
|
|
|
// console.log(res.data.mess, 'request_consumption_records');
|
|
|
if (typeof(res.data.mess) != 'undefined') {
|
|
|
let items = res.data.mess
|
|
|
@@ -247,7 +300,7 @@
|
|
|
})
|
|
|
}
|
|
|
},
|
|
|
-
|
|
|
+
|
|
|
/**
|
|
|
* 绑定用户信息
|
|
|
*/
|
|
|
@@ -263,7 +316,7 @@
|
|
|
user: JSON.stringify(this.userinfo)
|
|
|
}
|
|
|
});
|
|
|
-
|
|
|
+
|
|
|
// console.log('send_save_user_info:', res)
|
|
|
let error = res.data.erro;
|
|
|
if (error == '未获取到数据!') {
|
|
|
@@ -330,7 +383,7 @@
|
|
|
return
|
|
|
}
|
|
|
|
|
|
- if (!this.test) {
|
|
|
+ if (!this.test) { // 非测试环境
|
|
|
if (this.inputMoney > 200 || this.inputMoney < 10) {
|
|
|
uni.showToast({
|
|
|
title: '限额10~200元',
|
|
|
@@ -436,7 +489,7 @@
|
|
|
* 输入充值金额
|
|
|
*/
|
|
|
onInput(e) {
|
|
|
- if (this.test) {
|
|
|
+ if (this.test) { // 测试环境
|
|
|
return
|
|
|
}
|
|
|
|
|
|
@@ -468,7 +521,7 @@
|
|
|
* 失去焦点时
|
|
|
*/
|
|
|
onBlur() {
|
|
|
- if (this.test) {
|
|
|
+ if (this.test) { // 测试环境
|
|
|
return
|
|
|
}
|
|
|
|