d845adea by simon

默认提交

1 parent f08b8177
import {
getBindtapData,
formatDateTime,
} from '../../utils/util';
let Date = require('../../utils/date.js');
var timer = require('../../utils/wxTimer.js');
......@@ -44,16 +45,13 @@ Page({
options
})
this.queryAuctionDetail().then((result) => {
this.refreshTime();
this.startTimer();
})
this.queryAuctionRecordLast();
this.initData();
},
onUnload() {
if (wxTimer) {
wxTimer.stop()
}
clearInterval(this.data.stiIndex);
this.removeTimer();
this.closeSocket()
},
......@@ -64,7 +62,7 @@ Page({
},
// 开始倒计时
refreshTime() {
startTimer() {
let _this = this;
if (wxTimer) {
wxTimer.stop();
......@@ -75,11 +73,11 @@ Page({
wxTimer = new timer({
beginTime: beginTime,
complete() {
// console.log("完成了")
_this.removeTimer();
_this.queryAuctionDetail();
},
interval: 1,
intervalFn() {
// console.log("过去了1秒");
let lastTime = _this.getTimeStr({
day: true
});
......@@ -92,25 +90,23 @@ Page({
wxTimer.start(_this);
},
/**
* 移除倒计时
*/
removeTimer() {
if (wxTimer) {
wxTimer.stop()
}
},
/**
* 获取时间字符串
* @param {*} initObj
*/
getTimeStr(initObj) {
initObj = initObj || {};
let productInfo = this.data.productInfo;
if (!productInfo || !productInfo.endTime) return;
let t = productInfo.endTime - new Date().getTime();
if (t <= 0) return;
let d = Math.floor(t / 1000 / 60 / 60 / 24);
let h = Math.floor(t / 1000 / 60 / 60 % 24) + (initObj.day ? 0 : 24 * d); // 含日的话,就不用24*d了
let m = Math.floor(t / 1000 / 60 % 60);
let s = Math.floor(t / 1000 % 60);
if (h < 10) h = "0" + h;
if (m < 10) m = "0" + m;
if (s < 10) s = "0" + s;
let lastTime = h + ":" + m + ":" + s;
// 包含日
if (initObj.day) {
lastTime = d + "天 " + h + ":" + m + ":" + s;
}
return lastTime;
let endTime = productInfo && productInfo.endTime || 0;
return formatDateTime(endTime,initObj)
},
/**
......@@ -205,8 +201,6 @@ Page({
resolve();
}
})
},
/**
......
......@@ -57,16 +57,17 @@ Page({
size: this.data.size,
}
}).then((result) => {
if (!result) return;
if (!result.list) return;
let dataList = result.list;
dataList.forEach(element => {
element.dateStr = new Date(element.startTime).toString("yyyy.MM.dd hh:mm") + " - " + new Date(element.endTime).toString("yyyy.MM.dd hh:mm");
});
dataList = this.data.dataList.concat(dataList);
// if (!result) return;
// if (!result.list) return;
// let dataList = result.list;
// dataList.forEach(element => {
// element.dateStr = new Date(element.startTime).toString("yyyy.MM.dd hh:mm") + " - " + new Date(element.endTime).toString("yyyy.MM.dd hh:mm");
// });
// dataList = this.data.dataList.concat(dataList);
// console.log("dataList:", dataList);
this.setData({
dataList: dataList,
total: result.total
dataList: result,
total: result.total || 0
})
resolve();
})
......
@import '../../assets/scss/mixins';
@import '../../assets/scss/utils';
$contentWidth:690px;
.page {
.bgc {}
.bgc {
background-color: #f8f8f8;
}
.bg {}
.bg {}
.main {
.top-space {
height: 0px;
}
.main {
.top-space {
height: 0px;
}
.content {
position: relative;
// list
.list {
width: $contentWidth;
margin: 24px auto 0;
&-item {
@extend .bb;
padding: 30px 0;
display: flex;
justify-content: space-between;
align-items: center;
.prize {
margin: 0 24px;
.content {
.image {
width: 160px;
height: 160px;
}
}
.cont {
position: relative;
height: 100%;
flex: 1;
padding: 0 8px 0 12px;
@extend .bb;
.tt{
}
.t1 {
font-size: 30px;
}
}
}
}
}
}
}
......
......@@ -11,11 +11,7 @@
<image class="image" mode="aspectFill" src="{{item.auctionImage && item.auctionImage[0] || ''}}" />
</view>
<view class="cont">
<view class="tt tit">{{item.auctionName}}</view>
<view class="tt t2">活动区域:{{item.district}}</view>
<view class="tt t3">{{item.dateStr}}</view>
<view class="tt t4 m1">{{item.dateStr}}</view>
<view class="tt t4">{{item.dateStr}}</view>
<view class="tt t1">{{item.auctionName}}</view>
</view>
</view>
</view>
......
......@@ -55,6 +55,33 @@ function formatNumber(n) {
}
/**
* 获取时间字符串
* @param {*} endTime
* @param {*} initObj
*/
function formatDateTime(endTime, initObj) {
initObj = initObj || {};
let t = endTime - new Date().getTime();
if (t <= 0) return "";
let d = Math.floor(t / 1000 / 60 / 60 / 24);
let h = Math.floor(t / 1000 / 60 / 60 % 24) + (initObj.day ? 0 : 24 * d); // 含日的话,就不用24*d了
let m = Math.floor(t / 1000 / 60 % 60);
let s = Math.floor(t / 1000 % 60);
// if (h < 10) h = "0" + h;
// if (m < 10) m = "0" + m;
// if (s < 10) s = "0" + s;
h = formatNumber(h);
m = formatNumber(m);
s = formatNumber(s);
let lastTime = h + ":" + m + ":" + s;
// 包含日
if (initObj.day) {
lastTime = d + "天 " + h + ":" + m + ":" + s;
}
return lastTime;
}
/**
* 获取屏幕剩余高度
* useHeight 单位是rpx
* 默认返回单位是rpx 可通过unit参数改为 px
......@@ -258,5 +285,6 @@ module.exports = {
wxacodeGet: wxacodeGet,
getObjByListKeyValue: getObjByListKeyValue,
getQueryByUrl: getQueryByUrl,
Fen2Yuan: Fen2Yuan
Fen2Yuan: Fen2Yuan,
formatDateTime: formatDateTime
}
......