main
fanfan 10 months ago
parent d6ab9e51c1
commit 322583721f
  1. 59
      pages/goods/components/SkuPopup.vue
  2. 96
      pages/goods/components/setPrice.vue
  3. 5
      pages/goods/detail.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)
}
},
}
}

@ -11,20 +11,20 @@
placeholder="秒杀价格可低于成本价" />
</view>
<view class="priceTime">
<view class="text">秒杀区间</view>
<view class="priceDate">
<view class="selectTime" :style="'color: ' + (startTime?fontColor:'')" @click="timeShow=true">
{{startTime?startTime:'起始时间'}}
</view>
<text>-</text>
<view class="selectTime" :style="'color: ' + (endTime?fontColor:'')" @click="timeShow=true">
{{endTime?endTime:'终止时间'}}
</view>
<view class="text">开始时间</view>
<view class="selectTime" :style="'color: ' + (startTime?fontColor:'')" @click="timeShow=true">
{{startTime?startTime:'起始时间'}}
</view>
</view>
<view class="priceCon" style="justify-content: space-between;">
<view class="priceCon" v-if="secondQuota">
<text>秒杀时长</text>
<input type="number" style="width: 130rpx;margin-right: 15rpx;" class="input" v-model="sec_hour"
placeholder="请输入"> /
</view>
<view class="priceCon">
<text>秒杀限购</text>
<u-switch v-model="secondQuota" size='35' @change="change" activeColor='#55BD6A' inactiveColor='#F1F1F1'>
<u-switch v-model="secondQuota" size='35' @change="change" activeColor='#55BD6A'
inactiveColor='#F1F1F1'>
</u-switch>
</view>
<view class="priceCon" v-if="secondQuota">
@ -44,8 +44,8 @@
</view>
</u-popup>
</view>
<u-calendar v-model="timeShow" mode="multiple" minDate='0' @change="getTime" :pickerOptions="pickerOptions" range-color='#FF6257' range-bg-color='#FFBDBA'
active-bg-color='#FF6257'></u-calendar>
<u-calendar v-model="timeShow" mode="date" minDate='0' @change="getTime" :pickerOptions="pickerOptions"
range-color='#FF6257' range-bg-color='#FFBDBA' active-bg-color='#FF6257'></u-calendar>
</template>
<script>
@ -55,28 +55,22 @@
afterSale: false,
timeShow: false,
startTime: '',
endTime: '',
sec_hour: '',
secondPrice: '',
secondQuota: 1,
quotaNum: '',
fontColor:'#262626',
pickerOptions:{
disabledDate(time){
return true
}
}
fontColor: '#262626',
}
},
methods: {
reset() {
this.startTime = null;
this.endTime = null
this.sec_hour = null
this.secondPrice = null;
this.quotaNum = null
},
getTime(e) {
this.startTime = e.startDate;
this.endTime = e.endDate;
this.startTime = e.result;
},
submit() {
if (!this.secondPrice) {
@ -85,18 +79,18 @@
if (!this.startTime) {
return this.$toast('请选择开始时间')
}
if (!this.endTime) {
return this.$toast('请选择结束时间')
if (!this.sec_hour) {
return this.$toast('请输入秒杀时长')
}
if (!this.quotaNum&&this.secondQuota) {
if (!this.quotaNum && this.secondQuota) {
return this.$toast('请输入限购次数')
}
this.$emit('getprice', {
startTime: this.startTime,
endTime: this.endTime,
sec_hour: this.sec_hour,
secondPrice: this.secondPrice,
quotaNum: this.secondQuota?this.quotaNum:'',
secondQuota: this.secondQuota?1:2
quotaNum: this.secondQuota ? this.quotaNum : '',
secondQuota: this.secondQuota ? 1 : 2
})
}
}
@ -108,6 +102,7 @@
background-color: #FF6257 !important;
border-color: #FF6257 !important;
}
.afterSales {
padding: 32upx;
@ -154,6 +149,10 @@
}
.priceTime {
display: flex;
align-items: center;
font-size: 28rpx;
color: #262626;
margin-bottom: 20rpx;
.text {
@ -168,28 +167,23 @@
text-transform: none;
}
.priceDate {
display: flex;
align-items: center;
.selectTime {
width: 238rpx;
height: 70rpx;
background: #F3F3F3;
border-radius: 44rpx;
text-align: center;
line-height: 70rpx;
font-family: PingFang SC, PingFang SC;
font-weight: 500;
font-size: 28rpx;
color: #A1A1A1;
font-style: normal;
text-transform: none;
}
text {
margin: 0 15rpx;
}
.selectTime {
width: 300rpx;
height: 70rpx;
background: #F3F3F3;
border-radius: 44rpx;
text-align: center;
line-height: 70rpx;
font-family: PingFang SC, PingFang SC;
font-weight: 500;
font-size: 28rpx;
color: #A1A1A1;
font-style: normal;
text-transform: none;
}
text {
margin: 0 15rpx;
}
}

@ -409,7 +409,7 @@
<image :src="$picUrl+'/static/toTop.png?=1'"></image>
</view>
<view v-if="isTodo">
<SkuPopup v-model="showSkuPopup" :skuMode="skuMode" :goods="goods" @getSku='onGetSku'
<SkuPopup v-model="showSkuPopup" :skuMode="skuMode" :goods="goods" :addressResult='addressResult' @getSku='onGetSku'
@addCart="onAddCart" />
</view>
<setPrice ref="setRange" @getprice="getprice" />
@ -618,7 +618,7 @@
sku_id: that.goods.skuList[0].id,
seckill_price: e.secondPrice,
sec_start_time: e.startTime,
sec_end_time: e.endTime,
sec_hour: e.sec_hour,
is_limit: e.secondQuota,
limit_times: e.quotaNum
}
@ -836,6 +836,7 @@
})
},
onGetSku(e) {
console.log(e)
this.selectSku = e.selectSku
this.selectNum = e.shopNum
},

Loading…
Cancel
Save