main
fanfan 10 months ago
parent 46eb254312
commit d114542654
  1. 72
      components/goods-sku-popup/index.vue
  2. 13
      pages/goods/components/SkuPopup.vue

@ -19,7 +19,8 @@
<text class="sign">¥</text>
<text class="price" :class="priceCom.length > 16 ? 'price2' : ''">{{ priceCom }}</text>
</view>
<view class="inventory" v-if="!hideStock">{{ stockText }}{{ stockCom }}</view>
<view class="inventory" v-if="stockValue">{{ stockText }}{{stockValue?stockValue:'-' }}
</view>
<view class="inventory"></view>
<view class="choose" v-show="isManyCom">
<text v-if="!selectArr.every(val => val == '')">已选{{ selectArr.join(' ') }}</text>
@ -33,8 +34,7 @@
<view class="item-wrapper">
<view class="item-content" v-for="(item_value, index2) in item.list" :key="index2"
:class="[item_value.ishow ? '' : 'noactived', subIndex[index1] == index2 ? 'actived' : '']"
:style="[
item_value.ishow ? '' : themeColorFn('disableStyle'),
:style="[item_value.ishow ? '' : themeColorFn('disableStyle'),
item_value.ishow ? themeColorFn('btnStyle') : '',
subIndex[index1] == index2 ? themeColorFn('activedStyle') : ''
]" @click="skuClick(item_value, index1, index2,item)">
@ -61,16 +61,16 @@
<view class="sure" style="color:#ffffff;background-color:#cccccc">{{ noStockText }}</view>
</view>
<view class="btn-wrapper" v-else-if="mode == 1">
<view class="sure add-cart" style="border-radius:38rpx 0rpx 0rpx 38rpx;" :style="{
<view class="sure add-cart" v-if="stockValue=='有货'" style="border-radius:38rpx 0rpx 0rpx 38rpx;" :style="{
color: themeColorFn('addCartColor'),
backgroundColor: themeColorFn('addCartBackgroundColor')
backgroundColor:stockValue=='有货'? themeColorFn('addCartBackgroundColor'):'#cecece'
}" @click="addCart">
{{ addCartText }}
</view>
<view class="sure" style="border-radius:0rpx 38rpx 38rpx 0rpx;" :style="{
color: themeColorFn('buyNowColor'),
backgroundColor: themeColorFn('buyNowBackgroundColor')
backgroundColor:stockValue=='有货'? themeColorFn('buyNowBackgroundColor'):'#cecece'
}" @click="buyNow">
{{ userInfo.user_type == 40?'修改价格':buyNowText }}
</view>
@ -78,7 +78,7 @@
<view class="btn-wrapper" v-else-if="mode == 2">
<view class="sure add-cart" :style="{
color: themeColorFn('addCartColor'),
backgroundColor: themeColorFn('addCartBackgroundColor')
backgroundColor: stockValue=='有货'?themeColorFn('addCartBackgroundColor'):'#cecece'
}" @click="addCart">
{{ addCartText }}
</view>
@ -86,7 +86,7 @@
<view class="btn-wrapper" v-else-if="mode == 3">
<view class="sure" :style="{
color: themeColorFn('buyNowColor'),
backgroundColor: themeColorFn('buyNowBackgroundColor')
backgroundColor: stockValue=='有货'? themeColorFn('buyNowBackgroundColor'):'#cecece'
}" @click="buyNow">
{{ userInfo.user_type == 40?'修改价格':buyNowText }}
</view>
@ -98,6 +98,7 @@
<script>
import NumberBox from './number-box'
import * as GoodsApi from '@/api/goods'
var vk; // vk
var goodsCache = {}; //
export default {
@ -334,9 +335,18 @@
Type: Boolean,
default: true
},
addressResult: {
type: Object,
default: {
province: '江苏省',
city: '南京市',
district: '玄武区'
}
},
},
data() {
return {
stockValue: '有货',
skuItem: '',
userInfo: {},
complete: false, //
@ -446,6 +456,29 @@
},
mounted() {},
methods: {
async getGoodsStockInfor(list) {
let that = this;
let params = {
list: list,
province: that.addressResult ? that.addressResult.province : '江苏省',
city: that.addressResult ? that.addressResult.city : '南京市',
district: that.addressResult ? that.addressResult.district : '玄武区'
}
let {
status,
message,
data
} = await GoodsApi.getGoodsStock(params);
if (status == 200) {
that.stockValue = data[0].state
if (that.stockValue == '无货') {
uni.showToast({
icon: "none",
title: "该商品暂时无货"
})
}
}
},
//
init(notAutoClick) {
let that = this;
@ -461,8 +494,6 @@
that.selectArr.push('');
that.subIndex.push(-1);
});
console.log(notAutoClick, that.specListName)
console.log(that.goodsInfo)
that.checkItem(); // sku
that.checkInpath(-1); // -1
if (!notAutoClick) that.autoClickSku(); // sku
@ -645,6 +676,7 @@
},
// sku
skuClick(value, index1, index2, item) {
console.log(value, index1, index2, item, )
let that = this;
if (value.ishow) {
if (that.selectArr[index1] != value.name) {
@ -663,8 +695,21 @@
that.checkInpath(index1);
//
that.checkSelectShop();
let {
selectShop,
selectNum
} = that;
if (!that.isObjectEmpty(selectShop)) {
that.getGoodsStockInfor([{
goods_id: selectShop.goods_id,
num: selectNum
}])
}
}
},
isObjectEmpty(obj) {
return Object.keys(obj).length === 0;
},
// sku
checkSelectShop() {
let that = this;
@ -770,7 +815,6 @@
[]
]
);
// console.timeEnd('');
},
getArrayToSting(arr) {
let str = '';
@ -941,7 +985,7 @@
let skuName = skuArr[index];
let specList = specListArr[index].list;
let index1 = index;
let index2 = that.getListIndex(specList, 'name', skuName);
let index2 = that.getListIndex(specList, 'name', skuName, );
if (index2 == -1) {
clickKey = false;
break;
@ -1015,7 +1059,7 @@
maxStock = max;
}
}
console.log("getMaxStock",maxStock)
console.log("getMaxStock", maxStock)
return maxStock;
},
numChange(e) {
@ -1042,7 +1086,7 @@
if (max > maxStock) {
max = maxStock;
}
console.log("maxBuyNumCom",maxStock,that.maxBuyNum)
console.log("maxBuyNumCom", maxStock, that.maxBuyNum)
return max;
},
//

@ -4,7 +4,7 @@
:addCartColor="appTheme.viceText" :addCartBackgroundColor="appTheme.viceBg"
:activedStyle="{ color: appTheme.mainBg, borderColor: appTheme.mainBg, backgroundColor: activedBtnBackgroundColor }"
@open="openSkuPopup" @close="closeSkuPopup" @add-cart="addCart" @buy-now="buyNow" @num-change='numChange'
@selected-old='selectedOld' buyNowText="立即购买" :maxBuyNum="maxBuyNum" />
@selected-old='selectedOld' buyNowText="立即购买" :maxBuyNum="maxBuyNum" :addressResult='addressResult' />
</template>
<script>
@ -40,12 +40,7 @@
default: {}
},
addressResult: {
type: Object,
default: {
province: '江苏省',
city: '南京市',
district: '玄武区'
}
type: Object
},
},
data() {
@ -218,8 +213,8 @@
let that = this;
let params = {
list: [{
goods_id: that.goods.goods_id,
num: that.selectNum
goods_id:selectShop.goods_id,
num: selectShop.buy_num
}],
province: that.addressResult ? that.addressResult.province : '江苏省',
city: that.addressResult ? that.addressResult.city : '南京市',

Loading…
Cancel
Save