reviewWordsDetail.js
7.5 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
// pages/MemorizingWords/reviewWordsDetail/reviewWordsDetail.js
const app = getApp();
var temdata_i=0;//动态加载开始天数
var temdata_i1 = 0;//动态加载结束天数
Page({
/**
* 页面的初始数据
*/
data: {
starttime:'',
endtime:'',
page:0,
pushdate:[],//动态加载开始的时间
pushdate1: [],//动态加载结束的时间
moudel:false,
Recitewords:'',//根据时间段所需背单词数
toView:''
},
//确定选择某时间段背的单词数
confirmWords(){
let that=this;
if (that.data.starttime==''){
wx.showToast({
title: '请选择开始时间',
icon: 'none',
duration: 2000,
})
} else if (that.data.endtime==''){
wx.showToast({
title: '请选择结束时间',
icon: 'none',
duration: 2000,
})
}else{
that.getTimeWords();
}
},
//获取复习界面信息(错词,模糊词)
getFuxiInfo(){
let that=this;
let url ='Words/getFuxiInfo';
let params={
token: wx.getStorageSync('token')
}
app.post(url,params).then((res)=>{
if(res.data.code==1){
that.setData({
listdata:res.data.data
})
}
})
},
//按时间共需复习单词数
getTimeWords(){
let that=this;
let url ='Words/getTimeWords';
let params={
token: wx.getStorageSync('token'),
start_time: that.data.starttime,
end_time: that.data.endtime
}
app.post(url,params).then((res)=>{
if(res.data.code==1){
if (parseInt(res.data.data.total_num)>0){
that.setData({
moudel: true,
Recitewords: res.data.data.total_num
})
}else{
wx.showToast({
title: '没有错词请重新选择',
icon: 'none',
duration: 2000,
})
}
}
}).catch((errMsg)=>{
console.log(errMsg)
})
},
setmoudel_no(){
let that=this;
that.setData({
moudel:false,
starttime: '',
endtime: '',
})
},
setmoudel_yes(){
let that = this;
that.setData({
moudel: true
})
},
voidfun(){
},
gowordsDetail_review(e){
let that=this;
let id=e.currentTarget.id;
if(id=='-1'){
wx.showToast({
title: '暂无错词,不需要复习',
icon: 'none',
duration: 2000,
})
}else{
wx.navigateTo({
url: '../wordsDetail_review/wordsDetail_review?id=' + id + '&starttime=' + that.data.starttime + '&endtime=' + that.data.endtime,
success: function (res) { },
fail: function (res) { },
complete: function (res) { },
})
}
},
//开始:根据年月日获取(星期等信息)////later=0 当前 later=1明天 later=2后天...
dateLater(later) {
let that=this;
let pushdate = that.data.pushdate;
let dateObj = {};
let date = new Date();
date.setDate(date.getDate() + later);
let timestamp = Date.parse(date);
dateObj.dataday = date.getFullYear() + '-' + ((date.getMonth() + 1) < 10 ? ("0" + (date.getMonth() + 1)) : date.getMonth() + 1) + '-' + (date.getDate() < 10 ? ("0" + date.getDate()) : date.getDate());
if (later==0){
dateObj.state = true;
that.setData({
toView: 'date' + dateObj.dataday,
starttime: dateObj.dataday,
endtime: dateObj.dataday,
})
}else{
dateObj.state = false;
}
dateObj.timestamp = timestamp;
pushdate.push(dateObj);
that.setData({
pushdate: pushdate,
})
temdata_i++;
},
//开始:动态加载时间
loaddate(){
let that=this;
that.dateLater(temdata_i);
},
//开始:
setstarcell(e){
let that=this;
let index = parseInt(e.currentTarget.dataset.index);
let pushdate = that.data.pushdate;
let pushdate1 = that.data.pushdate1;
let starttime = pushdate[index].dataday;
for (let i in pushdate){
pushdate[i].state=false;
if (i == index){
pushdate[i].state = true;
}
}
for (let obj of pushdate1){
obj.state = false;
if (starttime == obj.dataday){
obj.state=true;
}
}
that.setData({
pushdate: pushdate,
pushdate1: pushdate1,
starttime: starttime,
endtime: starttime,
toView: 'date' + pushdate[index].dataday
})
},
//结束:根据年月日获取(星期等信息)////later=0 当前 later=1明天 later=2后天...
dateLater1(later) {
let that = this;
let pushdate1 = that.data.pushdate1;
let dateObj = {};
let date = new Date();
date.setDate(date.getDate() + later);
let timestamp = Date.parse(date);
dateObj.dataday = date.getFullYear() + '-' + ((date.getMonth() + 1) < 10 ? ("0" + (date.getMonth() + 1)) : date.getMonth() + 1) + '-' + (date.getDate() < 10 ? ("0" + date.getDate()) : date.getDate());
if (later == 0) {
dateObj.state = true;
} else {
dateObj.state = false;
}
dateObj.timestamp = timestamp;
pushdate1.push(dateObj);
that.setData({
pushdate1: pushdate1,
})
temdata_i1++;
},
//结束动态加载时间
loaddate1() {
let that = this;
that.dateLater1(temdata_i1);
},
//结束
setstarcell1(e) {
let that = this;
let starttimestamp=''//选中开始时间搓
let endttimestamp = e.currentTarget.dataset.timestamp//选中结束时间搓
let endtime = that.data.endtime;
let index = parseInt(e.currentTarget.dataset.index);
let pushdate1 = that.data.pushdate1;
let pushdate = that.data.pushdate;
for (let obj of pushdate){
if (obj.state){
starttimestamp = obj.timestamp
}
}
if (starttimestamp==''){
wx.showToast({
title: '请选择开始时间',
icon: 'none',
duration: 2000,
})
} else if (starttimestamp > endttimestamp){
wx.showToast({
title: '结束时间应该大于开始时间',
icon: 'none',
duration: 2000,
})
}
else{
for (let i in pushdate1) {
pushdate1[i].state = false;
if (i == index) {
pushdate1[i].state = true;
endtime = pushdate1[i].dataday
}
}
that.setData({
pushdate1: pushdate1,
endtime: endtime
})
}
},
/**
* 生命周期函数--监听页面加载
*/
onLoad: function (options) {
let that=this;
that.setData({
page:options.page,
pushdate:[],
pushdate1: [],
})
that.getFuxiInfo();
temdata_i = 0;//动态加载开始天数
temdata_i1 = 0;//动态加载结束天数
if (options.page==1){
for(var i=0;i<8;i++){
that.dateLater(temdata_i);
that.dateLater1(temdata_i1);
}
}
},
/**
* 生命周期函数--监听页面初次渲染完成
*/
onReady: function () {
},
/**
* 生命周期函数--监听页面显示
*/
onShow: function (options) {
let that = this;
that.getFuxiInfo();
// if (options.page == 1) {
// for (var i = 0; i < 8; i++) {
// that.dateLater(temdata_i);
// that.dateLater1(temdata_i1);
// }
// }
},
/**
* 生命周期函数--监听页面隐藏
*/
onHide: function () {
},
/**
* 生命周期函数--监听页面卸载
*/
onUnload: function () {
},
/**
* 页面相关事件处理函数--监听用户下拉动作
*/
onPullDownRefresh: function () {
},
/**
* 页面上拉触底事件的处理函数
*/
onReachBottom: function () {
},
/**
* 用户点击右上角分享
*/
onShareAppMessage: function () {
}
})