|
@@ -112,23 +112,23 @@
|
|
|
this.$store.state.building.add_class = 0;
|
|
this.$store.state.building.add_class = 0;
|
|
|
|
|
|
|
|
// 获取code
|
|
// 获取code
|
|
|
- this.getCode('')
|
|
|
|
|
|
|
+ this.getCode(options, param)
|
|
|
}
|
|
}
|
|
|
},
|
|
},
|
|
|
/**
|
|
/**
|
|
|
* 获取code
|
|
* 获取code
|
|
|
*/
|
|
*/
|
|
|
- getCode(param) {
|
|
|
|
|
|
|
+ getCode(options, param) {
|
|
|
|
|
+ // console.log(options, param)
|
|
|
uni.login({
|
|
uni.login({
|
|
|
success: (res) => {
|
|
success: (res) => {
|
|
|
- // console.log('获得code', res);
|
|
|
|
|
if (res.code) {
|
|
if (res.code) {
|
|
|
// 请求服务器,获得openid
|
|
// 请求服务器,获得openid
|
|
|
if (param == 'comfirm') {
|
|
if (param == 'comfirm') {
|
|
|
// 获取IP
|
|
// 获取IP
|
|
|
this.getIP(res.code)
|
|
this.getIP(res.code)
|
|
|
} else
|
|
} else
|
|
|
- this.getOpenId(res.code)
|
|
|
|
|
|
|
+ this.getOpenId(options, res.code)
|
|
|
} else {
|
|
} else {
|
|
|
uni.showToast({
|
|
uni.showToast({
|
|
|
title: res.errMsg,
|
|
title: res.errMsg,
|
|
@@ -147,6 +147,7 @@
|
|
|
* 获取IP
|
|
* 获取IP
|
|
|
*/
|
|
*/
|
|
|
async getIP(param_code) {
|
|
async getIP(param_code) {
|
|
|
|
|
+ // console.log(param_code)
|
|
|
const res = await this.$myRequest({
|
|
const res = await this.$myRequest({
|
|
|
host: 'ip',
|
|
host: 'ip',
|
|
|
url: '?ie=utf-8',
|
|
url: '?ie=utf-8',
|
|
@@ -165,7 +166,8 @@
|
|
|
/**
|
|
/**
|
|
|
* 请求服务器,获得openid
|
|
* 请求服务器,获得openid
|
|
|
*/
|
|
*/
|
|
|
- async getOpenId(param_code) {
|
|
|
|
|
|
|
+ async getOpenId(options, param_code) {
|
|
|
|
|
+ // console.log(options, param_code)
|
|
|
if (param_code != '') {
|
|
if (param_code != '') {
|
|
|
const res = await this.$myRequest({
|
|
const res = await this.$myRequest({
|
|
|
host: this.ceshi,
|
|
host: this.ceshi,
|
|
@@ -196,9 +198,15 @@
|
|
|
this.getDianLiang()
|
|
this.getDianLiang()
|
|
|
} else if (res.data.mess == '未查询到用户信息') {
|
|
} else if (res.data.mess == '未查询到用户信息') {
|
|
|
// 跳转到首页
|
|
// 跳转到首页
|
|
|
- uni.redirectTo({
|
|
|
|
|
- url: '../index/index?from=0'
|
|
|
|
|
- });
|
|
|
|
|
|
|
+ if (options && typeof(options.from) != 'undefined' && typeof(options.from) != '') {
|
|
|
|
|
+ uni.navigateTo({
|
|
|
|
|
+ url: '../index/index?from=' + options.from
|
|
|
|
|
+ })
|
|
|
|
|
+ } else {
|
|
|
|
|
+ uni.redirectTo({
|
|
|
|
|
+ url: '../index/index?from=0'
|
|
|
|
|
+ });
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
if (this.roomSelect == '' || typeof(this.roomSelect) == 'undefined') {
|
|
if (this.roomSelect == '' || typeof(this.roomSelect) == 'undefined') {
|
|
@@ -206,10 +214,6 @@
|
|
|
if (typeof(userinfo) != 'undefined' && typeof(userinfo.campus) != 'undefined' && typeof(
|
|
if (typeof(userinfo) != 'undefined' && typeof(userinfo.campus) != 'undefined' && typeof(
|
|
|
userinfo.dorm_number) != 'undefined') {
|
|
userinfo.dorm_number) != 'undefined') {
|
|
|
this.roomSelect = userinfo.campus + userinfo.dorm_number
|
|
this.roomSelect = userinfo.campus + userinfo.dorm_number
|
|
|
-
|
|
|
|
|
- if (this.roomSelect == '' || typeof(this.roomSelect) == 'undefined') {
|
|
|
|
|
- this.roomSelect = '请选择宿舍号'
|
|
|
|
|
- }
|
|
|
|
|
} else {
|
|
} else {
|
|
|
uni.navigateTo({
|
|
uni.navigateTo({
|
|
|
url: '../index/index?from=' + options.from
|
|
url: '../index/index?from=' + options.from
|
|
@@ -222,6 +226,10 @@
|
|
|
});
|
|
});
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
+
|
|
|
|
|
+ if (this.roomSelect == '' || typeof(this.roomSelect) == 'undefined') {
|
|
|
|
|
+ this.roomSelect = '请选择宿舍号'
|
|
|
|
|
+ }
|
|
|
} else {
|
|
} else {
|
|
|
uni.showToast({
|
|
uni.showToast({
|
|
|
title: 'code为空!',
|
|
title: 'code为空!',
|
|
@@ -233,7 +241,7 @@
|
|
|
* 取得电费额度
|
|
* 取得电费额度
|
|
|
*/
|
|
*/
|
|
|
async getDianLiang() {
|
|
async getDianLiang() {
|
|
|
- if (this.roomSelect != '') {
|
|
|
|
|
|
|
+ if (this.roomSelect != '' && typeof(this.roomSelect) != 'undefined') {
|
|
|
const res = await this.$myRequest({
|
|
const res = await this.$myRequest({
|
|
|
host: this.ceshi,
|
|
host: this.ceshi,
|
|
|
url: '/HotWaters/buildoverElec.action',
|
|
url: '/HotWaters/buildoverElec.action',
|
|
@@ -256,7 +264,7 @@
|
|
|
}
|
|
}
|
|
|
} else {
|
|
} else {
|
|
|
uni.showToast({
|
|
uni.showToast({
|
|
|
- title: '宿舍号为空',
|
|
|
|
|
|
|
+ title: '未获得宿舍号',
|
|
|
icon: 'success'
|
|
icon: 'success'
|
|
|
});
|
|
});
|
|
|
}
|
|
}
|
|
@@ -336,7 +344,7 @@
|
|
|
success: (res) => {
|
|
success: (res) => {
|
|
|
if (res.confirm) {
|
|
if (res.confirm) {
|
|
|
// 获取code
|
|
// 获取code
|
|
|
- this.getCode('comfirm')
|
|
|
|
|
|
|
+ this.getCode('options', 'comfirm')
|
|
|
} else if (res.cancel) {
|
|
} else if (res.cancel) {
|
|
|
// console.log('用户点击取消');
|
|
// console.log('用户点击取消');
|
|
|
}
|
|
}
|