feat:优化需求
This commit is contained in:
@@ -25,16 +25,15 @@
|
||||
</view>
|
||||
</view>
|
||||
<!-- 限时秒杀标签 -->
|
||||
<view class="tab-list-container">
|
||||
<!-- <view class="tab-list-container">
|
||||
<view class="tab-list" @click="onTab(index)" v-for="(item, index) in tabList" :key="index">
|
||||
<text class="text-28 text-space" :style="{
|
||||
color: curTab == index ? '#7A35F6' : '#666'
|
||||
}">
|
||||
{{ item.name }}
|
||||
</text>
|
||||
<!-- <view class="line" v-if="curTab == index"></view> -->
|
||||
</view>
|
||||
</view>
|
||||
</view> -->
|
||||
</view>
|
||||
|
||||
<view class="setting-view">
|
||||
@@ -126,7 +125,7 @@ export default {
|
||||
},
|
||||
// 获取秒杀
|
||||
onGetSeckillCurrent(type = 'current') {
|
||||
const url = type === 'current' ? getSeckillCurrent : getSeckillPreview;
|
||||
const url = type === 'current' ? getSeckillCurrent : getSeckillPreview;
|
||||
url()
|
||||
.then((res) => {
|
||||
if (res.bizcode === 100) {
|
||||
|
||||
@@ -17,14 +17,14 @@
|
||||
|
||||
</view>
|
||||
|
||||
<view class="tab-view">
|
||||
<!-- <view class="tab-view">
|
||||
<view class="tab-list" @click="onTab(index)" v-for="(item, index) in tabList" :key="index">
|
||||
<text class="text-28 text-space" :style="{
|
||||
color: curTab == index ? '#7A35F6' : '#666',
|
||||
}">{{ item.name }}</text>
|
||||
<view class="line" v-if="curTab == index"></view>
|
||||
</view>
|
||||
</view>
|
||||
</view> -->
|
||||
|
||||
<view class="setting-view">
|
||||
<view class="name-box">
|
||||
|
||||
@@ -153,7 +153,7 @@
|
||||
@click="onZiXun"></up-image>
|
||||
<view>咨询</view>
|
||||
</view>
|
||||
<view class="left_item" >
|
||||
<view class="left_item">
|
||||
<up-image src="/static/product/cart.png" width="24" height="20" bgColor="#f1f6ff00"
|
||||
@click="jumpOther('cart')"></up-image>
|
||||
<view>购物车</view>
|
||||
@@ -165,8 +165,7 @@
|
||||
</view>
|
||||
<!-- 限时秒杀现在要改为展示购物车icon 并且立即购买按钮变长一点 -->
|
||||
<view class="but_comm buy_warp" :class="{ 'border-16': isShowCart || isCoupon }"
|
||||
:style="isCoupon ? 'width: 400rpx' : ''"
|
||||
@click="checkSpecification(true, 'buy')">
|
||||
:style="isCoupon ? 'width: 400rpx' : ''" @click="checkSpecification(true, 'buy')">
|
||||
立即购买
|
||||
</view>
|
||||
</view>
|
||||
@@ -191,7 +190,8 @@
|
||||
</view>
|
||||
<!-- 商品 -->
|
||||
<view class="specification_product_warp">
|
||||
<up-image :src="orderInfo.mainGraph" width="100" height="100" bgColor="#f1f6ff00"></up-image>
|
||||
|
||||
<up-image :src="skuBySpecInfo.skuImage" width="100" height="100" bgColor="#f1f6ff00"></up-image>
|
||||
<view class="product_content">
|
||||
<view class="price_warp">
|
||||
<!-- 优惠券价格 -->
|
||||
@@ -211,21 +211,30 @@
|
||||
{{ selectSpecificationTempl.price }}
|
||||
</text>
|
||||
<view style="font-size: 50rpx" v-else>
|
||||
{{ orderInfo.minPrice }}
|
||||
<text v-if="orderInfo.maxPrice">- {{ orderInfo.maxPrice }}</text>
|
||||
{{ skuBySpecInfo.supplyPrice }}
|
||||
<text v-if="skuBySpecInfo.price">- {{ skuBySpecInfo.price }}</text>
|
||||
</view>
|
||||
<view class="price_content_coupon_warp" v-if="orderInfo.couponPrice && orderInfo.couponPrice !== 0">
|
||||
优惠券{{
|
||||
orderInfo.couponPrice }}</view>
|
||||
</view>
|
||||
<view class="oOrice_content_warp" v-if="!isCoupon">¥{{ orderInfo.adPrice }}</view>
|
||||
<view class="coupon_content_warp" v-if="orderInfo.couponPrice && orderInfo.couponPrice !== 0">优惠卷已优惠¥{{
|
||||
orderInfo.couponPrice }}</view>
|
||||
<view class="oOrice_content_warp" v-if="!isCoupon">¥{{ skuBySpecInfo.supplyPrice }}</view>
|
||||
<view class="coupon_content_warp" v-if="orderInfo.couponPrice && orderInfo.couponPrice !== 0">
|
||||
优惠券已优惠¥{{
|
||||
orderInfo.couponPrice }}</view>
|
||||
<view class="coupon_content_stock">
|
||||
<view>库存</view>
|
||||
<view>{{ skuBySpecInfo.stock || 0 }}件</view>
|
||||
</view>
|
||||
|
||||
</view>
|
||||
<view class="inventory_warp">
|
||||
<view>库存</view>
|
||||
<view>{{ orderInfo.inventory || 0 }}件</view>
|
||||
<!-- <view>库存</view>
|
||||
<view>{{ skuBySpecInfo.stock || 0 }}件</view> -->
|
||||
<view>已选规格: {{ skuBySpecInfo.skuName }}</view>
|
||||
</view>
|
||||
|
||||
|
||||
</view>
|
||||
</view>
|
||||
|
||||
@@ -422,6 +431,7 @@ export default {
|
||||
curAmount: 0, // 当前人剩余优惠券金额
|
||||
activedType: "", // 活动类型
|
||||
activityId: "", // 秒杀活动ID
|
||||
skuBySpecInfo: {},
|
||||
};
|
||||
},
|
||||
onBackPress(options) {
|
||||
@@ -885,6 +895,8 @@ export default {
|
||||
if (this.activedType === 'seckill') {
|
||||
data.minPrice = data.activity?.activityPrice;
|
||||
}
|
||||
|
||||
console.log("查询详细内容---", data)
|
||||
this.orderInfo = data;
|
||||
}
|
||||
},
|
||||
@@ -1033,6 +1045,13 @@ export default {
|
||||
})),
|
||||
}));
|
||||
this.refreshSpecOptionState();
|
||||
// 默认选中每组规格的第一个可用选项(若均无可用则选中第一个选项)
|
||||
this.specificationList.forEach((group, groupIndex) => {
|
||||
const defaultItem = group.items.find((item) => !item.disabled) || group.items[0];
|
||||
if (defaultItem) {
|
||||
this.clickSpecification(groupIndex, group, defaultItem);
|
||||
}
|
||||
});
|
||||
return true;
|
||||
},
|
||||
|
||||
@@ -1100,6 +1119,12 @@ export default {
|
||||
this.specificationList[groupIndex].selectVal = oItem.n;
|
||||
this.refreshSpecOptionState();
|
||||
|
||||
const skuBySpecBash = this.getSkuBySpecValueIds(this.selectedSpecValueIds) || {};
|
||||
console.log("----111", skuBySpecBash)
|
||||
|
||||
this.skuBySpecInfo = { ...this.orderInfo, skuImage: skuBySpecBash.skuImage, stock: skuBySpecBash.stock, supplyPrice: skuBySpecBash.supplyPrice, price: skuBySpecBash.price, skuName: skuBySpecBash.skuName }
|
||||
console.log("----222", this.orderInfo)
|
||||
|
||||
if (this.selectedSpecValueIds.every((id) => id != null)) {
|
||||
const currentSelectSpecification = this.skuBySpecKey[this.selectedSpecValueIds.join("_")] || {};
|
||||
this.selectSpecificationTempl = currentSelectSpecification;
|
||||
@@ -1109,6 +1134,20 @@ export default {
|
||||
this.selectSpecificationTempl = {};
|
||||
}
|
||||
},
|
||||
// 根据规格 ID 数组(如 [颜色id, 尺码id] -> [146913, 146916])获取单条 SKU 对象
|
||||
getSkuBySpecValueIds(specValueIds) {
|
||||
if (!specValueIds || !specValueIds.length) return null;
|
||||
// 方式一:直接通过预先拼接的 key ("146913_146916") 获取 (O(1))
|
||||
const key = specValueIds.join("_");
|
||||
if (this.skuBySpecKey && this.skuBySpecKey[key]) {
|
||||
return this.skuBySpecKey[key];
|
||||
}
|
||||
// 方式二:在 specificationTempl (skus) 数组中按 specValueIds 检索匹配
|
||||
return (this.specificationTempl || []).find((sku) => {
|
||||
const ids = sku.valueIds || JSON.parse(sku.specValueIds || "[]");
|
||||
return specValueIds.every((id) => ids.map(Number).includes(Number(id)));
|
||||
}) || null;
|
||||
},
|
||||
// 选择规格
|
||||
selectSpecificationFun(index, item) {
|
||||
console.log("selectSpecificationTempl");
|
||||
@@ -1619,9 +1658,15 @@ export default {
|
||||
margin-top: 10rpx;
|
||||
}
|
||||
|
||||
.coupon_content_stock {
|
||||
display: flex;
|
||||
font-size: 22rpx;
|
||||
color: #808080;
|
||||
margin-top: 10rpx;
|
||||
}
|
||||
|
||||
.inventory_warp {
|
||||
display: flex;
|
||||
font-weight: 500;
|
||||
font-size: 24rpx;
|
||||
color: #808080;
|
||||
margin-top: 16rpx;
|
||||
|
||||
Reference in New Issue
Block a user