【首页】

1. 秒杀活动组件
pull/1/MERGE
YunaiV 2023-06-18 02:01:24 +08:00
parent 987e90f80a
commit a89d014836
2 changed files with 41 additions and 28 deletions

View File

@ -1,5 +1,12 @@
import request from "@/utils/request.js";
// 获得当前秒杀活动
export function getNowSeckillActivity(id) {
return request.get("app-api/promotion/seckill-activity/get-now", {}, {
noAuth: true // TODO 芋艿:后续要做调整
});
}
// 获得秒杀活动明细
export function getSeckillActivity(id) {
return request.get("app-api/promotion/seckill-activity/get-detail", {

View File

@ -9,34 +9,34 @@
<view class="lines"></view>
<view class="point">{{point}} </view>
<countDown :is-day="false" :tip-text="' '" :day-text="' '" :hour-text="' : '" :minute-text="' : '" :second-text="' '"
:datatime="datatime" :is-col="true" :bgColor="bgColor"></countDown>
:datatime="datatime" :is-col="true" :bgColor="bgColor" />
</view>
<navigator url="/pages/activity/goods_seckill/index" hover-class="none" class="more acea-row row-center-wrapper">GO<text class="iconfont icon-xiangyou"></text></navigator>
<navigator url="/pages/activity/goods_seckill/index" hover-class="none" class="more acea-row row-center-wrapper">
GO<text class="iconfont icon-xiangyou"></text>
</navigator>
</view>
<view class="conter">
<scroll-view scroll-x="true" style="white-space: nowrap; vertical-align: middle;" show-scrollbar="false">
<view class="itemCon" v-for="(item, index) in spikeList" :key="index" @click="goDetail(item)">
<view class="item">
<view class="pictrue">
<image :src="item.image"></image>
<image :src="item.picUrl"></image>
</view>
<view class="name line1">{{item.title}}</view>
<view class="x_money line1">¥<text class="num">{{item.price}}</text></view>
<view class="y_money line1">¥{{item.otPrice}}</view>
<view class="name line1">{{ item.name }}</view>
<view class="x_money line1">¥<text class="num">{{ fen2yuan(item.seckillPrice ) }}</text></view>
<view class="y_money line1">¥{{ fen2yuan(item.marketPrice) }}</view>
</view>
</view>
</scroll-view>
</view>
</view>
</template>
<script>
let app = getApp();
let app = getApp();
import countDown from "@/components/countDown";
import {
getSeckillIndexApi
} from '@/api/activity.js';
export default {
import * as SeckillApi from '@/api/promotion/seckill.js';
import * as Util from '@/utils/util.js';
export default {
name: 'a_seckill',
components: {
countDown
@ -50,33 +50,39 @@
'timeTxtwidth': '16rpx',
'isDay': true
},
spikeList: [], //
point: '',
datatime: 0,
status: 0
spikeList: [], //
point: '', //
datatime: 0 //
}
},
created() {
this.getSeckillIndexTime();
SeckillApi.getNowSeckillActivity().then(res => {
//
const config = res.data.config;
if (!config) {
return;
}
this.spikeList = res.data.activities;
this.point = config.startTime;
//
const now = new Date();
this.datatime = new Date(now.getFullYear() + '-' + (now.getMonth() + 1) + '-' + now.getDate()
+ ' ' + config.endTime).getTime() / 1000;
})
},
methods: {
getSeckillIndexTime() {
getSeckillIndexApi().then(({data}) => {
this.spikeList = data ? data.productList : [];
this.point = data ? data.secKillResponse.time.split(',')[0] : '';
this.datatime = data ? parseFloat(data.secKillResponse.timeSwap) : '';
this.status = data ? data.secKillResponse.status : 0;
})
},
goDetail(item){
uni.navigateTo({
url: '/pages/activity/goods_seckill_details/index?id=' + item.id
})
}
},
fen2yuan(price) {
return Util.fen2yuan(price)
}
}
}
</script>
<style lang="scss" scoped>
.default{
width: 690rpx;
@ -187,7 +193,7 @@
color: #999999;
text-decoration: line-through;
}
.x_money {
color: #FD502F;
font-size: 28rpx;