<view class="bargain_time" v-if ="buyState" >
<view>{{ countdownHour }}</view>
<text>:</text>
<view>{{ countdownMinute }}</view>
<text>:</text>
<view>{{ countdownSecond }}</view> 后结束
</view>
<script>
export default {
data() {
return {
countdownHour: 0,
countdownMinute: 0,
countdownSecond: 0,
buyState:false,
List:''
};
},
<script>
onLoad() {
this.getlist();
},
method:{
getlist(){
let httpData = {
pageNo: this.page,
pageSize: 15,
};
this.$http .post( 'api/order/cut', httpData, {load: false }).then(res => {
uni.stopPullDownRefresh();
this.pages = res.pages;
if (this.pageNo == 1) {
this.List = res.data;
} else {
this.List = this.List.concat(res.data);
}
if (res.data.length > 0) {
this.pageNo = this.pageNo + 1;
}
});
},
getCountdown() {
let spikeEndTime = this.List.endTime.replace(/-/g, '/');
let endTime = new Date(spikeEndTime).getTime();
const _this = this;
recursion();
function recursion() {
let currentTime = new Date().getTime();
if (currentTime > endTime) {
_this.buyState = false;
} else {
_this.buyState = true;
let surplus = (endTime - currentTime) / 1000;
let hour = parseInt(surplus / 3600);
let minute = parseInt((surplus - hour * 3600) / 60);
let second = parseInt(surplus - hour * 3600 - minute * 60);
if (hour < 10) {
hour = '0' + hour;
}
if (minute < 10) {
minute = '0' + minute;
}
if (second < 10) {
second = '0' + second;
}
_this.countdownHour = hour;
_this.countdownMinute = minute;
_this.countdownSecond = second;
setTimeout(() => {
recursion();
}, 1000);
}
}
},
}