调整优惠卷-代金券
parent
554e83f6bc
commit
9bff65377b
|
|
@ -4,8 +4,9 @@
|
|||
*/
|
||||
|
||||
// 基础URL配置(注意:末尾不要加斜杠)
|
||||
const BASE_URL = 'https://guangsh.manage.hschengtai.com'
|
||||
// const BASE_URL = 'https://guangsh.manage.hschengtai.com'
|
||||
// const BASE_URL = 'http://192.168.0.97:48085'
|
||||
const BASE_URL = 'http://192.168.5.134:48085'
|
||||
// 是否正在刷新token(防止并发刷新)
|
||||
let isRefreshing = false
|
||||
// 等待刷新完成的请求队列
|
||||
|
|
|
|||
|
|
@ -30,10 +30,10 @@ export function getGuildStoreDetail(id) {
|
|||
})
|
||||
}
|
||||
|
||||
// 获得工会优惠券
|
||||
export function getGuildCoupon(params = {}) {
|
||||
// 获得工会代金券
|
||||
export function getGuildVoucher(params = {}) {
|
||||
return request({
|
||||
url: '/app-api/member/labor-union-coupon/page',
|
||||
url: '/app-api/member/labor-union-voucher/page',
|
||||
method: 'GET',
|
||||
data: params,
|
||||
})
|
||||
|
|
@ -100,12 +100,12 @@ export function isNeedMap(params = {}) {
|
|||
})
|
||||
}
|
||||
|
||||
// 工会优惠券/商品下单并发起微信支付(需要后端返回小程序支付参数)
|
||||
// 工会代金券/商品下单并发起微信支付(需要后端返回小程序支付参数)
|
||||
// 约定:后端返回字段需包含 timeStamp、nonceStr、package、signType、paySign(或等价字段)
|
||||
// export function createGuildCouponWxPay(params = {}) {
|
||||
// export function createGuildVoucherWxPay(params = {}) {
|
||||
// return request({
|
||||
// // TODO: 如后端实际路径不同,请替换这里的 url
|
||||
// url: '/app-api/member/labor-union-coupon/pay',
|
||||
// url: '/app-api/member/labor-union-voucher/pay',
|
||||
// method: 'POST',
|
||||
// data: params,
|
||||
// showLoading: true,
|
||||
|
|
@ -136,18 +136,18 @@ export function updateLuOrderPayStatus(params = {}){
|
|||
})
|
||||
}
|
||||
|
||||
// 删除优惠卷购买 (暂时不用)
|
||||
// export function delCouponPurchaseBuy(id){
|
||||
// 删除代金券购买 (暂时不用)
|
||||
// export function delVoucherPurchaseBuy(id){
|
||||
// return request({
|
||||
// url: '/app-api/member/labor-union-coupon-purchase/delete?id='+id,
|
||||
// url: '/app-api/member/labor-union-voucher-purchase/delete?id='+id,
|
||||
// method: 'DELETE',
|
||||
// })
|
||||
// }
|
||||
|
||||
// // 取消优惠卷购买 (暂时不用)
|
||||
// export function cancelCouponPurchaseBuy(id){
|
||||
// // 取消代金券购买 (暂时不用)
|
||||
// export function cancelVoucherPurchaseBuy(id){
|
||||
// return request({
|
||||
// url: '/app-api/member/labor-union-coupon-purchase/cancel?id='+id,
|
||||
// url: '/app-api/member/labor-union-voucher-purchase/cancel?id='+id,
|
||||
// method: 'POST',
|
||||
// })
|
||||
// }
|
||||
|
|
|
|||
|
|
@ -129,7 +129,7 @@
|
|||
<script>
|
||||
import {
|
||||
getGuildStoreDetail,
|
||||
getGuildCoupon,
|
||||
getGuildVoucher,
|
||||
getPaySign,
|
||||
appBuy
|
||||
} from "@/api/service";
|
||||
|
|
@ -265,10 +265,10 @@ export default {
|
|||
}
|
||||
},
|
||||
|
||||
// 加载工会优惠券
|
||||
// 加载工会代金券
|
||||
async loadStoreMenu(shopId) {
|
||||
try {
|
||||
const res = await getGuildCoupon({ shopId });
|
||||
const res = await getGuildVoucher({ shopId });
|
||||
console.log(res, 11119);
|
||||
if (res && res.list) {
|
||||
this.menuList = res.list;
|
||||
|
|
@ -360,19 +360,19 @@ export default {
|
|||
return;
|
||||
}
|
||||
//
|
||||
// 把选中的数据拼接成这样的数据 couponId:num;couponId:num 例如 2324:1;2325:2
|
||||
const couponStr = selectedItems
|
||||
// 把选中的数据拼接成这样的数据 voucherId:num;voucherId:num 例如 2324:1;2325:2
|
||||
const voucherStr = selectedItems
|
||||
.map((item) => `${item.id}:${item.quantity}`)
|
||||
.join(";");
|
||||
|
||||
// this.totalAmount 是元, 要转换成分
|
||||
const trxamt = (this.totalAmount * 100).toFixed(0);
|
||||
|
||||
console.log("购买信息: " + couponStr);
|
||||
console.log("购买信息: " + voucherStr);
|
||||
console.log("金额:" + trxamt);
|
||||
const res = await appBuy({
|
||||
shopId: this.shopId,
|
||||
couponData: couponStr,
|
||||
voucherData: voucherStr,
|
||||
payableAmount: trxamt,
|
||||
});
|
||||
console.log(res);
|
||||
|
|
@ -391,25 +391,25 @@ export default {
|
|||
// const reqsn =
|
||||
// "mini" + Date.now() + "" + Math.floor(Math.random() * 10000);
|
||||
|
||||
const couponArray = order.couponPurchaseRespVOS || [];
|
||||
const couponMap = new Map();
|
||||
const voucherArray = order.voucherPurchaseRespVOS || [];
|
||||
const voucherMap = new Map();
|
||||
|
||||
couponArray.forEach((item) => {
|
||||
const key = item.couponId;
|
||||
voucherArray.forEach((item) => {
|
||||
const key = item.voucherId;
|
||||
if (!key) return;
|
||||
|
||||
// 从 Map 中获取已有数组,没有则取空数组
|
||||
const currentList = couponMap.get(key) || [];
|
||||
const currentList = voucherMap.get(key) || [];
|
||||
currentList.push(item);
|
||||
// 更新 Map 中的值
|
||||
couponMap.set(key, currentList);
|
||||
voucherMap.set(key, currentList);
|
||||
});
|
||||
let bodyStr = ''
|
||||
couponMap.forEach((couponList, couponId) => {
|
||||
console.log(`优惠券ID:${couponId}`);
|
||||
console.log(`优惠券列表:`, couponList);
|
||||
const name = couponList[0] && couponList[0].couponName ? couponList[0].couponName : "商品";
|
||||
bodyStr = bodyStr + name + 'x' + couponList.length + ';';
|
||||
voucherMap.forEach((voucherList, voucherId) => {
|
||||
console.log(`代金券ID:${voucherId}`);
|
||||
console.log(`代金券列表:`, voucherList);
|
||||
const name = voucherList[0] && voucherList[0].voucherName ? voucherList[0].voucherName : "商品";
|
||||
bodyStr = bodyStr + name + 'x' + voucherList.length + ';';
|
||||
});
|
||||
|
||||
const randomstr = Math.floor(Math.random() * 10000000) + "";
|
||||
|
|
|
|||
|
|
@ -78,13 +78,13 @@
|
|||
<view
|
||||
class="record-goods"
|
||||
v-for="(goods, gIndex) in getGoodsList(item)"
|
||||
:key="goods.id || goods.couponId || gIndex"
|
||||
:key="goods.id || goods.voucherId || gIndex"
|
||||
>
|
||||
<image
|
||||
class="goods-image"
|
||||
:src="
|
||||
goods.coverUrl ||
|
||||
goods.couponCoverUrl ||
|
||||
goods.voucherCoverUrl ||
|
||||
goods.picUrl ||
|
||||
'/static/home/entry_icon.png'
|
||||
"
|
||||
|
|
@ -92,7 +92,7 @@
|
|||
></image>
|
||||
<view class="goods-info">
|
||||
<text class="goods-title">{{
|
||||
goods.couponName || goods.name
|
||||
goods.voucherName || goods.name
|
||||
}}</text>
|
||||
<!-- <text class="goods-subtitle">
|
||||
订单号:{{ item.orderNumber }}
|
||||
|
|
@ -207,13 +207,13 @@
|
|||
<view class="qr-modal-close" @click="closeQrModal">×</view>
|
||||
</view>
|
||||
<view class="qr-modal-body">
|
||||
<view class="qr-code-box" v-if="qrModalData.couponCode">
|
||||
<view class="qr-code-box" v-if="qrModalData.voucherCode">
|
||||
<image
|
||||
class="qr-code-image"
|
||||
:src="qrCodeImageUrl"
|
||||
mode="aspectFit"
|
||||
></image>
|
||||
<!-- <text class="qr-code-text">{{ qrModalData.couponCode }}</text> -->
|
||||
<!-- <text class="qr-code-text">{{ qrModalData.voucherCode }}</text> -->
|
||||
</view>
|
||||
<text v-else class="qr-code-empty">暂无券码</text>
|
||||
</view>
|
||||
|
|
@ -251,7 +251,7 @@ export default {
|
|||
qrModalVisible: false,
|
||||
qrModalData: {
|
||||
useStatus: 0,
|
||||
couponCode: "",
|
||||
voucherCode: "",
|
||||
},
|
||||
};
|
||||
},
|
||||
|
|
@ -263,7 +263,7 @@ export default {
|
|||
return this.recordsMap[this.currentTab] || [];
|
||||
},
|
||||
qrCodeImageUrl() {
|
||||
const code = this.qrModalData.couponCode || "";
|
||||
const code = this.qrModalData.voucherCode || "";
|
||||
if (!code) return "";
|
||||
return `https://api.qrserver.com/v1/create-qr-code/?size=400x400&data=${encodeURIComponent(code)}`;
|
||||
},
|
||||
|
|
@ -277,9 +277,9 @@ export default {
|
|||
this.loadData();
|
||||
},
|
||||
methods: {
|
||||
// 一个订单可能包含多个商品(couponPurchaseRespVOS)
|
||||
// 一个订单可能包含多个商品(voucherPurchaseRespVOS)
|
||||
getGoodsList(order) {
|
||||
const list = (order && order.couponPurchaseRespVOS) || [];
|
||||
const list = (order && order.voucherPurchaseRespVOS) || [];
|
||||
return Array.isArray(list) && list.length ? list : [order || {}];
|
||||
},
|
||||
// 金额分转元(去掉后两位)
|
||||
|
|
@ -465,24 +465,24 @@ export default {
|
|||
uni.showToast({ title: "订单信息异常", icon: "none" });
|
||||
return;
|
||||
}
|
||||
const couponArray = item.couponPurchaseRespVOS || [];
|
||||
const couponMap = new Map();
|
||||
couponArray.forEach((goods) => {
|
||||
const key = goods.couponId;
|
||||
const voucherArray = item.voucherPurchaseRespVOS || [];
|
||||
const voucherMap = new Map();
|
||||
voucherArray.forEach((goods) => {
|
||||
const key = goods.voucherId;
|
||||
if (!key) return;
|
||||
const currentList = couponMap.get(key) || [];
|
||||
const currentList = voucherMap.get(key) || [];
|
||||
currentList.push(goods);
|
||||
couponMap.set(key, currentList);
|
||||
voucherMap.set(key, currentList);
|
||||
});
|
||||
let bodyStr = "";
|
||||
couponMap.forEach((couponList) => {
|
||||
voucherMap.forEach((voucherList) => {
|
||||
bodyStr =
|
||||
bodyStr +
|
||||
(couponList[0] && couponList[0].couponName
|
||||
? couponList[0].couponName
|
||||
(voucherList[0] && voucherList[0].voucherName
|
||||
? voucherList[0].voucherName
|
||||
: "商品") +
|
||||
"x" +
|
||||
couponList.length +
|
||||
voucherList.length +
|
||||
";";
|
||||
});
|
||||
|
||||
|
|
@ -546,15 +546,15 @@ export default {
|
|||
icon: "none",
|
||||
});
|
||||
},
|
||||
// 点击二维码图标:打开弹窗,展示券状态 + 根据 couponCode 生成二维码
|
||||
// 点击二维码图标:打开弹窗,展示券状态 + 根据 voucherCode 生成二维码
|
||||
handleQrCode(item, goods) {
|
||||
const useStatus = goods?.useStatus ?? item?.useStatus ?? 0;
|
||||
const couponCode =
|
||||
(goods && (goods.couponCode || goods.couponNo)) ||
|
||||
item?.couponCode ||
|
||||
item?.couponNo ||
|
||||
const voucherCode =
|
||||
(goods && (goods.voucherCode || goods.voucherNo)) ||
|
||||
item?.voucherCode ||
|
||||
item?.voucherNo ||
|
||||
"";
|
||||
this.qrModalData = { useStatus, couponCode };
|
||||
this.qrModalData = { useStatus, voucherCode };
|
||||
this.qrModalVisible = true;
|
||||
},
|
||||
getQrUseStatusText(useStatus) {
|
||||
|
|
|
|||
Loading…
Reference in New Issue