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