var app = getApp() var that; Page({ data: { list: [], parameter:{}, isData:true, }, onLoad(e) { that = this; this.setData({ parameter: JSON.parse(e.data), }) if(this.data.parameter.index=='1'){ dd.setNavigationBar({ title: "逾期任务" }); }else if(this.data.parameter.index=='2'){ dd.setNavigationBar({ title: "今日任务" }); }else if(this.data.parameter.index=='3'){ dd.setNavigationBar({ title: "进行中任务" }); }else{ dd.setNavigationBar({ title: "待审批任务" }); } }, onShow() { if(this.data.parameter.page==1){ this.opneWebSocket(); } }, activeA(e){ let item = e.target.dataset.item; let text=''; let users=[]; if(this.data.parameter.index=='1'){//拿执行者ID users.push(item.receiver.ding_user.user_id) text=`积分任务【 ${item.task_name} 】已经逾期啦,请尽快完成` } if(this.data.parameter.index=='4'){//拿审批者ID users.push(item.reviewer_ding_info.user_id) text=`${item.receiver.name}的积分任务【 ${item.task_name} 】还未审批,请及时处理` } dd.createDing({ users: users, //默认选中用户工号列表;类型: Array corpId: app.globalData.corpId, // 类型: String alertType: 2, // 钉发送方式 0:电话, 1:短信, 2:应用内;类型 Number alertDate: {"format":"yyyy-MM-dd HH:mm", "value":"2019-08-29 08:25"}, // 非必选,定时发送时间, 非定时DING不需要填写 type: 1,// 附件类型 1:image, 2:link;类型: Number // 非必选 // 附件信息 // attachment: { // images: ["https://www.baidu.com/img/bd_logo1.png?where=super"], // 图片附件, type=1时, 必选;类型: Array // image: "https://www.baidu.com/img/bd_logo1.png?where=super", // 链接附件, type=2时, 必选;类型: String // title: "这是一个测试", // 链接附件, type=2时, 必选;类型: String // url: "https://www.baidu.com/", // 链接附件, type=2时, 必选;类型 String // text: "测试发钉成功" // 链接附件, type=2时, 必选;类型: String // }, text: text, // 正文 bizType :0, // 业务类型 0:通知DING;1:任务;2:会议; // 任务信息 // bizType=1的时候选填 taskInfo: { ccUsers: ['100', '101'],// 抄送用户列表, 工号,类型: Array deadlineTime: {"format":"yyyy-MM-dd HH:mm", "value":"2015-05-09 08:00"}, // 任务截止时间 taskRemind: 30 // 任务提醒时间, 单位分钟;支持参数: 0:不提醒;15:提前15分钟;60:提前1个小时;180:提前3个小时;1440:提前一天;类型: Number }, // 日程信息 // bizType=2的时候选填 confInfo: { bizSubType: 0, // 子业务类型如会议: 0:预约会议, 1:预约电话会议, 2:预约视频会议;类型: Number (注: 目前只有会议才有子业务类型); location: '某某会议室', // 会议地点(非必选),类型: String startTime: {"format":"yyyy-MM-dd HH:mm", "value":"2015-05-09 08:00"},// 会议开始时间 endTime: {"format":"yyyy-MM-dd HH:mm", "value":"2015-05-09 08:00"},// 会议结束时间 remindMinutes: 30, // 会前提醒。单位分钟;1:不提醒, 0:事件发生时提醒, 5:提前5分钟, 15:提前15分钟, 30:提前30分钟, 60:提前1个小时, 1440:提前一天 remindType: 2 // 会议提前提醒方式;0:电话, 1:短信, 2:应用内;类型: Number }, success:function(res){ /* { "dingId": "1_1_a09f167xxx", "text": "钉正文内容", "result": true } */ }, fail:function(err){ } }) }, //上啦加载 onScrollToLower() { if (that.data.isData) { this.setData({ 'parameter.page':++this.data.parameter.page }) this.opneWebSocket(); } }, opneWebSocket() { dd.showLoading({ content: '加载中...', }); setTimeout(() => { dd.hideLoading(); }, 600) app.globalData.socketApi.sendData(this.data.parameter, this.onmessageWS); }, onmessageWS(e) { // 因为作用域问题,这个函数不能使用this if (e.type == 'task_statistics') { let result = e.result result.map(item => { item.date = that.timestampToTime(item.expire_time); item.pt_name=item.pt_id==3? 'B分':'A分' item.sub= that.formatSeconds(item.sub); }) // console.log(result) var list = that.data.list || []; that.setData({ list:that.data.parameter.page=='1'?result:list.concat(result), isData:result.length<100? false:true, }) } }, formatSeconds(value) { var theTime = parseInt(value);// 需要转换的时间秒 var theTime1 = 0;// 分 var theTime2 = 0;// 小时 var theTime3 = 0;// 天 if(theTime > 60) { theTime1 = parseInt(theTime/60); theTime = parseInt(theTime%60); if(theTime1 > 60) { theTime2 = parseInt(theTime1/60); theTime1 = parseInt(theTime1%60); if(theTime2 > 24){ //大于24小时 theTime3 = parseInt(theTime2/24); theTime2 = parseInt(theTime2%24); } } } var result = ''; // if(theTime > 0){ // result = ""+parseInt(theTime)+"秒"; // } // if(theTime1 > 0) { // result = ""+parseInt(theTime1)+"分"+result; // } if(theTime2 > 0) { result = ""+parseInt(theTime2)+"小时"+result; } if(theTime3 > 0) { result = ""+parseInt(theTime3)+"天"; } return result; }, timestampToTime(timestamp) { var date = new Date(timestamp * 1000);//时间戳为10位需*1000,时间戳为13位的话不需乘1000 var Y = date.getFullYear() + '-'; var M = (date.getMonth() + 1 < 10 ? '0' + (date.getMonth() + 1) : date.getMonth() + 1) + '-'; var D = date.getDate() + ' '; var h = date.getHours() + ':'; var m = date.getMinutes() + ':'; var s = date.getSeconds(); // return Y + M + D + h + m + s; return Y + M + D; }, activeItem(e) { var index = Number(e.detail.value)+1; var status = ""; if (index == 1) { status = "all" } else if (index == 2) { status = "on_time" } else if (index == 3) { status = "before" }else{ status = "over_due" } this.setData({ minuteIndex: e.detail.value, [`parameter.range`]:status }) // console.log(this.data.parameter) this.opneWebSocket() }, openDetail(e) { var id = e.target.dataset.item.id; dd.navigateTo({ url: '../../statistics/workDetail/workDetail?id=' + id }) }, });