|
|
|
@ -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; |
|
|
|
|
}, |
|
|
|
|
// 是否是多规格 |
|
|
|
|