newPunch.js
11.1 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/index/rank/rank.js
import request from '../../../api/request.js'
import moment from 'moment';
Page({
/**
* 页面的初始数据
*/
data: {
tempId: 0,
form: {
taskTitle: '', //任务标题
taskDesc: '', //任务描述内容
allowRepairCard: 2, //是否允许补卡 1是 2否
hasData: 2, //是否需要提交数据 1是 2否
// id: '', // 任务ID
lackNum: '', // 缺卡次数
remindTime: '', // 打卡提醒时间点
startDate: '', // 打卡开始时间
statisticsUnit: '', // 统计单位 hasData=1 时,必传
submitCondition: '', //提交包含条件:图片、视频、音频
taskCycle: '', //打卡周期
taskFileUrl: [], //任务文件(含多个)
taskFrequency: '', //打卡频次
userId: '', //所属用户ID
},
fileList: [],
//弹出层
//统计单位
unitShow: false,
columnsUnit: ['分钟', '小时', '个', '篇', '本', '张', '页', '次'],
//开始时间
startTimeShow: false,
columnsStartTime: ['9', '10', '11', '12'],
minDate: new Date().getTime(),
currentDate: new Date().getTime(),
formatter(type, value) {
if (type === 'year') {
return `${value}年`;
}
if (type === 'month') {
return `${value}月`;
}
return value;
},
//打卡周期
clockCycleShow: false,
columnsClockCycle: ['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', '40','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'],
//打卡频次
clockRateShow: false,
columnsClockRate: ['每天', '7天', '一个月'],
//打卡提醒
clockRemindShow: false,
columnsClockRemind: [
{
values: ['每天','周一', '周二', '周三', '周四', '周五', '周六', '周日'],
defaultIndex: 2,
},
// 第二列
{
values: ['5:00','6:00','7:00','8:00', '9:00', '10:00', '11:00', '12:00', '13:00', '14:00', '15:00', '16:00', '17:00', '18:00', '19:00', '20:00', '21:00', '22:00', '23:00', '24:00'],
defaultIndex: 1,
},
],
//打卡缺卡提醒
clockLackShow: false,
columnsClockLack: [1,2,3,4,5,6,7,8,9,10],
//必须包含
containShow: false,
columnsContain: ['无限制','图片'],
},
//获取模板详情 / 空模板
getDetail() {
if(this.data.tempId == 0) return
request({
url: `/wx/temp/getTempDetail`,
method: 'get',
data: {
"tempId": this.data.tempId,
},
}).then(res => {
if (res.code == 0) {
const data = res.data
this.setData({
'form.taskTitle': data.taskTitle
})
this.setData({
'form.taskDesc': data.taskDesc
})
this.setData({
'form.allowRepairCard': data.allowRepairCard
})
this.setData({
'form.hasData': data.hasData
})
this.setData({
'form.lackNum': data.lackNum
})
this.setData({
'form.remindTime': data.remindTime
})
this.setData({
'form.startDate': moment(new Date().getTime()).format('YYYY-MM-DD')
})
this.setData({
'form.statisticsUnit': data.statisticsUnit
})
this.setData({
'form.submitCondition': data.submitCondition
})
this.setData({
'form.taskCycle': data.taskCycle
})
this.setData({
'form.taskFileUrl': []
})
this.setData({
'form.taskFrequency': data.taskFrequency
})
} else {
wx.showToast({
title: res.msg,
icon: 'none',
duration: 1000
})
}
})
},
//输入
onfieldChange(e) {
this.setData({
'form.taskTitle': e.detail
})
},
//输入
onfieldDescChange(e) {
this.setData({
'form.taskDesc': e.detail
})
},
//开关
onSwitch(e) {
console.log(e)
this.setData({
'form.hasData': e.detail
})
},
onChange(e) {
console.log(e)
this.setData({
'form.allowRepairCard': e.detail
})
},
//文件上传
afterRead(event) {
const {
file
} = event.detail;
var that = this
// 当设置 mutiple 为 true 时, file 为数组格式,否则为对象格式
wx.uploadFile({
url: 'https://market.myjxt.com:51311/file/fileUpload', // 仅为示例,非真实的接口地址
filePath: file.url,
name: 'file',
formData: {
user: 'test'
},
success(res) {
// 上传完成需要更新 fileList
const {
fileList = []
} = that.data;
fileList.push({
...file,
url: res.data
});
console.log(res,fileList)
that.setData({
fileList
});
that.setData({
'form.taskFileUrl': fileList.map(v => v.url)
})
},
});
},
//删除
delFile(event) {
let [list,index] = [this.data.fileList,event.detail.index]
list.splice(index,1)
this.setData({
fileList:list
})
this.setData({
'form.taskFileUrl': this.data.fileList.map(v => v.url)
})
},
//开关
onswitchChange({
detail
}) {
this.setData({
'form.checked': detail
});
},
//创建
createTask() {
console.log(this.data.form)
if(this.data.form.hasData == 1 && !this.data.form.statisticsUnit) {
return wx.showToast({title: '请选择统计单位',icon: 'none',})
}
request({
url: `/wx/task/addCardTask`,
method: 'post',
data: this.data.form,
}).then(res => {
if (res.code == 0) {
wx.navigateTo({
url: '../../mine/record/record'
})
}else {
wx.showToast({
title: res.msg,
icon: 'none',
duration: 1000
})
}
})
},
/**
* 生命周期函数--监听页面加载
*/
onLoad(options) {
this.setData({
'form.userId': wx.getStorageSync('userInfo_id')
})
this.setData({
tempId: options.tempId
}, () => {
this.getDetail()
})
},
// 创建完成
handleCreate() {
// console.log(111)
wx.switchTab({
url: '/pages/index/index',
})
},
// 统一返回
handleBack() {
wx.navigateBack()
},
/**
* 用户点击右上角分享
*/
onShareAppMessage() {
},
/*
弹出层 - 统计单位
*/
openUnitShow() {
this.setData({
unitShow: true
})
},
closeUnitShow() {
this.setData({
unitShow: false
})
},
changeUnitShow(e) {
console.log(e)
this.setData({
'form.statisticsUnit': e.detail.value
})
this.setData({
unitShow: false
})
},
/*
弹出层 - 开始时间
*/
openStartTimeShow() {
this.setData({
startTimeShow: true
})
},
closeStartTimeShow() {
this.setData({
startTimeShow: false
})
},
changeStartTimeShow(e) {
let time = moment(e.detail).format('YYYY-MM-DD')
this.setData({
'form.startDate': time,
});
this.setData({
startTimeShow: false
})
},
/*
弹出层 - 打卡周期
*/
openClockCycleShow() {
this.setData({
clockCycleShow: true
})
},
closeClockCycleShow() {
this.setData({
clockCycleShow: false
})
},
changeClockCycleShow(e) {
this.setData({
'form.taskCycle': e.detail.value
})
this.setData({
clockCycleShow: false
})
},
/*
弹出层 - 打卡频次
*/
openClockRateShow() {
this.setData({
clockRateShow: true
})
},
closeClockRateShow() {
this.setData({
clockRateShow: false
})
},
changeClockRateShow(e) {
this.setData({
'form.taskFrequency': e.detail.value
})
this.setData({
clockRateShow: false
})
},
/*
弹出层 - 打卡提醒
*/
openClockRemindShow() {
this.setData({
clockRemindShow: true
})
},
closeClockRemindShow() {
this.setData({
clockRemindShow: false
})
},
changeClockRemindShow(e) {
this.setData({
'form.remindTime': e.detail.value[0] + '::' + e.detail.value[1]
})
this.setData({
clockRemindShow: false
})
},
/*
弹出层 - 打卡缺卡提醒
*/
openClockLackShow() {
this.setData({
clockLackShow: true
})
},
closeClockLackShow() {
this.setData({
clockLackShow: false
})
},
changeClockLackShow(e) {
this.setData({
'form.lackNum': e.detail.value
})
this.setData({
clockLackShow: false
})
},
/*
弹出层 - 必须包含
*/
openContainShow() {
this.setData({
containShow: true
})
},
closeContainShow() {
this.setData({
containShow: false
})
},
changeContainShow(e) {
this.setData({
'form.submitCondition': e.detail.value
})
this.setData({
containShow: false
})
},
})