活动商品改为自提
This commit is contained in:
parent
b8dc69905e
commit
6fe1869a00
@ -2,18 +2,16 @@
|
|||||||
<view class="container">
|
<view class="container">
|
||||||
<!-- 顶部切换栏 -->
|
<!-- 顶部切换栏 -->
|
||||||
<view class="tab-bar">
|
<view class="tab-bar">
|
||||||
<view :class="{ active: activeTab === 'delivery' }" class="tab-item" @click="switchTab('delivery')">配送
|
<!-- <view :class="{ active: activeTab === 'delivery' }" class="tab-item" @click="switchTab('delivery')">配送
|
||||||
</view>
|
</view> -->
|
||||||
|
<view :class="{ active: activeTab === 'pickup' }" class="tab-item" @click="switchTab('pickup')">自提</view>
|
||||||
</view>
|
</view>
|
||||||
<!-- 分隔线 -->
|
<!-- 分隔线 -->
|
||||||
<view class="divider"></view>
|
<view class="divider"></view>
|
||||||
<!-- 配送信息 -->
|
<!-- 配送/自提信息 -->
|
||||||
<view class="info-section" v-if="activeTab === 'delivery'">
|
<view class="info-section" v-if="activeTab === 'delivery'">
|
||||||
<view class="address-section">
|
<view class="address-section">
|
||||||
<view class="section-title">
|
<view class="section-title">收货地址</view>
|
||||||
收货地址
|
|
||||||
<view v-if="!defAddress" class="addNewAddress" @click="chooseAddress">添加新地址 ></view>
|
|
||||||
</view>
|
|
||||||
<view class="address-info" @click="chooseAddress" v-if="defAddress">
|
<view class="address-info" @click="chooseAddress" v-if="defAddress">
|
||||||
<view class="address-main">
|
<view class="address-main">
|
||||||
<view class="address-name-phone">
|
<view class="address-name-phone">
|
||||||
@ -32,9 +30,9 @@
|
|||||||
<!-- 分隔线 -->
|
<!-- 分隔线 -->
|
||||||
<view class="divider"></view>
|
<view class="divider"></view>
|
||||||
<!-- 商品信息 -->
|
<!-- 商品信息 -->
|
||||||
<view v-if="activeTab === 'delivery' && orderList.length > 0">
|
<view v-if="activeTab === 'delivery' && orderList1.length > 0">
|
||||||
<view class="goods-list">
|
<view class="goods-list">
|
||||||
<view class="goods-item" v-for="(item, index) in orderList" :key="index">
|
<view class="goods-item" v-for="(item, index) in orderList1" :key="index">
|
||||||
<view class="goods-image">
|
<view class="goods-image">
|
||||||
<image :src="item.commodity_goods_info.commodity_pic" mode="aspectFill"></image>
|
<image :src="item.commodity_goods_info.commodity_pic" mode="aspectFill"></image>
|
||||||
</view>
|
</view>
|
||||||
@ -59,10 +57,15 @@
|
|||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
|
<!-- 运费 -->
|
||||||
|
<!-- <view class="fee-section">
|
||||||
|
<view class="fee-name">运费</view>
|
||||||
|
<view class="fee-value">¥{{ item.commodity_goods_info.freight }}</view>
|
||||||
|
</view> -->
|
||||||
<!-- 总金额 -->
|
<!-- 总金额 -->
|
||||||
<view class="total-section">
|
<view class="total-section">
|
||||||
<view class="total-name">总金额</view>
|
<view class="total-name">总金额</view>
|
||||||
<view class="total-value">¥{{ calculateTotal() }}</view>
|
<view class="total-value">¥{{ calculateTotal('order1') }}</view>
|
||||||
</view>
|
</view>
|
||||||
<!-- 支付方式 -->
|
<!-- 支付方式 -->
|
||||||
<view class="payment-section">
|
<view class="payment-section">
|
||||||
@ -90,7 +93,130 @@
|
|||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
<view v-if="activeTab === 'delivery' && orderList.length == 0" class="empty-tip">
|
<view v-if="activeTab === 'delivery' && orderList1.length == 0" class="empty-tip">
|
||||||
|
暂无商品数据
|
||||||
|
</view>
|
||||||
|
<view v-if="activeTab === 'pickup' && orderList2.length > 0">
|
||||||
|
<!-- 按供应商分组 -->
|
||||||
|
<view v-for="(group, supplierId) in supplierGroups" :key="supplierId">
|
||||||
|
<view class="goods-list">
|
||||||
|
<view class="info-section">
|
||||||
|
<view class="address-section">
|
||||||
|
<view class="section-title">自提点</view>
|
||||||
|
<view @click="editAddress(group[0])">
|
||||||
|
<view v-if="defZTAddress.length > 0">
|
||||||
|
<view v-for="(adItem, adIndex) in defZTAddress" :key="adIndex">
|
||||||
|
<view class="address-info" v-if="adItem.id == supplierId">
|
||||||
|
<view class="address-main">
|
||||||
|
<view class="address-name-phone">
|
||||||
|
<text class="name">{{ adItem.name }}</text>
|
||||||
|
<text class="phone">{{ adItem.phone }}</text>
|
||||||
|
</view>
|
||||||
|
<view class="address-detail">
|
||||||
|
{{ adItem.address }}
|
||||||
|
<view class="copy-icon" @click.stop="copyZTAddress" />
|
||||||
|
</view>
|
||||||
|
</view>
|
||||||
|
<view class="address-arrow"><u-icon name="arrow-right" size="25"></u-icon>
|
||||||
|
</view>
|
||||||
|
</view>
|
||||||
|
</view>
|
||||||
|
<view class="address-info"
|
||||||
|
v-if="!defZTAddress.some(adItem => adItem.id == supplierId)">
|
||||||
|
<view class="address-main">
|
||||||
|
<view class="address-name-phone">
|
||||||
|
<text class="name">请选择自提点</text>
|
||||||
|
</view>
|
||||||
|
</view>
|
||||||
|
<view class="address-arrow"><u-icon name="arrow-right" size="25"></u-icon>
|
||||||
|
</view>
|
||||||
|
</view>
|
||||||
|
</view>
|
||||||
|
<view class="address-info" v-else>
|
||||||
|
<view class="address-main">
|
||||||
|
<view class="address-name-phone">
|
||||||
|
<text class="name">请选择自提点</text>
|
||||||
|
</view>
|
||||||
|
</view>
|
||||||
|
<view class="address-arrow"><u-icon name="arrow-right" size="25"></u-icon></view>
|
||||||
|
</view>
|
||||||
|
</view>
|
||||||
|
</view>
|
||||||
|
</view>
|
||||||
|
</view>
|
||||||
|
<!-- 该供应商下的所有商品 -->
|
||||||
|
<view class="goods-item" v-for="(item, index) in group" :key="index">
|
||||||
|
<view class="goods-image">
|
||||||
|
<image :src="item.commodity_goods_info.commodity_pic" mode="aspectFill"></image>
|
||||||
|
</view>
|
||||||
|
<view class="goods-info">
|
||||||
|
<view class="goods-name">{{ item.commodity_goods_info.goods_name }}</view>
|
||||||
|
<view class="goods-desc">{{ item.commodity_goods_info.goods_spec }}</view>
|
||||||
|
<view class="price-container">
|
||||||
|
<view class="group-price">
|
||||||
|
<view>
|
||||||
|
<view v-if="isWithinActivityTime(item)" class="group-price-box">
|
||||||
|
<view class="group-price1">团购价</view>
|
||||||
|
<view class="group-price2">
|
||||||
|
{{ '¥' + item.commodity_goods_info.group_buy_price }}
|
||||||
|
/{{ item.commodity_goods_info.goods_unit }}
|
||||||
|
</view>
|
||||||
|
</view>
|
||||||
|
<view v-else>
|
||||||
|
{{ '¥' + item.commodity_goods_info.sales_price }}
|
||||||
|
/{{ item.commodity_goods_info.goods_unit }}
|
||||||
|
</view>
|
||||||
|
</view>
|
||||||
|
<!-- 运费 -->
|
||||||
|
<!-- <view class="goods-desc" style="margin-top: 10rpx;">运费 ¥{{
|
||||||
|
item.commodity_goods_info.freight }}</view> -->
|
||||||
|
</view>
|
||||||
|
<view class="quantity-control">
|
||||||
|
<view class="decrease-btn" @tap.stop="decreaseQuantity(item)">-</view>
|
||||||
|
<view class="quantity">{{ item.count }}</view>
|
||||||
|
<view class="increase-btn" @tap.stop="increaseQuantity(item)">+</view>
|
||||||
|
</view>
|
||||||
|
</view>
|
||||||
|
</view>
|
||||||
|
</view>
|
||||||
|
</view>
|
||||||
|
<!-- 运费 -->
|
||||||
|
<!-- <view class="fee-section">
|
||||||
|
<view class="fee-name">运费</view>
|
||||||
|
<view class="fee-value">¥{{ item.commodity_goods_info.freight }}</view>
|
||||||
|
</view> -->
|
||||||
|
<!-- 总金额 -->
|
||||||
|
<view class="total-section">
|
||||||
|
<view class="total-name">总金额</view>
|
||||||
|
<view class="total-value">¥{{ calculateTotal('order2') }}</view>
|
||||||
|
</view>
|
||||||
|
<!-- 支付方式 -->
|
||||||
|
<view class="payment-section">
|
||||||
|
<view class="payment-item" @click="selectPayment('wechat')">
|
||||||
|
<view class="payment-icon">
|
||||||
|
<image
|
||||||
|
src="https://wechat-img-file.oss-cn-beijing.aliyuncs.com/property-img-file/com_wechat.png"
|
||||||
|
mode="aspectFit"></image>
|
||||||
|
</view>
|
||||||
|
<view class="payment-content">
|
||||||
|
<view class="payment-name">微信支付</view>
|
||||||
|
<view class="payment-desc"><text
|
||||||
|
style="color: #f03d0e;margin-right: 15rpx;">可用优惠券</text>单笔支付限额:¥10000.00</view>
|
||||||
|
</view>
|
||||||
|
<view class="payment-select" v-if="selectedPayment === 'wechat'">
|
||||||
|
<image
|
||||||
|
src="https://wechat-img-file.oss-cn-beijing.aliyuncs.com/property-img-file/com_check2.png"
|
||||||
|
mode="aspectFit" style="width: 40rpx; height: 40rpx;"></image>
|
||||||
|
</view>
|
||||||
|
<view class="payment-select" v-else>
|
||||||
|
<image
|
||||||
|
src="https://wechat-img-file.oss-cn-beijing.aliyuncs.com/property-img-file/com_check1.png"
|
||||||
|
mode="aspectFit" style="width: 40rpx; height: 40rpx;"></image>
|
||||||
|
</view>
|
||||||
|
</view>
|
||||||
|
</view>
|
||||||
|
</view>
|
||||||
|
<view v-if="activeTab === 'pickup' && orderList2.length == 0" class="empty-tip">
|
||||||
暂无商品数据
|
暂无商品数据
|
||||||
</view>
|
</view>
|
||||||
<!-- 立即支付按钮 -->
|
<!-- 立即支付按钮 -->
|
||||||
@ -108,6 +234,9 @@
|
|||||||
</view>
|
</view>
|
||||||
<view class="boxshadow_img">
|
<view class="boxshadow_img">
|
||||||
<view v-if="verifyCode">核销码:{{ verifyCode }}</view>
|
<view v-if="verifyCode">核销码:{{ verifyCode }}</view>
|
||||||
|
<!-- <image
|
||||||
|
src="https://wechat-img-file.oss-cn-beijing.aliyuncs.com/property-img-file/shop_share_img.png">
|
||||||
|
</image> -->
|
||||||
</view>
|
</view>
|
||||||
<view>
|
<view>
|
||||||
<view class="wealBoxTit">
|
<view class="wealBoxTit">
|
||||||
@ -117,8 +246,7 @@
|
|||||||
<view class="wealBox">
|
<view class="wealBox">
|
||||||
<view class="wealBoxItem wealBoxItem1">
|
<view class="wealBoxItem wealBoxItem1">
|
||||||
<view class="wealBoxItemTop">
|
<view class="wealBoxItemTop">
|
||||||
<image src="https://wechat-img-file.oss-cn-beijing.aliyuncs.com/activity_fen.png"
|
<image src="https://wechat-img-file.oss-cn-beijing.aliyuncs.com/activity_fen.png" mode="aspectFit">
|
||||||
mode="aspectFit">
|
|
||||||
</image>
|
</image>
|
||||||
<view>石榴分</view>
|
<view>石榴分</view>
|
||||||
</view>
|
</view>
|
||||||
@ -131,8 +259,7 @@
|
|||||||
</view>
|
</view>
|
||||||
<view class="wealBoxItem wealBoxItem2">
|
<view class="wealBoxItem wealBoxItem2">
|
||||||
<view class="wealBoxItemTop">
|
<view class="wealBoxItemTop">
|
||||||
<image src="https://wechat-img-file.oss-cn-beijing.aliyuncs.com/activity_zi.png"
|
<image src="https://wechat-img-file.oss-cn-beijing.aliyuncs.com/activity_zi.png" mode="aspectFit">
|
||||||
mode="aspectFit">
|
|
||||||
</image>
|
</image>
|
||||||
<view>石榴籽</view>
|
<view>石榴籽</view>
|
||||||
</view>
|
</view>
|
||||||
@ -145,8 +272,7 @@
|
|||||||
</view>
|
</view>
|
||||||
<view class="wealBoxItem wealBoxItem3">
|
<view class="wealBoxItem wealBoxItem3">
|
||||||
<view class="wealBoxItemTop">
|
<view class="wealBoxItemTop">
|
||||||
<image src="https://wechat-img-file.oss-cn-beijing.aliyuncs.com/activity_jin.png"
|
<image src="https://wechat-img-file.oss-cn-beijing.aliyuncs.com/activity_jin.png" mode="aspectFit"/>
|
||||||
mode="aspectFit" />
|
|
||||||
<view>石榴金</view>
|
<view>石榴金</view>
|
||||||
</view>
|
</view>
|
||||||
<view>
|
<view>
|
||||||
@ -158,7 +284,65 @@
|
|||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
|
<view class="bottom">
|
||||||
|
<view class="boxbottom1">
|
||||||
|
<view class="boxbottom">
|
||||||
|
<view class="line1"></view>
|
||||||
|
赶快邀请好友来下单吧
|
||||||
|
<view class="line2"></view>
|
||||||
</view>
|
</view>
|
||||||
|
<view @click.stop="changeShadow">
|
||||||
|
<view class="shadowBox1">
|
||||||
|
<button class="shadowBox1Item_btn" open-type="share" bindtap="onShareButtonClick" />
|
||||||
|
<view class="shadowBox1Item">
|
||||||
|
<image
|
||||||
|
src="https://wechat-img-file.oss-cn-beijing.aliyuncs.com/property-img-file/shop_WX.png"
|
||||||
|
mode="aspectFill"></image>
|
||||||
|
微信好友
|
||||||
|
</view>
|
||||||
|
<button class="shadowBox2Item_btn" open-type="share" bindtap="onShareButtonClick" />
|
||||||
|
<view class="shadowBox1Item" @click="shareFriend">
|
||||||
|
<image
|
||||||
|
src="https://wechat-img-file.oss-cn-beijing.aliyuncs.com/property-img-file/shop_WX.png"
|
||||||
|
mode="aspectFill"></image>
|
||||||
|
小程序链接
|
||||||
|
</view>
|
||||||
|
<!-- <view class="shadowBox1Item" @click="openSave">
|
||||||
|
<image
|
||||||
|
src="https://wechat-img-file.oss-cn-beijing.aliyuncs.com/property-img-file/shop_saveImg.png"
|
||||||
|
mode="aspectFill"></image>
|
||||||
|
二维码海报
|
||||||
|
</view> -->
|
||||||
|
</view>
|
||||||
|
</view>
|
||||||
|
</view>
|
||||||
|
</view>
|
||||||
|
</view>
|
||||||
|
</view>
|
||||||
|
</view>
|
||||||
|
|
||||||
|
<!-- 海报 -->
|
||||||
|
<view class="shadow" @click="changeShadow2" v-if="boxshadow2">
|
||||||
|
<view class="shadowBox2">
|
||||||
|
<view class="shadowBox_img">
|
||||||
|
<view class="boxshadow_tit">今日商品推荐</view>
|
||||||
|
<view class="boxshadow_img">
|
||||||
|
<image
|
||||||
|
src="https://wechat-img-file.oss-cn-beijing.aliyuncs.com/property-img-file/shop_share_img.png">
|
||||||
|
</image>
|
||||||
|
</view>
|
||||||
|
<view class="shadowBoxInfo">
|
||||||
|
<view class="shadowboxInfo_left">二维码</view>
|
||||||
|
<view class="shadowboxInfo_right">
|
||||||
|
<view class="shadowboxInfo_right_1">正鲜生</view>
|
||||||
|
<view class="shadowboxInfo_right_2">
|
||||||
|
长按识别小程序 <br />
|
||||||
|
数量有限马上抢购
|
||||||
|
</view>
|
||||||
|
</view>
|
||||||
|
</view>
|
||||||
|
</view>
|
||||||
|
<view class="shadowBox_btn" @click.stop="saveImg">保存海报</view>
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
@ -170,28 +354,48 @@ import { apiArr } from "../../../api/shop";
|
|||||||
export default {
|
export default {
|
||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
activeTab: 'delivery', // 默认选中配送
|
activeTab: 'pickup', // 默认选中自提
|
||||||
quantity: 1, // 商品数量
|
quantity: 1, // 商品数量
|
||||||
selectedPayment: 'wechat',
|
selectedPayment: 'wechat',
|
||||||
boxshadow1: false,
|
boxshadow1: false,
|
||||||
boxshadow2: false,
|
boxshadow2: false,
|
||||||
defAddress: {},
|
defAddress: {},
|
||||||
orderList: [],
|
defZTAddress: [],
|
||||||
|
orderList1: [],
|
||||||
|
orderList2: [],
|
||||||
carList: [],
|
carList: [],
|
||||||
|
|
||||||
slJin: 0,
|
slJin: 0,
|
||||||
slFen: 0,
|
slFen: 0,
|
||||||
slZi: 0,
|
slZi: 0,
|
||||||
|
|
||||||
|
// 团购活动id
|
||||||
|
group_buy_activity_id: 0,
|
||||||
|
|
||||||
// 核销码
|
// 核销码
|
||||||
verifyCode: '',
|
verifyCode: '',
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
|
computed: {
|
||||||
|
// 按供应商id分组商品
|
||||||
|
supplierGroups() {
|
||||||
|
const groups = {};
|
||||||
|
this.orderList2.forEach(item => {
|
||||||
|
const supplierId = item.supplier_id || 'default';
|
||||||
|
if (!groups[supplierId]) {
|
||||||
|
groups[supplierId] = [];
|
||||||
|
}
|
||||||
|
groups[supplierId].push(item);
|
||||||
|
});
|
||||||
|
return groups;
|
||||||
|
},
|
||||||
|
},
|
||||||
onLoad(options) {
|
onLoad(options) {
|
||||||
this.carList = JSON.parse(options.shopCarList)
|
this.carList = JSON.parse(options.shopCarList)
|
||||||
},
|
},
|
||||||
onShow() {
|
onShow() {
|
||||||
this.getUserAddress()
|
this.getUserAddress()
|
||||||
|
this.getZTAddress()
|
||||||
this.getGoodsList()
|
this.getGoodsList()
|
||||||
},
|
},
|
||||||
onUnload() {
|
onUnload() {
|
||||||
@ -209,22 +413,56 @@ export default {
|
|||||||
},
|
},
|
||||||
// 商品列表
|
// 商品列表
|
||||||
getGoodsList() {
|
getGoodsList() {
|
||||||
this.orderList = []
|
this.orderList1 = []
|
||||||
|
this.orderList2 = []
|
||||||
|
|
||||||
this.carList.forEach(item => {
|
this.carList.forEach(item => {
|
||||||
// 如果图片URL不是以https开头,则拼接picUrl
|
// 如果图片URL不是以https开头,则拼接picUrl
|
||||||
if (item.commodity_goods_info.commodity_pic && item.commodity_goods_info.commodity_pic.indexOf('https') !== 0) {
|
if (item.commodity_goods_info.commodity_pic && item.commodity_goods_info.commodity_pic.indexOf('https') !== 0) {
|
||||||
item.commodity_goods_info.commodity_pic = picUrl + item.commodity_goods_info.commodity_pic
|
item.commodity_goods_info.commodity_pic = picUrl + item.commodity_goods_info.commodity_pic
|
||||||
}
|
}
|
||||||
this.orderList.push(item)
|
|
||||||
|
// const list = item.commodity_goods_info.group_buy_activity_info
|
||||||
|
const list = true
|
||||||
|
if (list) {
|
||||||
|
this.orderList2.push(item)
|
||||||
|
} else {
|
||||||
|
this.orderList1.push(item)
|
||||||
|
}
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
|
getZTAddress() {
|
||||||
|
setTimeout(() => {
|
||||||
|
let changeAddress = uni.getStorageSync('changeZTAddress')
|
||||||
|
if (changeAddress) {
|
||||||
|
this.defZTAddress = changeAddress
|
||||||
|
}
|
||||||
|
}, 100)
|
||||||
|
},
|
||||||
chooseAddress() {
|
chooseAddress() {
|
||||||
NavgateTo('/packages/shop/address/index')
|
NavgateTo('../address/index')
|
||||||
|
},
|
||||||
|
editAddress(item) {
|
||||||
|
NavgateTo('/packages/shop/ztLocation/index?item=' + JSON.stringify(item));
|
||||||
},
|
},
|
||||||
decreaseQuantity(item) {
|
decreaseQuantity(item) {
|
||||||
|
const currentTime = new Date().getTime();
|
||||||
|
const startTime = new Date(item.commodity_goods_info.group_buy_activity_info?.start_time).getTime();
|
||||||
|
const endTime = new Date(item.commodity_goods_info.group_buy_activity_info?.end_time).getTime();
|
||||||
if (item.count > 0) {
|
if (item.count > 0) {
|
||||||
|
if (currentTime >= startTime && currentTime <= endTime) {
|
||||||
|
if (item.count == item.commodity_goods_info.min_order_quantity) {
|
||||||
|
uni.showToast({
|
||||||
|
title: '最少购买' + item.commodity_goods_info.min_order_quantity + '件',
|
||||||
|
icon: 'none'
|
||||||
|
});
|
||||||
|
item.count = 0
|
||||||
|
} else {
|
||||||
item.count--
|
item.count--
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
item.count--
|
||||||
|
}
|
||||||
|
|
||||||
// 当数量减到0时,从carList中删除该商品
|
// 当数量减到0时,从carList中删除该商品
|
||||||
if (item.count === 0) {
|
if (item.count === 0) {
|
||||||
@ -240,6 +478,10 @@ export default {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
increaseQuantity(item) {
|
increaseQuantity(item) {
|
||||||
|
const currentTime = new Date().getTime();
|
||||||
|
const startTime = new Date(item.commodity_goods_info.group_buy_activity_info?.start_time).getTime();
|
||||||
|
const endTime = new Date(item.commodity_goods_info.group_buy_activity_info?.end_time).getTime();
|
||||||
|
|
||||||
if (item.count >= item.commodity_goods_info.stock_quantity) {
|
if (item.count >= item.commodity_goods_info.stock_quantity) {
|
||||||
uni.showToast({
|
uni.showToast({
|
||||||
title: '库存不足',
|
title: '库存不足',
|
||||||
@ -247,6 +489,27 @@ export default {
|
|||||||
});
|
});
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (currentTime >= startTime && currentTime <= endTime) {
|
||||||
|
if (item.count == 0) {
|
||||||
|
item.count += item.commodity_goods_info.min_order_quantity
|
||||||
|
} else {
|
||||||
|
if (item.count >= item.commodity_goods_info.stock_quantity) {
|
||||||
|
uni.showToast({
|
||||||
|
title: '库存不足',
|
||||||
|
icon: 'none'
|
||||||
|
});
|
||||||
|
return
|
||||||
|
}
|
||||||
|
if (item.count == item.commodity_goods_info.max_limit_quantity) {
|
||||||
|
uni.showToast({
|
||||||
|
title: '一次最多购买' + item.commodity_goods_info.max_limit_quantity + '件',
|
||||||
|
icon: 'none'
|
||||||
|
});
|
||||||
|
return
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
item.count++;
|
item.count++;
|
||||||
this.changeCart(item);
|
this.changeCart(item);
|
||||||
},
|
},
|
||||||
@ -269,26 +532,89 @@ export default {
|
|||||||
},
|
},
|
||||||
|
|
||||||
// 计算总金额
|
// 计算总金额
|
||||||
calculateTotal() {
|
calculateTotal(order) {
|
||||||
|
const currentTime = new Date().getTime();
|
||||||
|
if (order === 'order1') {
|
||||||
let total = 0;
|
let total = 0;
|
||||||
this.orderList.forEach(goods => {
|
this.orderList1.forEach(goods => {
|
||||||
total += goods.commodity_goods_info.sales_price * goods.count + goods.commodity_goods_info.freight;
|
// 团购活动时间判断
|
||||||
|
const startTime = new Date(goods.commodity_goods_info.group_buy_activity_info?.start_time).getTime();
|
||||||
|
const endTime = new Date(goods.commodity_goods_info.group_buy_activity_info?.end_time).getTime();
|
||||||
|
if (currentTime >= startTime && currentTime <= endTime) {
|
||||||
|
// total += goods.commodity_goods_info.group_buy_price * goods.count + goods.commodity_goods_info.freight;
|
||||||
|
total += goods.commodity_goods_info.group_buy_price * goods.count;
|
||||||
|
} else {
|
||||||
|
// total += goods.commodity_goods_info.sales_price * goods.count + goods.commodity_goods_info.freight;
|
||||||
|
total += goods.commodity_goods_info.sales_price * goods.count;
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
// 加运费
|
||||||
return total.toFixed(2);
|
return total.toFixed(2);
|
||||||
|
} else {
|
||||||
|
let total = 0;
|
||||||
|
this.orderList2.forEach(goods => {
|
||||||
|
// 团购活动时间判断
|
||||||
|
const startTime = new Date(goods.commodity_goods_info.group_buy_activity_info?.start_time).getTime();
|
||||||
|
const endTime = new Date(goods.commodity_goods_info.group_buy_activity_info?.end_time).getTime();
|
||||||
|
if (currentTime >= startTime && currentTime <= endTime) {
|
||||||
|
// total += goods.commodity_goods_info.group_buy_price * goods.count + goods.commodity_goods_info.freight;
|
||||||
|
total += goods.commodity_goods_info.group_buy_price * goods.count;
|
||||||
|
} else {
|
||||||
|
// total += goods.commodity_goods_info.sales_price * goods.count + goods.commodity_goods_info.freight;
|
||||||
|
total += goods.commodity_goods_info.sales_price * goods.count;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
// 加运费
|
||||||
|
return total.toFixed(2);
|
||||||
|
}
|
||||||
},
|
},
|
||||||
selectPayment(payment) {
|
selectPayment(payment) {
|
||||||
this.selectedPayment = payment;
|
this.selectedPayment = payment;
|
||||||
},
|
},
|
||||||
submitPayment() {
|
submitPayment() {
|
||||||
// 检查是否有收货地址
|
// 检查所有供应商是否都选择了自提点
|
||||||
if (!this.defAddress || Object.keys(this.defAddress).length === 0) {
|
const supplierIds = [...new Set(this.orderList2.map(item =>
|
||||||
|
item.supplier_id || 'default'
|
||||||
|
))];
|
||||||
|
|
||||||
|
const allHaveZTAddress = supplierIds.every(supplierId => {
|
||||||
|
const ztAddress = this.defZTAddress.find(adItem => adItem.id == supplierId);
|
||||||
|
return !!ztAddress;
|
||||||
|
});
|
||||||
|
|
||||||
|
if (!allHaveZTAddress) {
|
||||||
uni.showToast({
|
uni.showToast({
|
||||||
title: '请选择收货地址',
|
title: '请选择所有货品的自提点',
|
||||||
icon: 'none'
|
icon: 'none'
|
||||||
});
|
});
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 团购活动时间判断
|
||||||
|
const currentTime = new Date().getTime();
|
||||||
|
let isGroupBuyValid = true;
|
||||||
|
|
||||||
|
// 检查所有商品是否在团购活动时间内
|
||||||
|
for (let supplierId in this.supplierGroups) {
|
||||||
|
const group = this.supplierGroups[supplierId];
|
||||||
|
for (let item of group) {
|
||||||
|
const activityInfo = item.commodity_goods_info.group_buy_activity_info;
|
||||||
|
// 如果没有团购活动信息,或者不在活动时间内,则isGroupBuyValid设为false
|
||||||
|
if (!activityInfo) {
|
||||||
|
isGroupBuyValid = false;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
const startTime = new Date(activityInfo.start_time).getTime();
|
||||||
|
const endTime = new Date(activityInfo.end_time).getTime();
|
||||||
|
if (!(currentTime >= startTime && currentTime <= endTime)) {
|
||||||
|
isGroupBuyValid = false;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (!isGroupBuyValid) break;
|
||||||
|
}
|
||||||
|
|
||||||
// 检查是否存在isafterSale属性且值为true
|
// 检查是否存在isafterSale属性且值为true
|
||||||
const hasAfterSaleItem = this.carList.some(item => item.isafterSale === true);
|
const hasAfterSaleItem = this.carList.some(item => item.isafterSale === true);
|
||||||
const orderIdFromAfterSale = hasAfterSaleItem ? this.carList.find(item => item.isafterSale === true)?.orderId : null;
|
const orderIdFromAfterSale = hasAfterSaleItem ? this.carList.find(item => item.isafterSale === true)?.orderId : null;
|
||||||
@ -327,22 +653,40 @@ export default {
|
|||||||
const params = {
|
const params = {
|
||||||
user_id: uni.getStorageSync('userId'),
|
user_id: uni.getStorageSync('userId'),
|
||||||
// 先判断shopCarList数据中是否包含isAdver且为true
|
// 先判断shopCarList数据中是否包含isAdver且为true
|
||||||
order_cate: this.carList.some(item => item.isAdver === true) ? 3 : 1,
|
order_cate : this.carList.some(item => item.isAdver === true) ? 3 : (isGroupBuyValid ? 2 : 1),
|
||||||
goods_list: [{
|
goods_list: Object.keys(this.supplierGroups).map(supplierId => {
|
||||||
supplier_id: this.orderList[0].supplier_id,
|
const group = this.supplierGroups[supplierId];
|
||||||
supplier_name: this.orderList[0].supplier_name || '',
|
const firstItem = group[0];
|
||||||
is_same_day: this.orderList[0].commodity_goods_info.is_same_day,
|
|
||||||
receiving_name: this.defAddress.name,
|
// 团购活动id
|
||||||
receiving_phone: this.defAddress.phone,
|
this.group_buy_activity_id = firstItem.commodity_goods_info.group_buy_activity_id;
|
||||||
receiving_address: this.defAddress.address + this.defAddress.house_number,
|
|
||||||
merchant_id: this.defAddress.address_id,
|
// 根据供应商id获取自提点信息
|
||||||
goods_and_count: this.orderList.map(item => ({
|
const ztAddress = this.defZTAddress.find(adItem => adItem.id == supplierId) || {};
|
||||||
|
|
||||||
|
return {
|
||||||
|
supplier_id: firstItem.supplier_id,
|
||||||
|
supplier_name: firstItem.supplier_name || '',
|
||||||
|
is_same_day: firstItem.commodity_goods_info.is_same_day,
|
||||||
|
receiving_name: ztAddress.name || '',
|
||||||
|
receiving_phone: ztAddress.phone || '',
|
||||||
|
receiving_address: ztAddress.address || '',
|
||||||
|
merchant_id: ztAddress.address_id,
|
||||||
|
group_buy_activity_id: firstItem.commodity_goods_info.group_buy_activity_id,
|
||||||
|
goods_and_count: group.map(item => {
|
||||||
|
const activityInfo = item.commodity_goods_info.group_buy_activity_info;
|
||||||
|
const isGroupBuy = activityInfo &&
|
||||||
|
currentTime >= new Date(activityInfo.start_time).getTime() &&
|
||||||
|
currentTime <= new Date(activityInfo.end_time).getTime();
|
||||||
|
return {
|
||||||
goods_id: item.goods_id,
|
goods_id: item.goods_id,
|
||||||
count: item.count,
|
count: item.count,
|
||||||
price: item.commodity_goods_info.sales_price,
|
price: isGroupBuy ? item.commodity_goods_info.group_buy_price : item.commodity_goods_info.sales_price,
|
||||||
freight: item.commodity_goods_info.freight,
|
freight: item.commodity_goods_info.freight,
|
||||||
}))
|
}
|
||||||
}]
|
})
|
||||||
|
}
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
request(apiArr.createOrder, "POST", params).then(resVal => {
|
request(apiArr.createOrder, "POST", params).then(resVal => {
|
||||||
@ -371,7 +715,8 @@ export default {
|
|||||||
success: (payRes) => {
|
success: (payRes) => {
|
||||||
const params = {
|
const params = {
|
||||||
order_id: orderId,
|
order_id: orderId,
|
||||||
from: this.carList.some(item => item.isAdver === true) ? 3 : 1,
|
from: this.carList.some(item => item.isAdver === true) ? 3 : (isGroupBuyValid ? 2 : 1),
|
||||||
|
group_buy_activity_id: this.group_buy_activity_id,
|
||||||
adver_id: this.carList.some(item => item.isAdver === true) ? this.carList.find(item => item.isAdver === true).adver_id : ''
|
adver_id: this.carList.some(item => item.isAdver === true) ? this.carList.find(item => item.isAdver === true).adver_id : ''
|
||||||
}
|
}
|
||||||
request(apiArr.queryOrder, "POST", params).then(res => {
|
request(apiArr.queryOrder, "POST", params).then(res => {
|
||||||
@ -422,6 +767,24 @@ export default {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
copyZTAddress() {
|
||||||
|
// 使用uni-app的复制API
|
||||||
|
uni.setClipboardData({
|
||||||
|
data: this.defZTAddress.address,
|
||||||
|
success: () => {
|
||||||
|
uni.showToast({
|
||||||
|
title: '复制成功',
|
||||||
|
icon: 'success'
|
||||||
|
});
|
||||||
|
},
|
||||||
|
fail: () => {
|
||||||
|
uni.showToast({
|
||||||
|
title: '复制失败',
|
||||||
|
icon: 'none'
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
},
|
||||||
openSave() {
|
openSave() {
|
||||||
this.boxshadow1 = false;
|
this.boxshadow1 = false;
|
||||||
this.boxshadow2 = true;
|
this.boxshadow2 = true;
|
||||||
@ -460,6 +823,16 @@ export default {
|
|||||||
},
|
},
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
// 判断当前日期是否在团购活动时间范围内
|
||||||
|
isWithinActivityTime(item) {
|
||||||
|
if (!item || !item.commodity_goods_info || !item.commodity_goods_info.group_buy_activity_info) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
const now = new Date();
|
||||||
|
const startTime = new Date(item.commodity_goods_info.group_buy_activity_info?.start_time);
|
||||||
|
const endTime = new Date(item.commodity_goods_info.group_buy_activity_info?.end_time);
|
||||||
|
return now >= startTime && now <= endTime;
|
||||||
|
},
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
</script>
|
</script>
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user