|
@@ -82,51 +82,40 @@
|
|
|
}
|
|
}
|
|
|
},
|
|
},
|
|
|
onLoad: function(options) {
|
|
onLoad: function(options) {
|
|
|
- // console.log('item:' + options.item);
|
|
|
|
|
|
|
+ let item_tmp = decodeURIComponent(options.item)
|
|
|
|
|
+ //将字符串解密转换成对象
|
|
|
|
|
+ let item = JSON.parse(item_tmp);
|
|
|
|
|
+ // console.log(options.o, item)
|
|
|
|
|
+ // 如果是选择宿舍号返回
|
|
|
|
|
+ if (options.o == 'select') {
|
|
|
|
|
+ this.roomSelect = item.roomSelect;
|
|
|
|
|
+ this.add_class = 1;
|
|
|
|
|
+ this.dom = item.dom;
|
|
|
|
|
+ }
|
|
|
try {
|
|
try {
|
|
|
// 获取存储的用户数据
|
|
// 获取存储的用户数据
|
|
|
const value = uni.getStorageSync('userinfo_storage_key')
|
|
const value = uni.getStorageSync('userinfo_storage_key')
|
|
|
- let item_tmp = decodeURIComponent(options.item)
|
|
|
|
|
-
|
|
|
|
|
- //将字符串解密转换成对象
|
|
|
|
|
- let item = JSON.parse(item_tmp);
|
|
|
|
|
// console.log(item)
|
|
// console.log(item)
|
|
|
if (item_tmp == '{}') { // 如果没有用户信息,返回首页
|
|
if (item_tmp == '{}') { // 如果没有用户信息,返回首页
|
|
|
uni.redirectTo({
|
|
uni.redirectTo({
|
|
|
url: '../index/index'
|
|
url: '../index/index'
|
|
|
- });
|
|
|
|
|
- return;
|
|
|
|
|
|
|
+ })
|
|
|
|
|
+ return
|
|
|
}
|
|
}
|
|
|
-
|
|
|
|
|
- //判断item是否存在
|
|
|
|
|
- if (item_tmp != '') {
|
|
|
|
|
- //判断是哪个页面传入
|
|
|
|
|
- if (typeof(item.roomSelect) != 'undefined') {
|
|
|
|
|
- // this.item = item;
|
|
|
|
|
- this.roomSelect = item.roomSelect;
|
|
|
|
|
- this.add_class = 1;
|
|
|
|
|
- this.dom = item.dom;
|
|
|
|
|
- // console.log(this.roomSelect)
|
|
|
|
|
- } else {
|
|
|
|
|
- // 处理JSON字符串
|
|
|
|
|
- // this.userinfo = options.item.replace(/"/g, "'");
|
|
|
|
|
- this.userinfo = item;
|
|
|
|
|
- // 更新存储的用户信息
|
|
|
|
|
- uni.setStorageSync('userinfo_storage_key', this.userinfo)
|
|
|
|
|
- // console.log(this.userinfo)
|
|
|
|
|
- this.campus = this.userinfo.campus
|
|
|
|
|
- this.dom = this.userinfo.dorm_number
|
|
|
|
|
- this.sub_appid = this.userinfo.sub_appid
|
|
|
|
|
- this.roomSelect = this.campus + this.dom
|
|
|
|
|
- this.add_class = 1
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ // 如果是选择宿舍号返回
|
|
|
|
|
+ if (options.o == 'index') {
|
|
|
|
|
+ this.userinfo = item;
|
|
|
|
|
+ // 更新存储的用户信息
|
|
|
|
|
+ uni.setStorageSync('userinfo_storage_key', this.userinfo)
|
|
|
|
|
+ this.roomSelect = this.campus + this.dom
|
|
|
} else if (value != '') {
|
|
} else if (value != '') {
|
|
|
- // 处理JSON字符串
|
|
|
|
|
- // this.userinfo = value.replace(/"/g, "'");
|
|
|
|
|
this.userinfo = value;
|
|
this.userinfo = value;
|
|
|
}
|
|
}
|
|
|
- // console.log(this.dom)
|
|
|
|
|
- // console.log(this.campus)
|
|
|
|
|
|
|
+ this.campus = this.userinfo.campus
|
|
|
|
|
+ this.dom = this.userinfo.dorm_number
|
|
|
|
|
+ this.sub_appid = this.userinfo.sub_appid
|
|
|
|
|
+
|
|
|
|
|
+ this.add_class = 1
|
|
|
} catch (e) {
|
|
} catch (e) {
|
|
|
console.log(e)
|
|
console.log(e)
|
|
|
}
|
|
}
|
|
@@ -139,13 +128,6 @@
|
|
|
},
|
|
},
|
|
|
|
|
|
|
|
methods: {
|
|
methods: {
|
|
|
- //修改房间号
|
|
|
|
|
- // changeSelect1(e) {
|
|
|
|
|
- // console.log(e);
|
|
|
|
|
- // this.index = e.detail.value;
|
|
|
|
|
- // this.arr1 = this.array1;
|
|
|
|
|
- // },
|
|
|
|
|
-
|
|
|
|
|
/**
|
|
/**
|
|
|
* 获取应用有效凭证
|
|
* 获取应用有效凭证
|
|
|
*/
|
|
*/
|
|
@@ -186,7 +168,7 @@
|
|
|
});
|
|
});
|
|
|
},
|
|
},
|
|
|
|
|
|
|
|
- //跳转到显示页面
|
|
|
|
|
|
|
+ //跳转到台账页面
|
|
|
navigateToShow(e) {
|
|
navigateToShow(e) {
|
|
|
uni.navigateTo({
|
|
uni.navigateTo({
|
|
|
url: '../show/show?card_number=' + this.card_number,
|
|
url: '../show/show?card_number=' + this.card_number,
|
|
@@ -198,73 +180,74 @@
|
|
|
this.add_class1 = 0
|
|
this.add_class1 = 0
|
|
|
this.addMoney = e.currentTarget.dataset.item
|
|
this.addMoney = e.currentTarget.dataset.item
|
|
|
|
|
|
|
|
- this.confirm_info()
|
|
|
|
|
|
|
+ this.confirm_room('add_money')
|
|
|
},
|
|
},
|
|
|
|
|
|
|
|
- confirm_info(num_money) {
|
|
|
|
|
|
|
+ confirm_room(op) {
|
|
|
|
|
+ // 检查房间号
|
|
|
if (this.roomSelect == '') {
|
|
if (this.roomSelect == '') {
|
|
|
uni.showToast({
|
|
uni.showToast({
|
|
|
title: '请选择房间号',
|
|
title: '请选择房间号',
|
|
|
- icon:'success'
|
|
|
|
|
|
|
+ icon: 'success'
|
|
|
})
|
|
})
|
|
|
-
|
|
|
|
|
return
|
|
return
|
|
|
}
|
|
}
|
|
|
-
|
|
|
|
|
|
|
+ // 输入金额进行充值
|
|
|
|
|
+ if (op == 'input_money') {
|
|
|
|
|
+ //判断输入是否为空或不是数字
|
|
|
|
|
+ if (this.inputMoney == '' || this.inputMoney == null) {
|
|
|
|
|
+ uni.showToast({
|
|
|
|
|
+ title: '请输入充值金额',
|
|
|
|
|
+ duration: 2000
|
|
|
|
|
+ })
|
|
|
|
|
+ return
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ if (isNaN(this.inputMoney)) {
|
|
|
|
|
+ uni.showToast({
|
|
|
|
|
+ title: '请输入数值',
|
|
|
|
|
+ duration: 2000
|
|
|
|
|
+ })
|
|
|
|
|
+ return
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ if (!this.test) {
|
|
|
|
|
+ if (this.inputMoney > 200 || this.inputMoney < 10) {
|
|
|
|
|
+ uni.showToast({
|
|
|
|
|
+ title: '限额10~200元',
|
|
|
|
|
+ duration: 2000
|
|
|
|
|
+ })
|
|
|
|
|
+ return
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ this.addMoney = this.inputMoney
|
|
|
|
|
+ }
|
|
|
|
|
+ // 确认充值对话框
|
|
|
|
|
+ this.confirm_dialog()
|
|
|
|
|
+ },
|
|
|
|
|
+ // 确认充值对话框
|
|
|
|
|
+ confirm_dialog() {
|
|
|
uni.showModal({
|
|
uni.showModal({
|
|
|
// title: '确定充值'+this.inputMoney+'元',
|
|
// title: '确定充值'+this.inputMoney+'元',
|
|
|
title: '确定充值' + this.addMoney + '元',
|
|
title: '确定充值' + this.addMoney + '元',
|
|
|
success: (res) => {
|
|
success: (res) => {
|
|
|
if (res.confirm) {
|
|
if (res.confirm) {
|
|
|
- this.pay_money_start()
|
|
|
|
|
|
|
+ this.jsapi()
|
|
|
} else if (res.cancel) {
|
|
} else if (res.cancel) {
|
|
|
console.log('用户点击取消');
|
|
console.log('用户点击取消');
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
})
|
|
})
|
|
|
},
|
|
},
|
|
|
-
|
|
|
|
|
//增加可变金额
|
|
//增加可变金额
|
|
|
input_money(e) {
|
|
input_money(e) {
|
|
|
// console.log(e)
|
|
// console.log(e)
|
|
|
- //判断输入是否为空或不是数字
|
|
|
|
|
- if (this.inputMoney == '' || this.inputMoney == null) {
|
|
|
|
|
- uni.showToast({
|
|
|
|
|
- title: '请输入充值金额',
|
|
|
|
|
- duration: 2000
|
|
|
|
|
- })
|
|
|
|
|
-
|
|
|
|
|
- return
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- if (isNaN(this.inputMoney)) {
|
|
|
|
|
- uni.showToast({
|
|
|
|
|
- title: '请输入数值',
|
|
|
|
|
- duration: 2000
|
|
|
|
|
- })
|
|
|
|
|
-
|
|
|
|
|
- return
|
|
|
|
|
- }
|
|
|
|
|
- if (this.test) {
|
|
|
|
|
-
|
|
|
|
|
- } else {
|
|
|
|
|
- if (this.inputMoney > 200 || this.inputMoney < 10) {
|
|
|
|
|
- uni.showToast({
|
|
|
|
|
- title: '限额10~200元',
|
|
|
|
|
- duration: 2000
|
|
|
|
|
- })
|
|
|
|
|
-
|
|
|
|
|
- return
|
|
|
|
|
- }
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- this.addMoney = this.inputMoney
|
|
|
|
|
-
|
|
|
|
|
- this.confirm_info()
|
|
|
|
|
|
|
+ this.confirm_room('input_money')
|
|
|
},
|
|
},
|
|
|
|
|
|
|
|
//准备支付
|
|
//准备支付
|
|
|
- async pay_money_start() {
|
|
|
|
|
|
|
+ async jsapi() {
|
|
|
const res = await this.$myRequest({
|
|
const res = await this.$myRequest({
|
|
|
host: 'wecard',
|
|
host: 'wecard',
|
|
|
url: "/cgi-bin/pay/app/mppay",
|
|
url: "/cgi-bin/pay/app/mppay",
|
|
@@ -278,13 +261,15 @@
|
|
|
'user_id': this.card_number,
|
|
'user_id': this.card_number,
|
|
|
"order_id": this.order_id = get_order_id('dianfei'),
|
|
"order_id": this.order_id = get_order_id('dianfei'),
|
|
|
"amount": this.addMoney * 100,
|
|
"amount": this.addMoney * 100,
|
|
|
|
|
+ 'order_type': 1,
|
|
|
|
|
+ 'callback_url': ''
|
|
|
}
|
|
}
|
|
|
})
|
|
})
|
|
|
|
|
|
|
|
if (res.data.code == 0) {
|
|
if (res.data.code == 0) {
|
|
|
this.pay_info = res.data.data.pay_info
|
|
this.pay_info = res.data.data.pay_info
|
|
|
// 发起支付
|
|
// 发起支付
|
|
|
- this.add_money_pay()
|
|
|
|
|
|
|
+ this.pay_amount()
|
|
|
} else {
|
|
} else {
|
|
|
uni.showToast({
|
|
uni.showToast({
|
|
|
icon: 'none',
|
|
icon: 'none',
|
|
@@ -294,8 +279,8 @@
|
|
|
}
|
|
}
|
|
|
},
|
|
},
|
|
|
|
|
|
|
|
- //调起支付
|
|
|
|
|
- add_money_pay() {
|
|
|
|
|
|
|
+ // 调起支付
|
|
|
|
|
+ pay_amount() {
|
|
|
var OpenMidas = require("@/static/openMidas.js"); // 引入小程序目录下的SDK文件
|
|
var OpenMidas = require("@/static/openMidas.js"); // 引入小程序目录下的SDK文件
|
|
|
|
|
|
|
|
// 设置支付配置
|
|
// 设置支付配置
|