|
|
@@ -75,6 +75,7 @@
|
|
|
sub_appid: '', //商户号
|
|
|
xiaofei_items: '', // 消费记录
|
|
|
dorm_number: '', //栋宿舍号
|
|
|
+ stu_number: '',
|
|
|
compus: '', //校区
|
|
|
ceshi: 'code',
|
|
|
test: this.$store.state.test
|
|
|
@@ -103,7 +104,7 @@
|
|
|
try {
|
|
|
// 获取学号
|
|
|
this.stu_number = this.$store.state.userInfo.card_number
|
|
|
-
|
|
|
+
|
|
|
if (this.stu_number == '' || typeof(this.stu_number) == 'undefined') {
|
|
|
const userinfo = uni.getStorageSync('userinfo_storage_key')
|
|
|
if (userinfo) {
|
|
|
@@ -140,7 +141,6 @@
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
// 初始化参数
|
|
|
this.$store.state.building.add_class = 0;
|
|
|
|
|
|
@@ -155,18 +155,19 @@
|
|
|
uni.login({
|
|
|
success: (res) => {
|
|
|
if (res.code) {
|
|
|
- // 请求服务器,获得openid
|
|
|
if (param == 'comfirm') {
|
|
|
- // 获取IP
|
|
|
- this.getIP(res.code)
|
|
|
- } else
|
|
|
+ // 组合地址,发起支付
|
|
|
+ this.jsapi(res.code)
|
|
|
+ } else {
|
|
|
+ // 请求服务器,获得openid
|
|
|
this.getOpenId(options, res.code)
|
|
|
+ }
|
|
|
} else {
|
|
|
uni.showToast({
|
|
|
title: res.errMsg,
|
|
|
icon: 'none'
|
|
|
});
|
|
|
-
|
|
|
+
|
|
|
// 跳转到首页
|
|
|
uni.redirectTo({
|
|
|
url: '../index/index?from=0'
|
|
|
@@ -176,26 +177,6 @@
|
|
|
})
|
|
|
},
|
|
|
/**
|
|
|
- * 获取IP
|
|
|
- */
|
|
|
- async getIP(param_code) {
|
|
|
- // console.log(param_code)
|
|
|
- const res = await this.$myRequest({
|
|
|
- host: 'ip',
|
|
|
- url: '?ie=utf-8',
|
|
|
- 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.jsapi(param_code, ip[0])
|
|
|
- }
|
|
|
- },
|
|
|
- /**
|
|
|
* 请求服务器,获得openid
|
|
|
*/
|
|
|
async getOpenId(options, param_code) {
|
|
|
@@ -216,7 +197,7 @@
|
|
|
// console.log('获得openid', res);
|
|
|
if (res.data.mess == '返回成功') {
|
|
|
if (!(this.$store.state.building.roomSelect && typeof(this.$store.state.building.roomSelect) !=
|
|
|
- 'undefined')) {
|
|
|
+ 'undefined')) {
|
|
|
// 栋宿舍号
|
|
|
this.dorm_number = res.data.info[0].build + res.data.info[0].dom
|
|
|
// 校区
|
|
|
@@ -236,6 +217,13 @@
|
|
|
// 请求选定的月份消费记录
|
|
|
this.getDianLiang()
|
|
|
} else if (res.data.mess == '未查询到用户信息') {
|
|
|
+ // 数据库中 未查询到用户信息,就清除本地存储
|
|
|
+ uni.removeStorageSync('userinfo_storage_key');
|
|
|
+
|
|
|
+ uni.showToast({
|
|
|
+ title: '获取用户信息失败!'
|
|
|
+ })
|
|
|
+
|
|
|
// 跳转到首页
|
|
|
if (options && typeof(options.from) != 'undefined' && typeof(options.from) != '') {
|
|
|
uni.navigateTo({
|
|
|
@@ -389,8 +377,8 @@
|
|
|
/**
|
|
|
* 请求服务器,获取支付参数,并支付
|
|
|
*/
|
|
|
- async jsapi(param_code, param_ip) {
|
|
|
- if (param_code == '' || this.amount == '' || param_ip == '' || this.roomSelect == '') {
|
|
|
+ async jsapi(param_code) {
|
|
|
+ if (param_code == '' || this.amount == '' || this.roomSelect == '') {
|
|
|
uni.showToast({
|
|
|
title: 'code、充值金额、宿舍号或IP为空'
|
|
|
});
|
|
|
@@ -398,7 +386,7 @@
|
|
|
}
|
|
|
const res = await this.$myRequest({
|
|
|
host: this.ceshi,
|
|
|
- url: '/HotWaters/elPay.action',
|
|
|
+ url: '/HotWaters/elpay_ns.action',
|
|
|
method: 'POST',
|
|
|
header: {
|
|
|
'content-type': 'application/x-www-form-urlencoded'
|
|
|
@@ -406,25 +394,20 @@
|
|
|
data: {
|
|
|
code: param_code,
|
|
|
num: this.amount,
|
|
|
- ip: param_ip,
|
|
|
+ stu_number: this.stu_number,
|
|
|
roomSelect: this.roomSelect
|
|
|
}
|
|
|
})
|
|
|
|
|
|
// console.log(res);
|
|
|
- if (res.data.pay == 'error') {
|
|
|
- uni.showToast({
|
|
|
- title: '未获得支付参数',
|
|
|
- icon: 'success',
|
|
|
- duration: 3000
|
|
|
- });
|
|
|
- } else {
|
|
|
+ if (res.statusCode == 200 && res.data.sub_openid && res.data.sub_openid != '') {
|
|
|
wx.requestPayment({
|
|
|
- timeStamp: res.data.pay.timeStamp,
|
|
|
- nonceStr: res.data.pay.nonceStr,
|
|
|
- package: 'prepay_id=' + res.data.pay.prepay_id,
|
|
|
- signType: res.data.pay.signType,
|
|
|
- paySign: res.data.pay.paySign,
|
|
|
+ appId: res.data.appId,
|
|
|
+ timeStamp: res.data.timeStamp,
|
|
|
+ nonceStr: res.data.nonceStr,
|
|
|
+ package: res.data.package,
|
|
|
+ signType: res.data.signType,
|
|
|
+ paySign: res.data.paySign,
|
|
|
success: res => {
|
|
|
if (res.errMsg == 'requestPayment:ok') {
|
|
|
uni.showToast({
|
|
|
@@ -446,6 +429,12 @@
|
|
|
// console.log(res);
|
|
|
}
|
|
|
});
|
|
|
+ } else {
|
|
|
+ uni.showToast({
|
|
|
+ title: '未获得支付参数',
|
|
|
+ icon: 'success',
|
|
|
+ duration: 3000
|
|
|
+ });
|
|
|
}
|
|
|
},
|
|
|
/**
|