|
|
@@ -71,10 +71,12 @@
|
|
|
inputMoney: '', //手动输入增加金额
|
|
|
addMoney: 0, //选择充值金额
|
|
|
sub_appid: '', //商户号
|
|
|
+ code: '',
|
|
|
+ IP: '',
|
|
|
xiaofei_items: '', // 消费记录
|
|
|
- ceshi: 'code',
|
|
|
dorm_number: '', //栋宿舍号
|
|
|
compus: '', //校区
|
|
|
+ ceshi: 'code',
|
|
|
test: this.$store.state.test
|
|
|
}
|
|
|
},
|
|
|
@@ -83,7 +85,7 @@
|
|
|
this.$store.state.building.roomSelect = '';
|
|
|
this.$store.state.building.add_class = 0;
|
|
|
this.$store.state.building.dorm_number = '';
|
|
|
-
|
|
|
+
|
|
|
// 获得code
|
|
|
this.getCode()
|
|
|
},
|
|
|
@@ -93,7 +95,7 @@
|
|
|
this.roomSelect = this.$store.state.building.roomSelect;
|
|
|
this.add_class = this.$store.state.building.add_class;
|
|
|
this.dorm_number = this.$store.state.building.dorm_number;
|
|
|
-
|
|
|
+
|
|
|
this.add_class = 1
|
|
|
if (this.roomSelect != '') {
|
|
|
this.getDianLiang()
|
|
|
@@ -134,13 +136,13 @@
|
|
|
url: '/',
|
|
|
method: 'POST'
|
|
|
})
|
|
|
-
|
|
|
+
|
|
|
if (res) {
|
|
|
// console.log(res);
|
|
|
const reg = /\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}/;
|
|
|
let ip = reg.exec(res.data);
|
|
|
this.IP = ip[0]
|
|
|
-
|
|
|
+
|
|
|
// 组合地址,发起支付
|
|
|
this.jsapi()
|
|
|
}
|
|
|
@@ -149,39 +151,46 @@
|
|
|
* 请求服务器,获得openid
|
|
|
*/
|
|
|
async getOpenId() {
|
|
|
- const res = await this.$myRequest({
|
|
|
- host: this.ceshi,
|
|
|
- url: '/HotWaters/wpget_stu.action',
|
|
|
- method: 'POST',
|
|
|
- header: {
|
|
|
- 'content-type': 'application/x-www-form-urlencoded'
|
|
|
- },
|
|
|
- data: {
|
|
|
- code: this.code
|
|
|
- }
|
|
|
- })
|
|
|
+ if (this.code != '') {
|
|
|
+ const res = await this.$myRequest({
|
|
|
+ host: this.ceshi,
|
|
|
+ url: '/HotWaters/wpget_stu.action',
|
|
|
+ method: 'POST',
|
|
|
+ header: {
|
|
|
+ 'content-type': 'application/x-www-form-urlencoded'
|
|
|
+ },
|
|
|
+ data: {
|
|
|
+ code: this.code
|
|
|
+ }
|
|
|
+ })
|
|
|
|
|
|
- // console.log('获得openid', res);
|
|
|
- if (res.data.mess == '返回成功') {
|
|
|
- // 学号
|
|
|
- this.$store.state.stu_number = res.data.info[0].stu_number
|
|
|
- // 栋宿舍号
|
|
|
- this.dorm_number = res.data.info[0].build + res.data.info[0].dom
|
|
|
- // 校区
|
|
|
- this.compus = res.data.info[0].campus
|
|
|
- // 填充校区宿舍号
|
|
|
- this.roomSelect = this.compus + this.dorm_number.split('栋')[1]
|
|
|
- // 存储选择
|
|
|
- this.$store.state.building.roomSelect = this.roomSelect
|
|
|
- // 样式
|
|
|
- this.add_class = 1
|
|
|
-
|
|
|
- // 请求选定的月份消费记录
|
|
|
- this.getDianLiang()
|
|
|
-
|
|
|
- } else if (res.data.mess == '未查询到用户信息') {
|
|
|
- uni.redirectTo({
|
|
|
- url: '../index/index'
|
|
|
+ // console.log('获得openid', res);
|
|
|
+ if (res.data.mess == '返回成功') {
|
|
|
+ // 学号
|
|
|
+ this.$store.state.stu_number = res.data.info[0].stu_number
|
|
|
+ // 栋宿舍号
|
|
|
+ this.dorm_number = res.data.info[0].build + res.data.info[0].dom
|
|
|
+ // 校区
|
|
|
+ this.compus = res.data.info[0].campus
|
|
|
+ // 填充校区宿舍号
|
|
|
+ this.roomSelect = this.compus + this.dorm_number.split('栋')[1]
|
|
|
+ // 存储选择
|
|
|
+ this.$store.state.building.roomSelect = this.roomSelect
|
|
|
+ // 样式
|
|
|
+ this.add_class = 1
|
|
|
+
|
|
|
+ // 请求选定的月份消费记录
|
|
|
+ this.getDianLiang()
|
|
|
+
|
|
|
+ } else if (res.data.mess == '未查询到用户信息') {
|
|
|
+ uni.redirectTo({
|
|
|
+ url: '../index/index'
|
|
|
+ });
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ uni.showToast({
|
|
|
+ title: 'code为空!',
|
|
|
+ icon: 'success'
|
|
|
});
|
|
|
}
|
|
|
},
|
|
|
@@ -189,31 +198,32 @@
|
|
|
* 取得电费额度
|
|
|
*/
|
|
|
async getDianLiang() {
|
|
|
- let res;
|
|
|
- res = await this.$myRequest({
|
|
|
- host: 'code',
|
|
|
- url: '/HotWaters/buildoverElec.action',
|
|
|
- method: 'POST',
|
|
|
- header: {
|
|
|
- 'content-type': 'application/x-www-form-urlencoded'
|
|
|
- },
|
|
|
- data: {
|
|
|
- 'roomSelect': this.roomSelect
|
|
|
- }
|
|
|
- })
|
|
|
+ if (this.roomSelect != '') {
|
|
|
+ const res = await this.$myRequest({
|
|
|
+ host: 'code',
|
|
|
+ url: '/HotWaters/buildoverElec.action',
|
|
|
+ method: 'POST',
|
|
|
+ header: {
|
|
|
+ 'content-type': 'application/x-www-form-urlencoded'
|
|
|
+ },
|
|
|
+ data: {
|
|
|
+ 'roomSelect': this.roomSelect
|
|
|
+ }
|
|
|
+ })
|
|
|
|
|
|
- // console.log('取得电费额度', res);
|
|
|
- if (res.data.mess == '0') {
|
|
|
- setTimeout(() => {
|
|
|
- this.remainElec = res.data.amount.toFixed(2)
|
|
|
- }, 30);
|
|
|
+ // console.log('取得电费额度', res);
|
|
|
+ if (res.data.mess == '0') {
|
|
|
+ setTimeout(() => {
|
|
|
+ this.remainElec = res.data.amount.toFixed(2)
|
|
|
+ }, 30);
|
|
|
+ } else {
|
|
|
+ this.remainElec = 0.00.toFixed(2)
|
|
|
+ }
|
|
|
} else {
|
|
|
- this.remainElec = 0.00.toFixed(2)
|
|
|
- // uni.showToast({
|
|
|
- // // 未获取到户号
|
|
|
- // title: res.data.mess,
|
|
|
- // duration: 2000
|
|
|
- // })
|
|
|
+ uni.showToast({
|
|
|
+ title: '宿舍号为空',
|
|
|
+ icon: 'success'
|
|
|
+ });
|
|
|
}
|
|
|
},
|
|
|
|
|
|
@@ -310,6 +320,12 @@
|
|
|
* 请求服务器,获取支付参数,并支付
|
|
|
*/
|
|
|
async jsapi() {
|
|
|
+ if (this.code == '' || this.addMoney == '' || this.IP == '') {
|
|
|
+ uni.showToast({
|
|
|
+ title: 'code、充值金额或IP为空'
|
|
|
+ });
|
|
|
+ return
|
|
|
+ }
|
|
|
const res = await this.$myRequest({
|
|
|
host: this.ceshi,
|
|
|
url: '/HotWaters/elPay.action',
|