123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278 |
- 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 () {
- },
-
- })
|