|
|
@@ -18,18 +18,26 @@
|
|
|
|
|
|
<view class="login-contont">
|
|
|
<view class="uInput">
|
|
|
- <u-input placeholder="请输入金额" border="bottom" :fontSize="40" type="digit"
|
|
|
- @change="validateInput($event, 1)" v-model="price" :customStyle="inpustyle">
|
|
|
+ <u-input placeholder="请输入金额" border="bottom" :fontSize="40" type="digit" v-model="price"
|
|
|
+ :customStyle="inpustyle">
|
|
|
<span slot="prefix" style="font-size: 30px">¥</span>
|
|
|
</u-input>
|
|
|
</view>
|
|
|
+ <view style="padding: 20rpx" v-if="voucherRadio">
|
|
|
+ <text style="font-size: 25rpx;">抵扣代金券后,实付金额</text><text
|
|
|
+ style="color: orange;font-size: 40rpx;margin-left: 10rpx;"> {{ payment }}</text>
|
|
|
+
|
|
|
+ </view>
|
|
|
<view class="login-contont-button">
|
|
|
<button class="btn" @click="Pay">立即支付</button>
|
|
|
<view style="padding: 0px 30rpx">
|
|
|
<view style="margin-top: 66rpx; background: #fff7f6">
|
|
|
<u-cell-group :border="false">
|
|
|
- <u-cell title="代金券折扣" :value="couponList.length + '个券可使用'" :border="false" isLink
|
|
|
- @click="voucher"></u-cell>
|
|
|
+ <u-cell title="代金券折扣" :border="false" isLink @click="voucher">
|
|
|
+ <template slot="value">
|
|
|
+ <text style="color: orange;">{{ CellText }}</text>
|
|
|
+ </template>
|
|
|
+ </u-cell>
|
|
|
</u-cell-group>
|
|
|
</view>
|
|
|
|
|
|
@@ -50,26 +58,31 @@
|
|
|
</view>
|
|
|
|
|
|
<view class="coupon-list">
|
|
|
- <view class="coupon-item" :class="item.status === 0 ? 'disabled' : 'active'"
|
|
|
- v-for="(item, index) in couponList" :key="index" @click="selectCoupon(index)">
|
|
|
- <view class="left">
|
|
|
- <view class="tag" :class="item.type === 1 ? 'independent' : 'chain'">
|
|
|
- {{ item.type === 1 ? '独立券' : '连锁券' }}
|
|
|
- </view>
|
|
|
- <view class="price">
|
|
|
- <text class="yen">¥</text>
|
|
|
- <text class="num">{{ item.price }}</text>
|
|
|
- <text class="tip">{{ item.desc }}</text>
|
|
|
+ <u-radio-group v-model="voucherRadio" placement="column" @change="groupChange" iconSize="30"
|
|
|
+ size="40">
|
|
|
+ <view class="coupon-item" :class="item.status === 0 ? 'disabled' : 'active'"
|
|
|
+ v-for="(item, index) in couponList" :key="index" @click="selectCoupon(index)">
|
|
|
+ <view class="left">
|
|
|
+ <view class="tag" :class="item.voucherType === 1 ? 'independent' : 'chain'">
|
|
|
+ {{ item.voucherType === 1 ? '独立券' : item.voucherType === 2 ? '连锁券' : '联合券' }}
|
|
|
+ </view>
|
|
|
+ <view class="price">
|
|
|
+ <text class="yen">¥</text>
|
|
|
+ <text class="num">{{ item.amount }}</text>
|
|
|
+ <text class="tip">{{ item.voucherRule == 1 ? '无门槛' : '满' + item.minOrderAmount + '减'
|
|
|
+ +
|
|
|
+ item.discountAmount }}</text>
|
|
|
+ </view>
|
|
|
+ <view class="info">
|
|
|
+ <text>{{ item.createTime }}</text>
|
|
|
+ <!-- <text>{{ item.scope }}</text> -->
|
|
|
+ </view>
|
|
|
</view>
|
|
|
- <view class="info">
|
|
|
- <text>{{ item.time }}</text>
|
|
|
- <text>{{ item.scope }}</text>
|
|
|
+ <view class="right">
|
|
|
+ <u-radio :name="item.id" iconSize="30" />
|
|
|
</view>
|
|
|
</view>
|
|
|
- <view class="right">
|
|
|
- <u-radio :checked="selectIndex === index" disabled :custom-style="radioStyle" />
|
|
|
- </view>
|
|
|
- </view>
|
|
|
+ </u-radio-group>
|
|
|
</view>
|
|
|
</view>
|
|
|
</u-popup>
|
|
|
@@ -95,39 +108,150 @@ export default {
|
|
|
},
|
|
|
price: null,
|
|
|
shopId: "",
|
|
|
+ storeId: "",
|
|
|
shopInfo: {},
|
|
|
localUserInfo: {},
|
|
|
- couponList: []
|
|
|
+ voucherRadio: null,
|
|
|
+ couponList: [
|
|
|
+ // {
|
|
|
+ // "amount": 2,
|
|
|
+ // "applyAllProducts": 1,
|
|
|
+ // "applyProductIds": [],
|
|
|
+ // "bizType": 14,
|
|
|
+ // "claimTime": "2026-04-11 09:56:51",
|
|
|
+ // "createTime": "2026-04-11 09:56:51",
|
|
|
+ // "discountAmount": null,
|
|
|
+ // "endTime": "2026-04-30 10:33:38",
|
|
|
+ // "id": "2042783907267350530",
|
|
|
+ // "isApply": 0,
|
|
|
+ // "minOrderAmount": null,
|
|
|
+ // "orderNo": "",
|
|
|
+ // "productIds": [],
|
|
|
+ // "ruleDisplay": "无门槛",
|
|
|
+ // "startTime": "2026-04-10 10:33:26",
|
|
|
+ // "status": 1,
|
|
|
+ // "storeCount": 1,
|
|
|
+ // "storeId": "2018881434293329922",
|
|
|
+ // "storeList": [
|
|
|
+ // {
|
|
|
+ // "isCreator": 1,
|
|
|
+ // "storeId": "2018881434293329922",
|
|
|
+ // "storeName": "医药one店",
|
|
|
+ // "voucherId": "2042068417733718017"
|
|
|
+ // }
|
|
|
+ // ],
|
|
|
+ // "storeName": "",
|
|
|
+ // "unApplyReason": "",
|
|
|
+ // "updateTime": "2026-04-11 09:56:47",
|
|
|
+ // "useTime": null,
|
|
|
+ // "userId": "1965353825816576001",
|
|
|
+ // "voucherId": "2042068417733718017",
|
|
|
+ // "voucherName": "2元代金券",
|
|
|
+ // "voucherRule": 1,
|
|
|
+ // "voucherType": 3,
|
|
|
+ // "voucherTypeDesc": "联合券"
|
|
|
+ // },
|
|
|
+ // {
|
|
|
+ // "amount": 2,
|
|
|
+ // "applyAllProducts": 1,
|
|
|
+ // "applyProductIds": [],
|
|
|
+ // "bizType": 14,
|
|
|
+ // "claimTime": "2026-04-11 09:56:50",
|
|
|
+ // "createTime": "2026-04-11 09:56:50",
|
|
|
+ // "discountAmount": null,
|
|
|
+ // "endTime": "2026-04-16 21:21:31",
|
|
|
+ // "id": "2042783902674587650",
|
|
|
+ // "isApply": 0,
|
|
|
+ // "minOrderAmount": null,
|
|
|
+ // "orderNo": "",
|
|
|
+ // "productIds": [],
|
|
|
+ // "ruleDisplay": "无门槛",
|
|
|
+ // "startTime": "2026-04-07 15:14:37",
|
|
|
+ // "status": 1,
|
|
|
+ // "storeCount": 1,
|
|
|
+ // "storeId": "2018881434293329922",
|
|
|
+ // "storeList": [
|
|
|
+ // {
|
|
|
+ // "isCreator": 1,
|
|
|
+ // "storeId": "2018881434293329922",
|
|
|
+ // "storeName": "医药one店",
|
|
|
+ // "voucherId": "2042139544933875713"
|
|
|
+ // }
|
|
|
+ // ],
|
|
|
+ // "storeName": "",
|
|
|
+ // "unApplyReason": "",
|
|
|
+ // "updateTime": "2026-04-11 09:56:46",
|
|
|
+ // "useTime": null,
|
|
|
+ // "userId": "1965353825816576001",
|
|
|
+ // "voucherId": "2042139544933875713",
|
|
|
+ // "voucherName": "联合券",
|
|
|
+ // "voucherRule": 1,
|
|
|
+ // "voucherType": 3,
|
|
|
+ // "voucherTypeDesc": "联合券"
|
|
|
+ // }
|
|
|
+ ],
|
|
|
+ CellText: "暂无代金券",
|
|
|
+ payment: ""
|
|
|
};
|
|
|
},
|
|
|
onLoad(options) {
|
|
|
this.shopId = options.shopId;
|
|
|
+ this.storeId = options.storeId;
|
|
|
localStorage.setItem("shopId", this.shopId);
|
|
|
+ localStorage.setItem("storeId", this.storeId);
|
|
|
let info = localStorage.getItem("weChatUserInfo");
|
|
|
this.localUserInfo = JSON.parse(info);
|
|
|
if (this.localUserInfo) {
|
|
|
this.getShopInfo();
|
|
|
+ this.getVoucher();
|
|
|
} else {
|
|
|
this.getInfo();
|
|
|
- this.getVoucher();
|
|
|
+
|
|
|
}
|
|
|
},
|
|
|
methods: {
|
|
|
+ groupChange(e) {
|
|
|
+ this.showPopup = false;
|
|
|
+ let targetObj = this.couponList.find(item => item.id === e)
|
|
|
+ if (targetObj.voucherRule === 1) {
|
|
|
+ this.CellText = `- ¥${targetObj.amount}`
|
|
|
+ } else {
|
|
|
+ this.CellText = `满${targetObj.minOrderAmount}减${targetObj.discountAmount}`
|
|
|
+ }
|
|
|
+ this.payment = this.price - targetObj.amount
|
|
|
+ console.log(this.price - targetObj.amount);
|
|
|
+
|
|
|
+ },
|
|
|
getVoucher() {
|
|
|
api
|
|
|
- .byStore({
|
|
|
- storeId: '2018881434293329922',
|
|
|
+ .availableList({
|
|
|
+ storeId: this.storeId,
|
|
|
})
|
|
|
.then((res) => {
|
|
|
if (res.code == 200) {
|
|
|
- this.couponList = res.data;
|
|
|
+ if (res.data.length > 0) {
|
|
|
+ this.couponList = res.data.filter(item => item.applyAllProducts !== 0)
|
|
|
+ this.CellText = '可使用' + this.couponList.length + '个'
|
|
|
+ } else {
|
|
|
+ this.CellText = '暂无代金券'
|
|
|
+ }
|
|
|
} else {
|
|
|
uni.$u.toast(res.msg);
|
|
|
}
|
|
|
});
|
|
|
},
|
|
|
voucher() {
|
|
|
- this.showPopup = true;
|
|
|
+ if (!this.price) {
|
|
|
+ uni.$u.toast("请输入支付金额!");
|
|
|
+ return
|
|
|
+ }
|
|
|
+ if (this.couponList.length == 0) {
|
|
|
+ uni.$u.toast("暂无代金券");
|
|
|
+ return;
|
|
|
+ } else {
|
|
|
+ this.showPopup = true;
|
|
|
+ }
|
|
|
+
|
|
|
},
|
|
|
getInfo() {
|
|
|
let code = this.GetQueryString("code");
|
|
|
@@ -138,20 +262,15 @@ export default {
|
|
|
code: code,
|
|
|
})
|
|
|
.then((res) => {
|
|
|
- console.log(res);
|
|
|
if (res.code == 200) {
|
|
|
this.userInfo = res.data;
|
|
|
- localStorage.setItem("token", this.userInfo.token);
|
|
|
+ localStorage.setItem("token", this.userInfo.access_token);
|
|
|
localStorage.setItem(
|
|
|
"weChatUserInfo",
|
|
|
JSON.stringify(this.userInfo),
|
|
|
);
|
|
|
- if (this.userInfo.bindPhoneStatus == 0) {
|
|
|
- this.showPhone = true;
|
|
|
- } else {
|
|
|
- this.showPhone = false;
|
|
|
- }
|
|
|
this.getShopInfo();
|
|
|
+ this.getVoucher();
|
|
|
} else {
|
|
|
uni.$u.toast("获取微信登录信息失败,请重新登录!");
|
|
|
}
|
|
|
@@ -174,17 +293,20 @@ export default {
|
|
|
uni.showLoading({
|
|
|
title: "支付中",
|
|
|
});
|
|
|
+ console.log(this.price);
|
|
|
+
|
|
|
if (!this.price) {
|
|
|
uni.$u.toast("请输入支付金额!");
|
|
|
+ return
|
|
|
}
|
|
|
api
|
|
|
.payOrder({
|
|
|
shopType: this.shopInfo.shopType,
|
|
|
shopUserId: this.shopInfo.shopUserId,
|
|
|
shopId: this.shopInfo.shopId,
|
|
|
- payAmount: Number(this.price),
|
|
|
+ payAmount: Number(this.payment) || Number(this.price),
|
|
|
payWay: 6,
|
|
|
- userId: this.localUserInfo.userId
|
|
|
+ // userId: this.localUserInfo.userId
|
|
|
})
|
|
|
.then((res) => {
|
|
|
if (res.code == 200) {
|
|
|
@@ -205,14 +327,10 @@ export default {
|
|
|
},
|
|
|
function (res) {
|
|
|
if (res.err_msg == "get_brand_wcpay_request:ok") {
|
|
|
- // 使用以上方式判断前端返回,
|
|
|
- // 微信团队郑重提示:
|
|
|
uni.hideLoading();
|
|
|
- // window.location.href = requestConfig.redirectOpen;
|
|
|
uni.navigateTo({
|
|
|
url: `/pages/index/paySuccess`,
|
|
|
});
|
|
|
- // res.err_msg将在用户支付成功后返回ok,但并不保证它绝对可靠。
|
|
|
} else {
|
|
|
uni.hideLoading();
|
|
|
uni.$u.toast("支付失败!");
|
|
|
@@ -236,17 +354,7 @@ export default {
|
|
|
if (r != null) return unescape(r[2]);
|
|
|
return null;
|
|
|
},
|
|
|
- validateInput(e, num) {
|
|
|
- const inputTypeNum = /[^\d]/g; //数字
|
|
|
- // switch (num) {
|
|
|
- // case 1:
|
|
|
- // //要写nextTick 不然无效
|
|
|
- // this.$nextTick(() => {
|
|
|
- // this.price = e.replace(inputTypeNum, "");
|
|
|
- // });
|
|
|
- // break;
|
|
|
- // }
|
|
|
- },
|
|
|
+
|
|
|
},
|
|
|
};
|
|
|
</script>
|
|
|
@@ -284,7 +392,7 @@ export default {
|
|
|
}
|
|
|
|
|
|
.coupon-item.active {
|
|
|
- border-color: #ff4d4f;
|
|
|
+ // border-color: #ff4d4f;
|
|
|
background: #fffbf4;
|
|
|
}
|
|
|
|
|
|
@@ -305,10 +413,12 @@ export default {
|
|
|
}
|
|
|
|
|
|
.independent {
|
|
|
+ width: 70rpx;
|
|
|
background: #5c8dff;
|
|
|
}
|
|
|
|
|
|
.chain {
|
|
|
+ width: 70rpx;
|
|
|
background: #ff7d00;
|
|
|
}
|
|
|
|