|
|
@@ -173,6 +173,7 @@
|
|
|
<script>
|
|
|
import {getMyStoreOrderList,cancelOrder,canceliveOrder, deleteOrder as deleteOrderApi, cancelLiveOrder} from '@/api/storeOrder'
|
|
|
import {getDicts} from '@/api/index'
|
|
|
+ import {checkPurchaseLimit} from '@/api/product'
|
|
|
import MescrollMixin from "@/uni_modules/mescroll-uni/components/mescroll-uni/mescroll-mixins.js";
|
|
|
export default {
|
|
|
mixins: [MescrollMixin],
|
|
|
@@ -352,13 +353,61 @@
|
|
|
}
|
|
|
});
|
|
|
},
|
|
|
- pay(item) {
|
|
|
+ async pay(item) {
|
|
|
if(item.isPrescribe==1 && item.prescribeId==null){
|
|
|
uni.navigateTo({
|
|
|
url:"/pages/shopping/prescribe?orderId="+item.id
|
|
|
});
|
|
|
}
|
|
|
else{
|
|
|
+ // 检查限购
|
|
|
+ let productId = null;
|
|
|
+ if(item.orderType==2){
|
|
|
+ // 直播订单,从 item 中获取 productId
|
|
|
+ if(item.productId){
|
|
|
+ productId = item.productId;
|
|
|
+ } else if(item.itemJson){
|
|
|
+ try {
|
|
|
+ const itemJson = JSON.parse(item.itemJson);
|
|
|
+ productId = itemJson.productId;
|
|
|
+ } catch(e) {
|
|
|
+ console.error('解析 itemJson 失败:', e);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ // 普通订单,从 items 中获取第一个商品的 productId
|
|
|
+ if(item.items && item.items.length > 0 && item.items[0].jsonInfo){
|
|
|
+ try {
|
|
|
+ const jsonInfo = JSON.parse(item.items[0].jsonInfo);
|
|
|
+ productId = jsonInfo.productId;
|
|
|
+ } catch(e) {
|
|
|
+ console.error('解析 jsonInfo 失败:', e);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ // 如果获取到 productId,检查限购
|
|
|
+ if(productId){
|
|
|
+ try {
|
|
|
+ const res = await checkPurchaseLimit({ productId: productId });
|
|
|
+ if (res.code !== 200) {
|
|
|
+ uni.showToast({
|
|
|
+ icon: 'none',
|
|
|
+ title: res.msg || '该商品限购,目前剩余可购买数量不足'
|
|
|
+ });
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ } catch (error) {
|
|
|
+ console.error('检查限购失败:', error);
|
|
|
+ uni.showToast({
|
|
|
+ icon: 'none',
|
|
|
+ title: '检查限购失败,请稍后重试'
|
|
|
+ });
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ // 限购检查通过,进行支付跳转
|
|
|
if(item.orderType==2){
|
|
|
// 支付
|
|
|
console.log("去支付", item)
|