<template>
|
<view class="orderGoods borRadius14">
|
<view class='total'>共<text>{{ (orderProNum ? orderProNum : totalNmu) + getGiftCount() }}</text>件商品</view>
|
<view class='goodWrapper'>
|
<view v-for="(zoneGroup, zoneIndex) in getGroupedCartInfo()" :key="zoneIndex">
|
<view class="list_name"><text>{{ getZoneName(zoneGroup.zoneId) }}</text>
|
<text class="promotion-tip">{{
|
getZonePromotion(zoneGroup.zoneId) ? getZonePromotion(zoneGroup.zoneId).ruleName : '' }}</text>
|
</view>
|
<view class='pad30 item acea-row row-between-wrapper' v-for="(item, index) in zoneGroup.items"
|
:key="index" @click="jumpCon(item)">
|
<view class='pictrue'>
|
<image :src='item.image'></image>
|
<view v-if="item.isGift" class="gift-tag">赠品</view>
|
</view>
|
<view class='text'>
|
<view class='acea-row row-between-wrapper'>
|
<view class='name line1'>{{ item.productName ? item.productName : item.storeName }}</view>
|
<view class='num'>x {{ item.payNum ? item.payNum : item.cartNum }}</view>
|
</view>
|
<view class='attr line1' v-if="item.sku">{{ item.sku }}</view>
|
<view class='money'>
|
<text class="color-blue" v-if="item.payWay !== 3 && item.payPrice > 0">¥{{
|
toNumber(item.payPrice) }}</text>
|
<text class="color-blue"
|
v-if="item.payPrice > 0 && item.payCareBean > 0 && payWay !== 3">+</text>
|
<text class="color-blue" v-if="item.payCareBean > 0">{{
|
toThousands(toNumber(item.payCareBean)) }}悦养豆</text>
|
</view>
|
</view>
|
</view>
|
<view v-if="getZonePromotion(zoneGroup.zoneId) && getZoneCouponGifts(zoneGroup.zoneId).length > 0"
|
class="pad30 gift-list">
|
<view v-for="(gift, giftIndex) in getZoneCouponGifts(zoneGroup.zoneId)" :key="giftIndex"
|
class='item acea-row row-between-wrapper' :class="{ 'gift-item': true }">
|
<view class='picTxt acea-row row-between-wrapper' style="flex-wrap: nowrap;">
|
<view class='pictrue'>
|
<image :src='getGiftImage(gift)'></image>
|
<view class="gift-tag">赠品</view>
|
</view>
|
<view class='text' style="margin-left: 20rpx;">
|
<view class='line1'>{{ gift.giftName }}</view>
|
<view class='infor'>x{{ gift.giftNum }}</view>
|
</view>
|
</view>
|
</view>
|
</view>
|
<view v-if="getZonePromotion(zoneGroup.zoneId) && getZonePromotion(zoneGroup.zoneId).promotionFee > 0"
|
class="promotion-discount">
|
<text class="discount-label">专区活动立减</text>
|
<text class="discount-amount">-¥{{ getZonePromotion(zoneGroup.zoneId).promotionFee }}</text>
|
</view>
|
</view>
|
</view>
|
</view>
|
|
</template>
|
|
<script>
|
import {
|
getZoneDetail,
|
getProductDetail
|
} from '@/api/store.js';
|
|
export default {
|
props: {
|
payWay: {
|
type: Number,
|
default: 1,
|
},
|
evaluate: {
|
type: Number,
|
default: 0,
|
},
|
cartInfo: {
|
type: Array,
|
default: function () {
|
return [];
|
}
|
},
|
orderId: {
|
type: String,
|
default: '',
|
},
|
ids: {
|
type: Number,
|
default: 0,
|
},
|
jump: {
|
type: Boolean,
|
default: false,
|
},
|
orderProNum: {
|
type: Number,
|
default: function () {
|
return 0;
|
}
|
},
|
productType: {
|
type: Number,
|
default: function () {
|
return 0;
|
}
|
},
|
zonePromotionList: {
|
type: Array,
|
default: function () {
|
return [];
|
}
|
}
|
},
|
data() {
|
return {
|
totalNmu: '',
|
giftCache: {},
|
zoneCache: {}
|
};
|
},
|
watch: {
|
cartInfo: function (nVal, oVal) {
|
let num = 0
|
nVal.forEach((item, index) => {
|
num += item.cartNum
|
})
|
this.totalNmu = num
|
}
|
},
|
methods: {
|
getGroupedCartInfo() {
|
const groups = {};
|
if (!this.cartInfo || !Array.isArray(this.cartInfo)) return [];
|
this.cartInfo.forEach(item => {
|
const zoneId = item.zoneId || item.storeZoneId || 'default';
|
const zoneName = item.zoneName || '中粮好物';
|
if (!groups[zoneId]) {
|
groups[zoneId] = {
|
zoneId: zoneId,
|
zoneName: zoneName,
|
items: []
|
};
|
}
|
groups[zoneId].items.push(item);
|
});
|
return Object.values(groups);
|
},
|
getGiftCount() {
|
let count = 0;
|
if (!this.zonePromotionList || !Array.isArray(this.zonePromotionList)) return 0;
|
this.zonePromotionList.forEach(promotion => {
|
if (promotion.giftList) {
|
promotion.giftList.forEach(gift => {
|
count += gift.giftNum || 0;
|
});
|
}
|
});
|
return count;
|
},
|
evaluateTap(item) {
|
uni.navigateTo({
|
url: "/pages/users/goods_comment_con/index?unique=" + item.attrId + "&orderId=" + this.orderId + '&id=' + this.ids
|
})
|
},
|
jumpCon: function (item) {
|
let type = this.productType == 0 ? 'normal' : 'video'
|
if (this.jump) {
|
uni.navigateTo({
|
url: `/pages/goods_details/index?id=${item.productId}&type=${type}` + (item.storeZoneId ? ('&zoneId=' + item.storeZoneId) : '')
|
})
|
}
|
},
|
getZonePromotion(zoneId) {
|
if (!zoneId || zoneId === 'default') return null;
|
console.log('-------------------getZonePromotion', this.zonePromotionList.find(p => p.zoneId === zoneId));
|
return this.zonePromotionList.find(p => p.zoneId === zoneId);
|
},
|
getZoneCouponGifts(zoneId) {
|
const promotion = this.getZonePromotion(zoneId);
|
if (!promotion || !promotion.giftList) return [];
|
return promotion.giftList.filter(gift => gift.giftType === 2);
|
},
|
getAllCouponGifts() {
|
const gifts = [];
|
if (!this.zonePromotionList || !Array.isArray(this.zonePromotionList)) return gifts;
|
this.zonePromotionList.forEach(promotion => {
|
if (promotion.giftList && Array.isArray(promotion.giftList)) {
|
promotion.giftList.forEach(gift => {
|
if (gift.giftType === 2) {
|
gifts.push(gift);
|
}
|
});
|
}
|
});
|
return gifts;
|
},
|
hasGiftRule(zoneId) {
|
const promotion = this.getZonePromotion(zoneId);
|
if (!promotion || !promotion.ruleList) return false;
|
return promotion.ruleList.some(rule => rule.ruleType === 3);
|
},
|
getGiftImage(gift) {
|
if (gift.giftType === 1) {
|
// 优先返回已缓存的图片
|
if (gift._productImage) {
|
return gift._productImage;
|
}
|
// 如果有缓存数据
|
if (this.giftCache[gift.giftRefId]) {
|
return this.giftCache[gift.giftRefId].image || '';
|
}
|
// 异步加载商品图片
|
if (!gift._loading) {
|
gift._loading = true;
|
getProductDetail(gift.giftRefId).then(res => {
|
if (res.code === 200 && res.data && res.data.productInfo) {
|
const image = res.data.productInfo.image || '';
|
this.$set(gift, '_productImage', image);
|
this.$set(this.giftCache, gift.giftRefId, res.data.productInfo);
|
}
|
gift._loading = false;
|
}).catch(() => {
|
gift._loading = false;
|
});
|
}
|
return '';
|
}
|
return 'https://ossacmall.bluedeer.com.cn/app/static/images/coupon.png';
|
},
|
getZoneName(zoneId) {
|
if (!zoneId || zoneId === 'default') {
|
return '中粮好物';
|
}
|
if (this.zoneCache[zoneId]) {
|
return this.zoneCache[zoneId].name || '中粮好物';
|
}
|
const zoneGroup = this.getGroupedCartInfo().find(g => g.zoneId === zoneId);
|
if (zoneGroup && zoneGroup.zoneName) {
|
getZoneDetail(zoneId).then(res => {
|
if (res.code === 200 && res.data) {
|
this.$set(this.zoneCache, zoneId, res.data);
|
}
|
});
|
return zoneGroup.zoneName;
|
}
|
getZoneDetail(zoneId).then(res => {
|
if (res.code === 200 && res.data) {
|
this.$set(this.zoneCache, zoneId, res.data);
|
}
|
});
|
return '中粮好物';
|
}
|
}
|
}
|
</script>
|
|
<style scoped lang="scss">
|
.orderGoods {
|
background-color: #fff;
|
margin-top: 15rpx;
|
}
|
|
.orderGoods .total {
|
width: 100%;
|
height: 86rpx;
|
padding: 0 24rpx;
|
font-size: 30rpx;
|
color: #282828;
|
line-height: 86rpx;
|
box-sizing: border-box;
|
|
text {
|
color: #FF780D;
|
}
|
|
.gift-count {
|
color: #999999;
|
font-size: 26rpx;
|
|
.gift-num {
|
color: #FF6600;
|
font-weight: bold;
|
}
|
}
|
}
|
|
.goodWrapper .item .text>.acea-row {
|
flex-wrap: nowrap;
|
}
|
|
.goodWrapper .item .text .num {
|
white-space: nowrap;
|
}
|
|
.pictrue {
|
position: relative;
|
|
.gift-tag {
|
position: absolute;
|
top: 0;
|
left: 0;
|
padding: 4rpx 8rpx;
|
background: #FF6600;
|
color: #FFFFFF;
|
font-size: 20rpx;
|
border-radius: 8rpx 0 8rpx 0;
|
}
|
}
|
|
.pictrue image {
|
background: #f4f4f4;
|
}
|
|
.orderGoods .list_name {
|
height: 92rpx;
|
line-height: 92rpx;
|
padding: 0 24rpx;
|
background: url(https://ossacmall.bluedeer.com.cn/app/static/images/addCart_listTitle.jpg) center center/cover no-repeat;
|
font-size: 28rpx;
|
color: #000000;
|
font-weight: bold;
|
display: flex;
|
align-items: center;
|
border-radius: 15rpx 15rpx 0 0;
|
|
.promotion-tip {
|
margin-left: 32rpx;
|
font-size: 24rpx;
|
color: #FF6600;
|
font-weight: normal;
|
}
|
}
|
|
.orderGoods .gift-list {
|
.gift-item {
|
padding: 20rpx 0;
|
border-bottom: 1rpx solid #f5f5f5;
|
|
&:last-child {
|
border-bottom: none;
|
}
|
|
.pictrue {
|
position: relative;
|
|
.gift-tag {
|
position: absolute;
|
top: 0;
|
left: 0;
|
padding: 4rpx 8rpx;
|
background: #FF6600;
|
color: #FFFFFF;
|
font-size: 20rpx;
|
border-radius: 8rpx 0 8rpx 0;
|
}
|
}
|
}
|
}
|
|
.orderGoods .promotion-discount {
|
display: flex;
|
justify-content: space-between;
|
align-items: center;
|
padding: 16rpx 24rpx;
|
background-color: #fff;
|
|
.discount-label {
|
font-size: 26rpx;
|
color: #999999;
|
}
|
|
.discount-amount {
|
font-size: 28rpx;
|
color: #FF4D4F;
|
font-weight: bold;
|
}
|
}
|
</style>
|