feat:优化需求

This commit is contained in:
2026-07-22 21:33:50 +08:00
parent 17ab8beefa
commit d9d3ec573a
3 changed files with 62 additions and 18 deletions
+2 -3
View File
@@ -25,16 +25,15 @@
</view> </view>
</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"> <view class="tab-list" @click="onTab(index)" v-for="(item, index) in tabList" :key="index">
<text class="text-28 text-space" :style="{ <text class="text-28 text-space" :style="{
color: curTab == index ? '#7A35F6' : '#666' color: curTab == index ? '#7A35F6' : '#666'
}"> }">
{{ item.name }} {{ item.name }}
</text> </text>
<!-- <view class="line" v-if="curTab == index"></view> -->
</view>
</view> </view>
</view> -->
</view> </view>
<view class="setting-view"> <view class="setting-view">
+2 -2
View File
@@ -17,14 +17,14 @@
</view> </view>
<view class="tab-view"> <!-- <view class="tab-view">
<view class="tab-list" @click="onTab(index)" v-for="(item, index) in tabList" :key="index"> <view class="tab-list" @click="onTab(index)" v-for="(item, index) in tabList" :key="index">
<text class="text-28 text-space" :style="{ <text class="text-28 text-space" :style="{
color: curTab == index ? '#7A35F6' : '#666', color: curTab == index ? '#7A35F6' : '#666',
}">{{ item.name }}</text> }">{{ item.name }}</text>
<view class="line" v-if="curTab == index"></view> <view class="line" v-if="curTab == index"></view>
</view> </view>
</view> </view> -->
<view class="setting-view"> <view class="setting-view">
<view class="name-box"> <view class="name-box">
+55 -10
View File
@@ -165,8 +165,7 @@
</view> </view>
<!-- 限时秒杀现在要改为展示购物车icon 并且立即购买按钮变长一点 --> <!-- 限时秒杀现在要改为展示购物车icon 并且立即购买按钮变长一点 -->
<view class="but_comm buy_warp" :class="{ 'border-16': isShowCart || isCoupon }" <view class="but_comm buy_warp" :class="{ 'border-16': isShowCart || isCoupon }"
:style="isCoupon ? 'width: 400rpx' : ''" :style="isCoupon ? 'width: 400rpx' : ''" @click="checkSpecification(true, 'buy')">
@click="checkSpecification(true, 'buy')">
立即购买 立即购买
</view> </view>
</view> </view>
@@ -191,7 +190,8 @@
</view> </view>
<!-- 商品 --> <!-- 商品 -->
<view class="specification_product_warp"> <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="product_content">
<view class="price_warp"> <view class="price_warp">
<!-- 优惠券价格 --> <!-- 优惠券价格 -->
@@ -211,21 +211,30 @@
{{ selectSpecificationTempl.price }} {{ selectSpecificationTempl.price }}
</text> </text>
<view style="font-size: 50rpx" v-else> <view style="font-size: 50rpx" v-else>
{{ orderInfo.minPrice }} {{ skuBySpecInfo.supplyPrice }}
<text v-if="orderInfo.maxPrice">- {{ orderInfo.maxPrice }}</text> <text v-if="skuBySpecInfo.price">- {{ skuBySpecInfo.price }}</text>
</view> </view>
<view class="price_content_coupon_warp" v-if="orderInfo.couponPrice && orderInfo.couponPrice !== 0"> <view class="price_content_coupon_warp" v-if="orderInfo.couponPrice && orderInfo.couponPrice !== 0">
优惠券{{ 优惠券{{
orderInfo.couponPrice }}</view> orderInfo.couponPrice }}</view>
</view> </view>
<view class="oOrice_content_warp" v-if="!isCoupon">¥{{ orderInfo.adPrice }}</view> <view class="oOrice_content_warp" v-if="!isCoupon">¥{{ skuBySpecInfo.supplyPrice }}</view>
<view class="coupon_content_warp" v-if="orderInfo.couponPrice && orderInfo.couponPrice !== 0">优惠卷已优惠¥{{ <view class="coupon_content_warp" v-if="orderInfo.couponPrice && orderInfo.couponPrice !== 0">
优惠券已优惠¥{{
orderInfo.couponPrice }}</view> orderInfo.couponPrice }}</view>
<view class="coupon_content_stock">
<view>库存</view>
<view>{{ skuBySpecInfo.stock || 0 }}件</view>
</view>
</view> </view>
<view class="inventory_warp"> <view class="inventory_warp">
<view>库存</view> <!-- <view>库存</view>
<view>{{ orderInfo.inventory || 0 }}件</view> <view>{{ skuBySpecInfo.stock || 0 }}件</view> -->
<view>已选规格: {{ skuBySpecInfo.skuName }}</view>
</view> </view>
</view> </view>
</view> </view>
@@ -422,6 +431,7 @@ export default {
curAmount: 0, // 当前人剩余优惠券金额 curAmount: 0, // 当前人剩余优惠券金额
activedType: "", // 活动类型 activedType: "", // 活动类型
activityId: "", // 秒杀活动ID activityId: "", // 秒杀活动ID
skuBySpecInfo: {},
}; };
}, },
onBackPress(options) { onBackPress(options) {
@@ -885,6 +895,8 @@ export default {
if (this.activedType === 'seckill') { if (this.activedType === 'seckill') {
data.minPrice = data.activity?.activityPrice; data.minPrice = data.activity?.activityPrice;
} }
console.log("查询详细内容---", data)
this.orderInfo = data; this.orderInfo = data;
} }
}, },
@@ -1033,6 +1045,13 @@ export default {
})), })),
})); }));
this.refreshSpecOptionState(); 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; return true;
}, },
@@ -1100,6 +1119,12 @@ export default {
this.specificationList[groupIndex].selectVal = oItem.n; this.specificationList[groupIndex].selectVal = oItem.n;
this.refreshSpecOptionState(); 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)) { if (this.selectedSpecValueIds.every((id) => id != null)) {
const currentSelectSpecification = this.skuBySpecKey[this.selectedSpecValueIds.join("_")] || {}; const currentSelectSpecification = this.skuBySpecKey[this.selectedSpecValueIds.join("_")] || {};
this.selectSpecificationTempl = currentSelectSpecification; this.selectSpecificationTempl = currentSelectSpecification;
@@ -1109,6 +1134,20 @@ export default {
this.selectSpecificationTempl = {}; 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) { selectSpecificationFun(index, item) {
console.log("selectSpecificationTempl"); console.log("selectSpecificationTempl");
@@ -1619,9 +1658,15 @@ export default {
margin-top: 10rpx; margin-top: 10rpx;
} }
.coupon_content_stock {
display: flex;
font-size: 22rpx;
color: #808080;
margin-top: 10rpx;
}
.inventory_warp { .inventory_warp {
display: flex; display: flex;
font-weight: 500;
font-size: 24rpx; font-size: 24rpx;
color: #808080; color: #808080;
margin-top: 16rpx; margin-top: 16rpx;