正在显示
3 个修改的文件
包含
140 行增加
和
4 行删除
@@ -33,8 +33,80 @@ App({ | @@ -33,8 +33,80 @@ App({ | ||
33 | } | 33 | } |
34 | }) | 34 | }) |
35 | }, | 35 | }, |
36 | + | ||
37 | + post: function(url,data,headerParams){ | ||
38 | + // 页面初次加载 转圈与提示 | ||
39 | + wx.showNavigationBarLoading() | ||
40 | + wx.showLoading({ | ||
41 | + title: '加载', | ||
42 | + }) | ||
43 | + var promise = new Promise((resolve,reject) => { | ||
44 | + let that = this; | ||
45 | + let postData = data; | ||
46 | + let baseUrl = 'http://grouppay.w.bronet.cn/api/'; | ||
47 | + //网络请求 | ||
48 | + let header = { | ||
49 | + 'content-type': 'application/x-www-form-urlencoded' | ||
50 | + } | ||
51 | + header = Object.assign(header,headerParams) | ||
52 | + wx.request({ | ||
53 | + url: baseUrl + url, | ||
54 | + data: postData, | ||
55 | + method: 'POST', | ||
56 | + header: header, | ||
57 | + success: function(res){ | ||
58 | + //返回取得的数据 | ||
59 | + if(res.data.code == '20000'){ | ||
60 | + resolve(res.data); | ||
61 | + }else if(res.data.code == '10001'){ | ||
62 | + | ||
63 | + }else if(res.data.code == '40000'){ | ||
64 | + wx.showModal({ | ||
65 | + title: '提示', | ||
66 | + content: res.data.msg, | ||
67 | + showCancel: false, | ||
68 | + success: function(res){ | ||
69 | + | ||
70 | + } | ||
71 | + }) | ||
72 | + }else if (res.data.code == '40005'){ | ||
73 | + wx.showModal({ | ||
74 | + title: '提示', | ||
75 | + content: res.data.msg, | ||
76 | + showCancel:false, | ||
77 | + success: function (res){ | ||
78 | + | ||
79 | + } | ||
80 | + }) | ||
81 | + }else if(res.data.code== '40006'){ | ||
82 | + | ||
83 | + }else { | ||
84 | + wx.showModal({ | ||
85 | + title: '提示', | ||
86 | + content: res.data.msg, | ||
87 | + showCancel: false, | ||
88 | + }) | ||
89 | + reject(res.data) | ||
90 | + } | ||
91 | + // 隐藏等待框 隐藏转圈框 | ||
92 | + wx.hideLoading() | ||
93 | + wx.hideNavigationBarLoading() | ||
94 | + }, | ||
95 | + // 连接失败 | ||
96 | + fail: function(e){ | ||
97 | + console.log(e) | ||
98 | + reject('网络出错'); | ||
99 | + wx.hideNavigationBarLoading() | ||
100 | + } | ||
101 | + }) | ||
102 | + }) | ||
103 | + }, | ||
104 | + | ||
105 | + | ||
106 | + | ||
36 | globalData: { | 107 | globalData: { |
37 | userInfo: null, | 108 | userInfo: null, |
38 | baseUrl: '../../img/' | 109 | baseUrl: '../../img/' |
39 | } | 110 | } |
40 | -}) | ||
111 | +}) | ||
112 | + |
@@ -4,21 +4,84 @@ Page({ | @@ -4,21 +4,84 @@ Page({ | ||
4 | * 页面的初始数据 | 4 | * 页面的初始数据 |
5 | */ | 5 | */ |
6 | data: { | 6 | data: { |
7 | - | 7 | + windowHeight: 654, |
8 | + maxtime: "", | ||
9 | + isHiddenLoading: true, | ||
10 | + isHiddenToast: true, | ||
11 | + dataList: {}, | ||
12 | + countDownDay: 0, | ||
13 | + countDownHour: 0, | ||
14 | + countDownMinute: 0, | ||
15 | + }, | ||
16 | + | ||
17 | + bindViewTap: function () { | ||
18 | + wx.navigateTo({ | ||
19 | + // url: '../logs/logs' | ||
20 | + }) | ||
8 | }, | 21 | }, |
9 | 22 | ||
23 | + | ||
24 | + | ||
10 | /** | 25 | /** |
11 | * 生命周期函数--监听页面加载 | 26 | * 生命周期函数--监听页面加载 |
12 | */ | 27 | */ |
13 | onLoad: function (options) { | 28 | onLoad: function (options) { |
14 | - | 29 | + this.setData({ |
30 | + windowHeight: wx.getStorageSync('windowHeight') | ||
31 | + }); | ||
15 | }, | 32 | }, |
16 | 33 | ||
17 | /** | 34 | /** |
18 | * 生命周期函数--监听页面初次渲染完成 | 35 | * 生命周期函数--监听页面初次渲染完成 |
19 | */ | 36 | */ |
20 | onReady: function () { | 37 | onReady: function () { |
21 | - | 38 | + var totalSecond = 1505540080 - Date.parse(new Date()) / 1000; |
39 | + | ||
40 | + var interval = setInterval(function () { | ||
41 | + // 秒数 | ||
42 | + var second = totalSecond; | ||
43 | + | ||
44 | + // 天数位 | ||
45 | + var day = Math.floor(second / 3600 / 24); | ||
46 | + var dayStr = day.toString(); | ||
47 | + if (dayStr.length == 1) dayStr = '0' + dayStr; | ||
48 | + | ||
49 | + // 小时位 | ||
50 | + var hr = Math.floor((second - day * 3600 * 24) / 3600); | ||
51 | + var hrStr = hr.toString(); | ||
52 | + if (hrStr.length == 1) hrStr = '0' + hrStr; | ||
53 | + | ||
54 | + // 分钟位 | ||
55 | + var min = Math.floor((second - day * 3600 * 24 - hr * 3600) / 60); | ||
56 | + var minStr = min.toString(); | ||
57 | + if (minStr.length == 1) minStr = '0' + minStr; | ||
58 | + | ||
59 | + // 秒位 | ||
60 | + var sec = second - day * 3600 * 24 - hr * 3600 - min * 60; | ||
61 | + var secStr = sec.toString(); | ||
62 | + if (secStr.length == 1) secStr = '0' + secStr; | ||
63 | + | ||
64 | + this.setData({ | ||
65 | + countDownDay: dayStr, | ||
66 | + countDownHour: hrStr, | ||
67 | + countDownMinute: minStr, | ||
68 | + countDownSecond: secStr, | ||
69 | + }); | ||
70 | + totalSecond--; | ||
71 | + if (totalSecond < 0) { | ||
72 | + clearInterval(interval); | ||
73 | + wx.showToast({ | ||
74 | + title: '活动已结束', | ||
75 | + }); | ||
76 | + this.setData({ | ||
77 | + countDownDay: '00', | ||
78 | + countDownHour: '00', | ||
79 | + countDownMinute: '00', | ||
80 | + countDownSecond: '00', | ||
81 | + }); | ||
82 | + } | ||
83 | + }.bind(this), 1000); | ||
84 | + | ||
22 | }, | 85 | }, |
23 | 86 | ||
24 | /** | 87 | /** |
-
请 注册 或 登录 后发表评论