mirror of
http://git.coreshop.cn/jianweie/coreshoppro.git
synced 2025-12-06 18:13:26 +08:00
uniapp【修复】:商品分类sku弹框取消默认选中的问题
This commit is contained in:
@@ -169,6 +169,7 @@
|
||||
cartMoney : number,
|
||||
showSku : boolean;
|
||||
goodsDetailData : any;
|
||||
selectGoodsId : number;
|
||||
}>({
|
||||
classifyData: [],
|
||||
topTabId: 0,
|
||||
@@ -186,6 +187,7 @@
|
||||
cartMoney: 0,
|
||||
showSku: false,
|
||||
goodsDetailData: {},
|
||||
selectGoodsId: 0,
|
||||
});
|
||||
|
||||
const buyNowLoading = ref(false);
|
||||
@@ -253,6 +255,10 @@
|
||||
|
||||
/** 选择sku */
|
||||
const handleSelectSku = (id : number) => {
|
||||
if (state.selectGoodsId == id) {
|
||||
state.showSku = true;
|
||||
return;
|
||||
}
|
||||
_useLoginStore.checkLogin(async () => {
|
||||
let goodsDetail : any = null;
|
||||
if (uni.getStorageSync(UserToken)) {
|
||||
|
||||
@@ -110,6 +110,7 @@
|
||||
cartMoney : number,
|
||||
showSku : boolean;
|
||||
goodsDetailData : any;
|
||||
selectGoodsId:number;
|
||||
}>({
|
||||
classifyData: [],
|
||||
leftTabId: 0,
|
||||
@@ -122,6 +123,7 @@
|
||||
cartMoney: 0,
|
||||
showSku: false,
|
||||
goodsDetailData: {},
|
||||
selectGoodsId:0,
|
||||
});
|
||||
|
||||
const buyNowLoading = ref(false);
|
||||
@@ -178,6 +180,11 @@
|
||||
|
||||
/** 选择sku */
|
||||
const handleSelectSku = (id : number) => {
|
||||
if(state.selectGoodsId == id){
|
||||
state.showSku = true;
|
||||
return ;
|
||||
}
|
||||
|
||||
_useLoginStore.checkLogin(async () => {
|
||||
let goodsDetail : any = null;
|
||||
if (uni.getStorageSync(UserToken)) {
|
||||
@@ -191,6 +198,7 @@
|
||||
data: true,
|
||||
})
|
||||
}
|
||||
state.selectGoodsId = id;
|
||||
state.goodsDetailData = goodsDetail.data;
|
||||
state.showSku = true;
|
||||
})
|
||||
|
||||
@@ -50,7 +50,6 @@
|
||||
.tag-box {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
gap: 25rpx;
|
||||
max-height: 500rpx;
|
||||
overflow-y: scroll;
|
||||
.tag {
|
||||
@@ -60,6 +59,8 @@
|
||||
border-radius: 15rpx;
|
||||
margin: inherit;
|
||||
background-color: #fff;
|
||||
margin-right: 15rpx;
|
||||
margin-bottom: 15rpx;
|
||||
.icon-select {
|
||||
position: absolute;
|
||||
right: 0;
|
||||
|
||||
@@ -26,16 +26,13 @@
|
||||
</view>
|
||||
<view class="number-box">
|
||||
<view class="tit">数量:</view>
|
||||
<uv-number-box v-model="state.numberVal"
|
||||
@change="handleChangeNumberVal"></uv-number-box>
|
||||
<uv-number-box v-model="state.numberVal" @change="handleChangeNumberVal"></uv-number-box>
|
||||
</view>
|
||||
<view class="btn-box">
|
||||
<!-- <view v-if="props.isShowAddCartBtn" class="btn add-cart" @click="handleAddCart">加入购物车</view> -->
|
||||
<view v-if="props.isShowAddCartBtn" class="core-button-confirm add-cart">
|
||||
<coreshop-button :loading="props.addCartloading" class="core-button-confirm_" :radius="0"
|
||||
title="加入购物车" :customStyle="addCartCustomStyle" @onClick="handleAddCart()"></coreshop-button>
|
||||
</view>
|
||||
<!-- <view class="btn buy-now" @click="handleBuyNow">{{ props.btnBuyTitlt }}</view> -->
|
||||
<view class="core-button-confirm">
|
||||
<coreshop-button :loading="props.buyNowNowloading" class="core-button-confirm_" :radius="0"
|
||||
:title="props.btnBuyTitlt" :customStyle="buyNowCustomStyle"
|
||||
@@ -131,6 +128,9 @@
|
||||
|
||||
watch(() => props.goodsDetailData, (newVal : any) => {
|
||||
if (newVal) {
|
||||
state.specMap = {};
|
||||
state.specCombinationList = [];
|
||||
state.selectedSpecs = [];
|
||||
// 构造规格权重
|
||||
let i = 0, j = 0;
|
||||
state.spec_list = deepClone(newVal?.skuList?.spec_list.map((item : GoodsSpecListType) => {
|
||||
@@ -223,6 +223,10 @@
|
||||
|
||||
/** sku选择 */
|
||||
const handleChooseSku = (name : string) => {
|
||||
/** 只有一层的时候,当自己选中时,不能点击自己取消选择 */
|
||||
if (state.spec_list.length === 1 && state.selectedSpecs.find((item)=> item.name == name)) {
|
||||
return;
|
||||
}
|
||||
const spec = state.specMap[name];
|
||||
const eleIndex = state.selectedSpecs.findIndex(item => item.name === name);
|
||||
const sortIndex = state.selectedSpecs.findIndex(item => item.sort === spec.sort);
|
||||
|
||||
Reference in New Issue
Block a user