默认提交
Showing
5 changed files
with
107 additions
and
43 deletions
1 | import { | 1 | import { |
2 | getBindtapData, | 2 | getBindtapData, |
3 | formatDateTime, | ||
3 | } from '../../utils/util'; | 4 | } from '../../utils/util'; |
4 | let Date = require('../../utils/date.js'); | 5 | let Date = require('../../utils/date.js'); |
5 | var timer = require('../../utils/wxTimer.js'); | 6 | var timer = require('../../utils/wxTimer.js'); |
... | @@ -44,16 +45,13 @@ Page({ | ... | @@ -44,16 +45,13 @@ Page({ |
44 | options | 45 | options |
45 | }) | 46 | }) |
46 | this.queryAuctionDetail().then((result) => { | 47 | this.queryAuctionDetail().then((result) => { |
47 | this.refreshTime(); | 48 | this.startTimer(); |
48 | }) | 49 | }) |
49 | this.queryAuctionRecordLast(); | 50 | this.queryAuctionRecordLast(); |
50 | this.initData(); | 51 | this.initData(); |
51 | }, | 52 | }, |
52 | onUnload() { | 53 | onUnload() { |
53 | if (wxTimer) { | 54 | this.removeTimer(); |
54 | wxTimer.stop() | ||
55 | } | ||
56 | clearInterval(this.data.stiIndex); | ||
57 | this.closeSocket() | 55 | this.closeSocket() |
58 | }, | 56 | }, |
59 | 57 | ||
... | @@ -64,7 +62,7 @@ Page({ | ... | @@ -64,7 +62,7 @@ Page({ |
64 | }, | 62 | }, |
65 | 63 | ||
66 | // 开始倒计时 | 64 | // 开始倒计时 |
67 | refreshTime() { | 65 | startTimer() { |
68 | let _this = this; | 66 | let _this = this; |
69 | if (wxTimer) { | 67 | if (wxTimer) { |
70 | wxTimer.stop(); | 68 | wxTimer.stop(); |
... | @@ -75,11 +73,11 @@ Page({ | ... | @@ -75,11 +73,11 @@ Page({ |
75 | wxTimer = new timer({ | 73 | wxTimer = new timer({ |
76 | beginTime: beginTime, | 74 | beginTime: beginTime, |
77 | complete() { | 75 | complete() { |
78 | // console.log("完成了") | 76 | _this.removeTimer(); |
77 | _this.queryAuctionDetail(); | ||
79 | }, | 78 | }, |
80 | interval: 1, | 79 | interval: 1, |
81 | intervalFn() { | 80 | intervalFn() { |
82 | // console.log("过去了1秒"); | ||
83 | let lastTime = _this.getTimeStr({ | 81 | let lastTime = _this.getTimeStr({ |
84 | day: true | 82 | day: true |
85 | }); | 83 | }); |
... | @@ -92,25 +90,23 @@ Page({ | ... | @@ -92,25 +90,23 @@ Page({ |
92 | wxTimer.start(_this); | 90 | wxTimer.start(_this); |
93 | }, | 91 | }, |
94 | 92 | ||
93 | /** | ||
94 | * 移除倒计时 | ||
95 | */ | ||
96 | removeTimer() { | ||
97 | if (wxTimer) { | ||
98 | wxTimer.stop() | ||
99 | } | ||
100 | }, | ||
101 | |||
102 | /** | ||
103 | * 获取时间字符串 | ||
104 | * @param {*} initObj | ||
105 | */ | ||
95 | getTimeStr(initObj) { | 106 | getTimeStr(initObj) { |
96 | initObj = initObj || {}; | ||
97 | let productInfo = this.data.productInfo; | 107 | let productInfo = this.data.productInfo; |
98 | if (!productInfo || !productInfo.endTime) return; | 108 | let endTime = productInfo && productInfo.endTime || 0; |
99 | let t = productInfo.endTime - new Date().getTime(); | 109 | return formatDateTime(endTime,initObj) |
100 | if (t <= 0) return; | ||
101 | let d = Math.floor(t / 1000 / 60 / 60 / 24); | ||
102 | let h = Math.floor(t / 1000 / 60 / 60 % 24) + (initObj.day ? 0 : 24 * d); // 含日的话,就不用24*d了 | ||
103 | let m = Math.floor(t / 1000 / 60 % 60); | ||
104 | let s = Math.floor(t / 1000 % 60); | ||
105 | if (h < 10) h = "0" + h; | ||
106 | if (m < 10) m = "0" + m; | ||
107 | if (s < 10) s = "0" + s; | ||
108 | let lastTime = h + ":" + m + ":" + s; | ||
109 | // 包含日 | ||
110 | if (initObj.day) { | ||
111 | lastTime = d + "天 " + h + ":" + m + ":" + s; | ||
112 | } | ||
113 | return lastTime; | ||
114 | }, | 110 | }, |
115 | 111 | ||
116 | /** | 112 | /** |
... | @@ -205,8 +201,6 @@ Page({ | ... | @@ -205,8 +201,6 @@ Page({ |
205 | resolve(); | 201 | resolve(); |
206 | } | 202 | } |
207 | }) | 203 | }) |
208 | |||
209 | |||
210 | }, | 204 | }, |
211 | 205 | ||
212 | /** | 206 | /** | ... | ... |
... | @@ -57,16 +57,17 @@ Page({ | ... | @@ -57,16 +57,17 @@ Page({ |
57 | size: this.data.size, | 57 | size: this.data.size, |
58 | } | 58 | } |
59 | }).then((result) => { | 59 | }).then((result) => { |
60 | if (!result) return; | 60 | // if (!result) return; |
61 | if (!result.list) return; | 61 | // if (!result.list) return; |
62 | let dataList = result.list; | 62 | // let dataList = result.list; |
63 | dataList.forEach(element => { | 63 | // dataList.forEach(element => { |
64 | element.dateStr = new Date(element.startTime).toString("yyyy.MM.dd hh:mm") + " - " + new Date(element.endTime).toString("yyyy.MM.dd hh:mm"); | 64 | // element.dateStr = new Date(element.startTime).toString("yyyy.MM.dd hh:mm") + " - " + new Date(element.endTime).toString("yyyy.MM.dd hh:mm"); |
65 | }); | 65 | // }); |
66 | dataList = this.data.dataList.concat(dataList); | 66 | // dataList = this.data.dataList.concat(dataList); |
67 | // console.log("dataList:", dataList); | ||
67 | this.setData({ | 68 | this.setData({ |
68 | dataList: dataList, | 69 | dataList: result, |
69 | total: result.total | 70 | total: result.total || 0 |
70 | }) | 71 | }) |
71 | resolve(); | 72 | resolve(); |
72 | }) | 73 | }) | ... | ... |
1 | @import '../../assets/scss/mixins'; | 1 | @import '../../assets/scss/mixins'; |
2 | @import '../../assets/scss/utils'; | 2 | @import '../../assets/scss/utils'; |
3 | 3 | ||
4 | $contentWidth:690px; | ||
5 | |||
4 | .page { | 6 | .page { |
5 | .bgc {} | 7 | .bgc { |
8 | background-color: #f8f8f8; | ||
9 | } | ||
6 | 10 | ||
7 | .bg {} | 11 | .bg {} |
8 | 12 | ||
... | @@ -13,6 +17,47 @@ | ... | @@ -13,6 +17,47 @@ |
13 | 17 | ||
14 | .content { | 18 | .content { |
15 | position: relative; | 19 | position: relative; |
20 | |||
21 | // list | ||
22 | .list { | ||
23 | width: $contentWidth; | ||
24 | margin: 24px auto 0; | ||
25 | |||
26 | &-item { | ||
27 | @extend .bb; | ||
28 | padding: 30px 0; | ||
29 | display: flex; | ||
30 | justify-content: space-between; | ||
31 | align-items: center; | ||
32 | |||
33 | .prize { | ||
34 | margin: 0 24px; | ||
35 | |||
36 | .image { | ||
37 | width: 160px; | ||
38 | height: 160px; | ||
39 | } | ||
40 | } | ||
41 | |||
42 | .cont { | ||
43 | position: relative; | ||
44 | height: 100%; | ||
45 | flex: 1; | ||
46 | padding: 0 8px 0 12px; | ||
47 | @extend .bb; | ||
48 | |||
49 | .tt{ | ||
50 | |||
51 | } | ||
52 | |||
53 | .t1 { | ||
54 | font-size: 30px; | ||
55 | } | ||
56 | } | ||
57 | |||
58 | } | ||
59 | } | ||
60 | |||
16 | } | 61 | } |
17 | } | 62 | } |
18 | } | 63 | } | ... | ... |
... | @@ -11,11 +11,7 @@ | ... | @@ -11,11 +11,7 @@ |
11 | <image class="image" mode="aspectFill" src="{{item.auctionImage && item.auctionImage[0] || ''}}" /> | 11 | <image class="image" mode="aspectFill" src="{{item.auctionImage && item.auctionImage[0] || ''}}" /> |
12 | </view> | 12 | </view> |
13 | <view class="cont"> | 13 | <view class="cont"> |
14 | <view class="tt tit">{{item.auctionName}}</view> | 14 | <view class="tt t1">{{item.auctionName}}</view> |
15 | <view class="tt t2">活动区域:{{item.district}}</view> | ||
16 | <view class="tt t3">{{item.dateStr}}</view> | ||
17 | <view class="tt t4 m1">{{item.dateStr}}</view> | ||
18 | <view class="tt t4">{{item.dateStr}}</view> | ||
19 | </view> | 15 | </view> |
20 | </view> | 16 | </view> |
21 | </view> | 17 | </view> | ... | ... |
... | @@ -55,6 +55,33 @@ function formatNumber(n) { | ... | @@ -55,6 +55,33 @@ function formatNumber(n) { |
55 | } | 55 | } |
56 | 56 | ||
57 | /** | 57 | /** |
58 | * 获取时间字符串 | ||
59 | * @param {*} endTime | ||
60 | * @param {*} initObj | ||
61 | */ | ||
62 | function formatDateTime(endTime, initObj) { | ||
63 | initObj = initObj || {}; | ||
64 | let t = endTime - new Date().getTime(); | ||
65 | if (t <= 0) return ""; | ||
66 | let d = Math.floor(t / 1000 / 60 / 60 / 24); | ||
67 | let h = Math.floor(t / 1000 / 60 / 60 % 24) + (initObj.day ? 0 : 24 * d); // 含日的话,就不用24*d了 | ||
68 | let m = Math.floor(t / 1000 / 60 % 60); | ||
69 | let s = Math.floor(t / 1000 % 60); | ||
70 | // if (h < 10) h = "0" + h; | ||
71 | // if (m < 10) m = "0" + m; | ||
72 | // if (s < 10) s = "0" + s; | ||
73 | h = formatNumber(h); | ||
74 | m = formatNumber(m); | ||
75 | s = formatNumber(s); | ||
76 | let lastTime = h + ":" + m + ":" + s; | ||
77 | // 包含日 | ||
78 | if (initObj.day) { | ||
79 | lastTime = d + "天 " + h + ":" + m + ":" + s; | ||
80 | } | ||
81 | return lastTime; | ||
82 | } | ||
83 | |||
84 | /** | ||
58 | * 获取屏幕剩余高度 | 85 | * 获取屏幕剩余高度 |
59 | * useHeight 单位是rpx | 86 | * useHeight 单位是rpx |
60 | * 默认返回单位是rpx 可通过unit参数改为 px | 87 | * 默认返回单位是rpx 可通过unit参数改为 px |
... | @@ -258,5 +285,6 @@ module.exports = { | ... | @@ -258,5 +285,6 @@ module.exports = { |
258 | wxacodeGet: wxacodeGet, | 285 | wxacodeGet: wxacodeGet, |
259 | getObjByListKeyValue: getObjByListKeyValue, | 286 | getObjByListKeyValue: getObjByListKeyValue, |
260 | getQueryByUrl: getQueryByUrl, | 287 | getQueryByUrl: getQueryByUrl, |
261 | Fen2Yuan: Fen2Yuan | 288 | Fen2Yuan: Fen2Yuan, |
289 | formatDateTime: formatDateTime | ||
262 | } | 290 | } | ... | ... |
-
Please register or sign in to post a comment