|
|
@@ -167,17 +167,23 @@
|
|
|
</view>
|
|
|
</view>
|
|
|
</mescroll-body>
|
|
|
+ <CustomToast ref="customToast">
|
|
|
+ </CustomToast>
|
|
|
</view>
|
|
|
</template>
|
|
|
|
|
|
<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";
|
|
|
+ import {checkPurchaseLimit,checkOrderPurchaseLimit} from '@/api/product';
|
|
|
+ import {CustomToast} from '@/components/custom-toast.vue';
|
|
|
+ import MescrollMixin from "@/uni_modules/mescroll-uni/components/mescroll-uni/mescroll-mixins.js";
|
|
|
export default {
|
|
|
- mixins: [MescrollMixin],
|
|
|
- data() {
|
|
|
+ mixins: [MescrollMixin],
|
|
|
+ components: {
|
|
|
+ CustomToast
|
|
|
+ },
|
|
|
+ data() {
|
|
|
return {
|
|
|
searchKey:"",
|
|
|
status:0,
|
|
|
@@ -360,10 +366,9 @@
|
|
|
});
|
|
|
}
|
|
|
else{
|
|
|
- // 检查限购
|
|
|
- let productId = null;
|
|
|
if(item.orderType==2){
|
|
|
- // 直播订单,从 item 中获取 productId
|
|
|
+ // 直播订单,限购逻辑不变,使用原有逻辑
|
|
|
+ let productId = null;
|
|
|
if(item.productId){
|
|
|
productId = item.productId;
|
|
|
} else if(item.itemJson){
|
|
|
@@ -374,47 +379,64 @@
|
|
|
console.error('解析 itemJson 失败:', e);
|
|
|
}
|
|
|
}
|
|
|
- } else {
|
|
|
- // 普通订单,从 items 中获取第一个商品的 productId
|
|
|
- if(item.items && item.items.length > 0 && item.items[0].jsonInfo){
|
|
|
+
|
|
|
+ // 如果获取到 productId,检查限购
|
|
|
+ if(productId){
|
|
|
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) {
|
|
|
+ const res = await checkPurchaseLimit({ productId: productId });
|
|
|
+ if (res.code !== 200) {
|
|
|
+ this.$refs.customToast.show({
|
|
|
+ title: res.msg || '该商品限购,目前剩余可购买数量不足',
|
|
|
+ duration: 2000
|
|
|
+ });
|
|
|
+ // uni.showToast({
|
|
|
+ // icon: 'none',
|
|
|
+ // title: res.msg || '该商品限购,目前剩余可购买数量不足'
|
|
|
+ // });
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ } catch (error) {
|
|
|
+ console.error('检查限购失败:', error);
|
|
|
uni.showToast({
|
|
|
icon: 'none',
|
|
|
- title: res.msg || '该商品限购,目前剩余可购买数量不足'
|
|
|
+ title: '检查限购失败,请稍后重试'
|
|
|
});
|
|
|
return;
|
|
|
}
|
|
|
- } catch (error) {
|
|
|
- console.error('检查限购失败:', error);
|
|
|
- uni.showToast({
|
|
|
- icon: 'none',
|
|
|
- title: '检查限购失败,请稍后重试'
|
|
|
- });
|
|
|
- return;
|
|
|
}
|
|
|
- }
|
|
|
-
|
|
|
- // 限购检查通过,进行支付跳转
|
|
|
- if(item.orderType==2){
|
|
|
+
|
|
|
// 支付
|
|
|
console.log("去支付", item)
|
|
|
uni.navigateTo({
|
|
|
url: `/pages_shopping/live/paymentOrder?orderList=${encodeURIComponent(JSON.stringify(item))}`
|
|
|
})
|
|
|
}else{
|
|
|
+ // 商城订单,使用新接口根据orderCode校验
|
|
|
+ if(item.orderCode){
|
|
|
+ try {
|
|
|
+ const res = await checkOrderPurchaseLimit({ orderCode: item.orderCode });
|
|
|
+ if (res.code !== 200) {
|
|
|
+ this.$refs.customToast.show({
|
|
|
+ title: res.msg || '订单商品限购校验失败',
|
|
|
+ duration: 2000
|
|
|
+ });
|
|
|
+ // uni.showToast({
|
|
|
+ // icon: 'none',
|
|
|
+ // title: res.msg || '订单商品限购校验失败'
|
|
|
+ // });
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ } catch (error) {
|
|
|
+ console.error('检查限购失败:', error);
|
|
|
+ uni.showToast({
|
|
|
+ icon: 'none',
|
|
|
+ title: '检查限购失败,请稍后重试'
|
|
|
+ });
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ // 限购检查通过,进行支付跳转
|
|
|
uni.navigateTo({
|
|
|
url: '/pages/shopping/paymentOrder?orderId='+item.id
|
|
|
})
|