const app = getApp() const util = require("../../../utils/util"); const api = require('../../../api/api.js'); const user = require('../../../utils/user.js'); // const update = require('../../../api/update.js'); import moment from 'moment' Page({ data: { activeTab:1, read:[],//8,9,10 问题工单 unread:[], // readFold:[], unReadFold:[], foldList:[], foldMsg:{ }, messageList:[ { type:1, text:'物损工单产生,请及时和站长沟通哦,请勿私自联系雇主哦,联系了就罚款,不服再罚,罚完不服再罚~', }, { type:2, text:'即将服务保洁2次新客,这是第N次服务,推荐客户复购4次/次/24次', } ], typeList: [ ], type: '', date: moment(new Date()).format('YYYY-MM'), currentDate: new Date().getTime(), minDate: new Date('2022-01-01').getTime(), pickerShow:false, }, /** * 生命周期函数--监听页面加载 */ onLoad: function (options) { this.selectComponent('#tabs').resize(); this.getTypeList(); }, getTypeList(){ util.request(api.getTypelist, { }, 'GET').then(res=> { if (res.errno === 0) { let list=res.data; let current=[]; list.forEach(item=>{ let obj={text:item.type,value:item.id}; current.push(obj); }); this.setData({ typeList:current, type:'' }); } }); }, dropdownChange(e){ let type=e.detail; this.setData({ type:type }); this.getNoticeList(); }, getNoticeList(){ util.request(api.getNotice, { type:this.data.type, yearMonth:this.data.date }, 'GET').then(res=> { if (res.errno === 0) { this.setData({ read:res.data.read, unRead:res.data.unRead, // readFold:res.data.readFold, unReadFold:res.data.unReadFold, foldList:this.data.activeTab==1?res.data.unReadFold:res.data.readFold, messageList:this.data.activeTab==1?res.data.unRead:res.data.read, }); if(this.data.activeTab==1){ this.setData({ foldMsg:this.data.unReadFold.length>0?this.data.unReadFold[0]:{} }); }else{ // this.setData({ // foldMsg:this.data.readFold.length>0?this.data.readFold[0]:{} // }); } } }); }, readNotice(e){ let id=e.currentTarget.dataset.id; util.request(api.readNotice, {id:id }, 'GET').then(res=> { if (res.errno === 0) { wx.showToast({ title: '操作成功' }); this.getNoticeList(); } }); }, onTabChange(e) { this.setData({ activeTab: e.detail.name, }); if (this.data.activeTab == 1) { this.setData({ messageList:this.data.unRead,foldList:this.data.unReadFold, foldMsg:this.data.unReadFold.length>0?this.data.unReadFold[0]:{} }); }else{ this.setData({ messageList:this.data.read, // foldList:this.data.readFold, // foldMsg:this.data.readFold.length>0?this.data.readFold[0]:{} }); } }, dateSelect(){ this.setData({ pickerShow:true }) }, onCancel(){ this.setData({ pickerShow:false }) }, onConfirm(e){ console.log(e); let date=moment(e.detail).format('YYYY-MM'); this.setData({ date:date, pickerShow:false }); this.getNoticeList(); }, goFeedback(e){ console.log(e); let feedback=e.currentTarget.dataset.feedback; let path=e.currentTarget.dataset.path; let id=e.currentTarget.dataset.id; if(feedback==1){ // 跳转到回执页面 // app.globalData.alertNoticeInfo=this.data.alertNoticeInfo; wx.navigateTo({ url: '/pages/upgrade/msgReceipt/msgReceipt?id='+id }); }else if(feedback!=1&&path==''){ if(this.data.activeTab==1){ // 调已读接口 util.request(api.readNotice, {id:id }, 'GET').then(res=> { if (res.errno === 0) { wx.showToast({ title: '操作成功', icon:'none' }) this.getNoticeList(); } }); }else{ } }else{ if(this.data.activeTab==1){ // 调已读接口 util.request(api.readNotice, {id:id }, 'GET').then(res=> { if (res.errno === 0) { // 跳转其他页面 wx.navigateTo({ url: path }); } }); }else{ // 跳转其他页面 wx.navigateTo({ url: path }); } } }, onReachBottom() { // if (this.data.totalPages > this.data.page) { // this.setData({ // page: this.data.page + 1 // }); // this.getGoodsList(); // } else { // wx.showToast({ // title: '没有更多商品了', // icon: 'none', // duration: 2000 // }); // return false; // } }, /** * 生命周期函数--监听页面初次渲染完成 */ onReady: function () { }, /** * 生命周期函数--监听页面显示 */ onShow: function () { this.getNoticeList(); }, onHide: function () { }, onUnload: function () { }, /** * 页面相关事件处理函数--监听用户下拉动作 */ onPullDownRefresh: function () { }, /** * 页面上拉触底事件的处理函数 */ onReachBottom: function () { }, /** * 用户点击右上角分享 */ onShareAppMessage: function () { }, })