parentsDetail.js
10.6 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
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
// pages/parentsDetail/parentsDetail.js
const app = getApp();
var mytime = null; //录音文件的时间
var moneytime = null; //录音文件的时间
Page({
/**
* 页面的初始数据
*/
data: {
showModel: false,
audioinit: 0,
myaudio: '',
ztime: 0,
qid: 0,
model:true,
list:[],
niceList:[]
},
/**
* 生命周期函数--监听页面加载
*/
onLoad: function(options) {
console.log(options)
wx.showLoading({
title: '加载中',
})
this.setData({
id: options.id,
classid: options.classId
});
this.contentFun();
this.innerAudioContext = wx.createInnerAudioContext();
this.innerAudioContext.onError((res) => {
console.log(res);
// that.tip("播放录音失败!")
})
this.youxiuArt()
},
youxiuArt(){
let url = '/api/teacher/nice_list',t=this;
let params = {
homework_id: this.data.id,
class_id: this.data.classid
}
app.post(url,params).then(r=>{
r.data.msg.forEach(function (item, ind) {
let dir = t.formatDuringtwo(item.s);
item['duration'] = item.s;
item.play = false
// item['imagesd'] = '/image/30.png';
})
t.setData({
niceList: r.data.msg
})
})
},
// 预览图片
yuFun(e) {
var t = this;
console.log(e)
// console.log(t.data.comments)
var current = e.currentTarget.dataset.src;
let list = e.currentTarget.dataset.item;
wx.previewImage({
current: current, // 当前显示图片的http链接
urls: list // 需要预览的图片http链接列表
})
},
yuFun2(e) {
let img = e.currentTarget.dataset.img;
wx.previewImage({
current: img,
urls: this.data.obj.images
})
},
// 前往视频页面
goVideo(e) {
let t = this;
let src = e.currentTarget.dataset.src;
console.log(src)
wx.navigateTo({
url: '/pages/video/video?src=' + src,
})
},
// 播放音频
playArtaudio(e) {
let t = this;
let src = e.currentTarget.dataset.src;
let dir = e.currentTarget.dataset.dir;
let index = e.currentTarget.dataset.index;
console.log(dir);
t.innerAudioContext.src = src;
t.innerAudioContext.play()
if (t.data.audioinit == 0) {
moneytime = dir;
}
mytime = dir;
console.log(moneytime)
t.innerAudioContext.src = src;
t.innerAudioContext.play()
if (t.data.ztime) {
var timeclone = setInterval(function () {
if (t.data.ztime) {
clearInterval(timeclone)
return
}
moneytime -= 1000;
if (moneytime < 0) {
t.data.niceList[index].play = false
t.setData({
qid: 0,
niceList:niceList
})
}
if (moneytime < -500) {
clearInterval(timeclone)
moneytime = mytime
}
t.setData({
'myaudio.duration': t.formatDuringtwo(moneytime),
})
}, 1000)
} else {
if (mytime > moneytime) {
} else {
var timeclone = setInterval(function () {
if (t.data.ztime) {
clearInterval(timeclone)
return
}
moneytime -= 1000;
if (moneytime < 0) {
t.data.niceList[index].play = false
t.setData({
niceList:niceList
})
}
if (moneytime < -500) {
clearInterval(timeclone)
moneytime = mytime
}
t.setData({
'myaudio.duration': t.formatDuringtwo(moneytime),
})
}, 1000)
}
}
t.data.niceList[index].play = true
t.setData({
ztime: 0,
niceList: t.data.niceList
})
},
pauseArtaudio(e) {
let that = this;
let src = e.currentTarget.dataset.src;
let dir = e.currentTarget.dataset.dir;
let index = e.currentTarget.dataset.index;
that.innerAudioContext.src = src;
that.innerAudioContext.pause()
this.data.niceList[index].play = false
that.setData({
'myaudio.duration': that.formatDuringtwo(moneytime),
niceList: this.data.niceList,
ztime: 1,
audioinit: 1
})
},
// 作业内容接口
contentFun(){
let t = this;
let url = '/api/StudentWoke/wokeInfo';
let params = {
id: t.data.id
};
app.post(url,params).then(res=>{
console.log(res);
t.setData({
content:res.data.msg
});
t.detailFun();
})
},
// 数据接口
detailFun() {
let t = this;
let url = '/api/StudentWoke/successinfo';
let params = {
id: t.data.id,
class_id: t.data.classid
};
app.post(url, params).then(res => {
console.log(res);
let dir = t.formatDuringtwo(res.data.msg.s);
res.data.msg['duration'] = res.data.msg.s;
wx.hideLoading()
t.setData({
list: res.data.msg
});
})
},
//点击删除出现弹框
removeFun(e) {
let status = e.currentTarget.dataset.status,that = this;
status == 0?wx.showToast({
title: '作业已过期不可删除',
icon:'none'
}) : (that.data.list.is || this.data.list.tall.length > 0 ? wx.showToast({
title: '作业已审批不可删除',
icon: 'none'
}) : this.setData({
showModel: true
}))
},
// 取消弹框
maskNo() {
this.setData({
showModel: false
})
},
// 确定弹框
maskOk() {
let t = this;
let url = '/api/StudentWoke/delete';
let params = {
id:t.data.id,
class_id: t.data.classid
};
app.post(url,params).then(res=>{
console.log(res);
this.setData({
showModel: false
});
wx.redirectTo({
url: '/pages/parentsDo/parentsDo',
})
})
},
// 播放音频
playaudio(e) {
let t = this;
let src = e.currentTarget.dataset.src;
let dir = e.currentTarget.dataset.dir;
let index = e.currentTarget
t.innerAudioContext.src = src;
t.innerAudioContext.play()
if (t.data.audioinit == 0) {
moneytime = dir;
}
mytime = dir;
t.innerAudioContext.src = src;
t.innerAudioContext.play()
if (t.data.ztime) {
var timeclone = setInterval(function() {
if (t.data.ztime) {
clearInterval(timeclone)
return
}
moneytime -= 1000;
if (moneytime < 0) {
t.setData({
qid: 0
})
}
if (moneytime < -500) {
clearInterval(timeclone)
moneytime = mytime
}
t.setData({
'myaudio.duration': t.formatDuringtwo(moneytime),
})
}, 1000)
} else {
if (mytime > moneytime) {
} else {
var timeclone = setInterval(function() {
if (t.data.ztime) {
clearInterval(timeclone)
return
}
moneytime -= 1000;
if (moneytime < 0) {
t.setData({
qid: 0
})
}
if (moneytime < -500) {
clearInterval(timeclone)
moneytime = mytime
}
t.setData({
'myaudio.duration': t.formatDuringtwo(moneytime),
})
}, 1000)
}
}
t.setData({
ztime: 0,
qid: 1
})
},
/**
* 暂停音频
*/
pauseaudio(e) {
let that = this;
let src = e.currentTarget.dataset.src;
let dir = e.currentTarget.dataset.dir;
that.innerAudioContext.src = src;
that.innerAudioContext.pause()
that.setData({
'myaudio.duration': that.formatDuringtwo(moneytime),
qid: 0,
ztime: 1,
audioinit: 1
})
},
//时间转换
formatDuringtwo(mss) {
var days = parseInt(mss / (1000 * 60 * 60 * 24));
var hours = parseInt((mss % (1000 * 60 * 60 * 24)) / (1000 * 60 * 60));
var minutes = parseInt((mss % (1000 * 60 * 60)) / (1000 * 60));
var min = minutes.toString().length == 1 ? '0' + minutes : minutes;
var seconds = Math.round((mss % (1000 * 60)) / 1000);
var sec = seconds.toString().length == 1 ? '0' + seconds : seconds;
return min + ":" + sec + '"';
},
// 预览图片
// yuFun(e) {
// var t = this;
// var current = e.currentTarget.dataset.src;
// wx.previewImage({
// current: current, // 当前显示图片的http链接
// urls: t.data.list.pigai_images // 需要预览的图片http链接列表
// })
// },
preview(e){
var t = this;
var current = e.currentTarget.dataset.src;
wx.previewImage({
current: current, // 当前显示图片的http链接
urls: t.data.content.images // 需要预览的图片http链接列表
})
},
// 视频预览
goVideo(e){
let t = this;
let src = e.currentTarget.dataset.src;
wx.navigateTo({
url: '/pages/video/video?src=' + src,
})
},
/**
* 生命周期函数--监听页面初次渲染完成
*/
onReady: function() {
},
/**
* 生命周期函数--监听页面显示
*/
onShow: function() {
},
/**
* 生命周期函数--监听页面隐藏
*/
onHide: function() {
},
/**
* 生命周期函数--监听页面卸载
*/
onUnload: function() {
this.innerAudioContext.pause()
},
/**
* 页面相关事件处理函数--监听用户下拉动作
*/
onPullDownRefresh: function() {
},
/**
* 页面上拉触底事件的处理函数
*/
onReachBottom: function() {
},
/**
* 用户点击右上角分享
*/
onShareAppMessage: function() {
}
})