MemorizingWords.js
4.4 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
// pages/MemorizingWords/MemorizingWords.js
const app=getApp();
Page({
/**
* 页面的初始数据
*/
data: {
page: 0,//0表示没有计划显示词包,1有计划显示计划
wordspackage:[],//词包
reciteInfo:[],//背诵信息
swiper_index:1,//当前swiper_index滑块
next_margin:'60rpx',//后边距
previous_margin:'60rpx',//前边距
circular:true,
},
//词包详情
wordsPackgeDetail(e) {
let that=this;
wx.navigateTo({
url: '../MemorizingWords/wordsPackage/wordsPackage?id=' + e.currentTarget.id,
})
},
//修改计划
editPlan(){
let that=this;
let days = that.data.reciteInfo.days;
let wordspackageid = that.data.reciteInfo.package_id;
let everyday_words = that.data.reciteInfo.everyday_words;
wx.navigateTo({
url: '../MemorizingWords/wordsPlan/wordsPlan?wordspackageid=' + wordspackageid + '&days=' + days + '&wordnum=' + everyday_words,
success: function(res) {},
fail: function(res) {},
complete: function(res) {},
})
},
//修改词包
editwordspage(){
let that=this;
let reciteInfo = that.data.reciteInfo;
let package_id = reciteInfo.package_id;//词包Id
let wordspackage = that.data.wordspackage;
let swiper_index = that.data.swiper_index;
for (let i in wordspackage){
if (wordspackage[i].id == package_id){
wordspackage[i].jindu = reciteInfo.jindu;
swiper_index=i;
}
}
wx.setStorageSync('ifeidtwordpackage',true);
that.setData({
page:0,
wordspackage: wordspackage,
swiper_index: swiper_index
})
},
//搜索页
searchPage() {
wx.navigateTo({
url: '../../pages/index/goldArticleSearch/goldArticleSearch?type='+2,
})
},
//开始背单词
startWords() {
wx.navigateTo({
url: '../MemorizingWords/wordsDetail/wordsDetail',
})
},
//复习跳转
review() {
wx.navigateTo({
url: '../MemorizingWords/reviewWords/reviewWords',
})
},
//单词报告
wordReport() {
wx.navigateTo({
url: '../MemorizingWords/wordsReport/wordsReport',
})
},
//判断是否有计划
getjudge(){
let that=this;
let url = 'Words/ifHasPlan';
let params={
token:wx.getStorageSync('token')
};
app.post(url,params).then((res)=>{
if(res.data.code==1){
if(res.data.data==0){
that.setData({
page:0
})
that.getPackage();
} else{
that.setData({
page: 1
})
that.getReciteInfo();
}
}
}).catch((errMsg)=>{
console.log(errMsg)
})
},
//获取全部词包
getPackage(){
let that=this;
let reciteInfo = that.data.reciteInfo;
let package_id = reciteInfo.package_id;//词包Id
let url ='Words/getPackage';
app.post(url,{}).then((res)=>{
if(res.data.code==1){
let wordspackage=res.data.data;
for (let obj of res.data.data){
if (obj.id == package_id){
obj.jindu = reciteInfo.jindu
}else{
obj.jindu = '0%'
}
}
that.setData({
wordspackage: wordspackage
})
}
}).catch((errMsg)=>{
})
},
//获取背单词页面数据
getReciteInfo() {
let that=this;
let url ='Words/getReciteInfo';
let params={
token: wx.getStorageSync('token')
}
app.post(url,params).then((res)=>{
if(res.data.code==1){
that.setData({
reciteInfo:res.data.data
})
}
}).catch((errMsg)=>{
console.log(errMsg)
})
},
/**
* 生命周期函数--监听页面加载
*/
onLoad: function(options) {
let that=this;
that.getjudge();
that.getPackage();
that.getReciteInfo();
},
/**
* 生命周期函数--监听页面初次渲染完成
*/
onReady: function() {
},
/**
* 生命周期函数--监听页面显示
*/
onShow: function() {
let that = this;
that.getjudge();
that.getReciteInfo();
},
/**
* 生命周期函数--监听页面隐藏
*/
onHide: function() {
},
/**
* 生命周期函数--监听页面卸载
*/
onUnload: function() {
},
/**
* 页面相关事件处理函数--监听用户下拉动作
*/
onPullDownRefresh: function() {
},
/**
* 页面上拉触底事件的处理函数
*/
onReachBottom: function() {
},
/**
* 用户点击右上角分享
*/
onShareAppMessage: function() {
}
})