|
@@ -15,7 +15,8 @@ Page({
|
|
|
users: [],
|
|
|
remarks: "",
|
|
|
showAmount: "¥0.00",
|
|
|
- isDelete: true
|
|
|
+ isDelete: true,
|
|
|
+ useDiscount: 0
|
|
|
},
|
|
|
onLoad(options) {
|
|
|
this.setData({
|
|
@@ -24,8 +25,22 @@ Page({
|
|
|
opUsers: options.users ? JSON.parse(options.users) : []
|
|
|
})
|
|
|
sys_payorderid = options.sys_payorderid;
|
|
|
- console.log(options)
|
|
|
this.getVersions(options.vid || "");
|
|
|
+ this.getDiscounts();
|
|
|
+ },
|
|
|
+ /* 获取优惠卷 */
|
|
|
+ getDiscounts() {
|
|
|
+ _Http.basic({
|
|
|
+ "id": 20230801162402,
|
|
|
+ "content": {
|
|
|
+ nocache: true
|
|
|
+ }
|
|
|
+ }).then(res => {
|
|
|
+ console.log("获取优惠卷", res)
|
|
|
+ this.setData({
|
|
|
+ discounts: res.data
|
|
|
+ })
|
|
|
+ })
|
|
|
},
|
|
|
/* 保存订单进度 */
|
|
|
changeOrder() {
|
|
@@ -172,6 +187,9 @@ Page({
|
|
|
// if (formatTime(new Date(), '-').split(" ")[0] >= date) users.push(v[idname] + '');
|
|
|
} else {
|
|
|
if (!users.some(v => v == v[idname])) users.push(v[idname] + '');
|
|
|
+ if (v.isleader == 0) this.setData({
|
|
|
+ useDiscount: this.data.useDiscount += 1
|
|
|
+ })
|
|
|
}
|
|
|
}
|
|
|
});
|
|
@@ -185,21 +203,44 @@ Page({
|
|
|
},
|
|
|
onChange(e) {
|
|
|
const {
|
|
|
- id
|
|
|
+ id,
|
|
|
+ isleader
|
|
|
} = e.currentTarget.dataset;
|
|
|
- let users = this.data.users;
|
|
|
+ let users = this.data.users,
|
|
|
+ useDiscount = this.data.useDiscount;
|
|
|
if (users.some(v => v == id)) {
|
|
|
users = users.filter(s => s != id)
|
|
|
+ if (isleader == 0) useDiscount -= 1;
|
|
|
} else {
|
|
|
users.push(id + "")
|
|
|
+ if (isleader == 0) useDiscount += 1;
|
|
|
}
|
|
|
this.setData({
|
|
|
- users
|
|
|
+ users,
|
|
|
+ useDiscount
|
|
|
});
|
|
|
this.changeOrder();
|
|
|
},
|
|
|
+ examine() {
|
|
|
+ return new Promise((resolve, reject) => {
|
|
|
+ if (currency(this.data.showAmount).value == 0) {
|
|
|
+ wx.showModal({
|
|
|
+ title: '提示',
|
|
|
+ content: '优惠后金额为0,是否确认',
|
|
|
+ complete: (res) => {
|
|
|
+ if (res.cancel) resolve(false)
|
|
|
+ if (res.confirm) resolve(true)
|
|
|
+ }
|
|
|
+ })
|
|
|
+ } else {
|
|
|
+ resolve(true)
|
|
|
+ }
|
|
|
+ })
|
|
|
+ },
|
|
|
/* 支付 */
|
|
|
- payment() {
|
|
|
+ async payment() {
|
|
|
+ let isPayment = await this.examine();
|
|
|
+ if (!isPayment) return;
|
|
|
let that = this;
|
|
|
that.data.isDelete = false;
|
|
|
wx.login({
|
|
@@ -213,7 +254,6 @@ Page({
|
|
|
"trade_type": "JSAPI"
|
|
|
}
|
|
|
}).then(res => {
|
|
|
- console.log(res)
|
|
|
wx.requestPayment({
|
|
|
timeStamp: res.data.timeStamp,
|
|
|
nonceStr: res.data.nonceStr,
|
|
@@ -227,12 +267,19 @@ Page({
|
|
|
})
|
|
|
},
|
|
|
fail(err) {
|
|
|
- wx.showToast({
|
|
|
- title: '支付失败',
|
|
|
- icon: "error",
|
|
|
- mask: true
|
|
|
- })
|
|
|
- console.error(err)
|
|
|
+ if (res.msg == '成功' && currency(that.data.showAmount).value == 0) {
|
|
|
+ wx.showToast({
|
|
|
+ title: '支付成功',
|
|
|
+ mask: true
|
|
|
+ })
|
|
|
+ } else {
|
|
|
+ wx.showToast({
|
|
|
+ title: '支付失败',
|
|
|
+ icon: "error",
|
|
|
+ mask: true
|
|
|
+ })
|
|
|
+ console.error(err)
|
|
|
+ }
|
|
|
},
|
|
|
complete(e) {
|
|
|
console.log(e)
|