diff --git a/pages/goods/components/SkuPopup.vue b/pages/goods/components/SkuPopup.vue index ca482e5..0ccd367 100644 --- a/pages/goods/components/SkuPopup.vue +++ b/pages/goods/components/SkuPopup.vue @@ -16,6 +16,7 @@ } from '@/utils/color' import * as CartApi from '@/api/cart' import GoodsSkuPopup from '@/components/goods-sku-popup' + import * as GoodsApi from '@/api/goods' export default { components: { @@ -37,7 +38,15 @@ goods: { type: Object, default: {} - } + }, + addressResult: { + type: Object, + default: { + province: '江苏省', + city: '南京市', + district: '玄武区' + } + }, }, data() { return { @@ -47,6 +56,7 @@ maxBuyNum: null, selectSku: '', shopNum: 1, + stockValue: '有货', } }, computed: { @@ -204,11 +214,46 @@ closeSkuPopup() { // console.log("监听 - 关闭sku组件") }, - + async getGoodsStockInfor(selectShop, type) { + let that = this; + let params = { + list: [{ + goods_id: that.goods.goods_id, + num: that.selectNum + }], + 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: "该商品暂时无货" + }) + } else { + if (type == 1) { + that.addCartInfor(selectShop) + } else { + that.buyNowInfor(selectShop) + } + } + } + }, // 加入购物车按钮 addCart(selectShop) { - this.selectInfor = selectShop const app = this + app.getGoodsStockInfor(selectShop, 1) + }, + addCartInfor(selectShop) { + const app = this + app.selectInfor = selectShop const { goods_id, goods_sku_id, @@ -228,9 +273,13 @@ app.$emit('addCart', cartTotal) }) }, - // 立即购买 buyNow(selectShop) { + const app = this + app.getGoodsStockInfor(selectShop, 2) + }, + buyNowInfor(selectShop) { + const app = this this.selectInfor = selectShop if (uni.getStorageSync("userInfo").user_type == 40) { // 隐藏当前弹窗 @@ -248,7 +297,7 @@ }) // 隐藏当前弹窗 this.onChangeValue(false) - } + }, } } diff --git a/pages/goods/components/setPrice.vue b/pages/goods/components/setPrice.vue index dbc7382..e9221b5 100644 --- a/pages/goods/components/setPrice.vue +++ b/pages/goods/components/setPrice.vue @@ -11,20 +11,20 @@ placeholder="秒杀价格可低于成本价" /> - 秒杀区间: - - - {{startTime?startTime:'起始时间'}} - - - - - {{endTime?endTime:'终止时间'}} - + 开始时间: + + {{startTime?startTime:'起始时间'}} - + + 秒杀时长: + /小时 + + 秒杀限购: - + @@ -44,8 +44,8 @@ - +