var app = getApp() Page({ data: { src: app.globalData.imgUrl +'/image/bg.jpg', itemIcon: app.globalData.imgUrl +'/image/ceshi.jpg', icon: app.globalData.imgUrl +'/image/fzl.svg', user: app.globalData.imgUrl +'/image/user.svg', yes: app.globalData.imgUrl +'/image/yes.svg', add: app.globalData.imgUrl +'/image/add.svg', del: app.globalData.imgUrl +'/image/del.svg', id: '', icon1: false, disabled: false, evalList: {}, dataSet: {}, status: 0, auditOpinion: '' }, // 页面跳转 requestInfo: function() { wx.navigateTo({ url: '../complaintAdviceUserInfo/complaintAdviceUserInfo?' + 'disabled=' + this.data.disabled + '&id=' + this.data.id + '&status=' + this.data.status + '&url=' + '/junctionStation/junctionStation' + '&flag=' + this.data.flag + '&businessType=21' }) }, inputChange: function(e) { var name = e.currentTarget.dataset.name; this.setData({ dataSet: { ...this.data.dataSet, [name]: e.detail.value } }) }, onLoad: function(option) { var that = this; that.setData({ id: option.id, flag: option.flag }) var titleName = '', nameLabel = '', businessType; switch(option.flag){ case 'renda': titleName = '人大代表联络站'; nameLabel = '人大代表编号'; businessType = 4; break; case 'teyue': titleName = '特约检察员监督员联络站'; nameLabel = '特约检察员编号'; businessType = 3; break; case 'renmin': titleName = '人民监督员联络站'; nameLabel = '人民检查员编号'; businessType = 1; break; case 'zhengxie': titleName = '政协委员联络员联络站'; nameLabel = '政协委员编号'; businessType = 2; break; } that.setData({ titleName, nameLabel, businessType }) wx.setNavigationBarTitle({ title: titleName//页面标题为路由参数 }) wx.request({ url: app.globalData.url + '/api/liaisonStation/find?id=' + that.data.id, success: function(res) { if (res.data.code == 0) { var dataSet = res.data.data.LiaisonStation; var attList = dataSet.attList || []; var evalList1012 = app.where(attList, { associateType: 1012 }) || []; var evalList = { evalList1012, }; for (var i in evalList) { evalList[i] = evalList[i].map(({ imgPath: pic, attachmentId: id }) => ({ pic, id })) } var status =dataSet.status; var disabled = app.judgeDisable(status); that.setData({ dataSet, id: dataSet.id, icon1: res.data.data.icon1, evalList, showTime: app.formatDate(dataSet.createTime), disabled, status, auditOpinion: res.data.data.auditOpinion || '' }) } else { wx.showModal({ title: '提示', content: "请求失败!" }) } } }) }, submit: function(e) { var status = e.currentTarget.dataset.type; var userinfo = wx.getStorageSync("user"); var dataSet = this.data.dataSet; dataSet.createId = userinfo.id; dataSet.createrId = userinfo.id; dataSet.status = status; var title = ''; dataSet.businessType = this.data.businessType; if (status == 1) { if (!this.data.icon1) { return app.showModal("请填写个人信息!"); } if (!dataSet.name) { return app.showModal("请填写" + this.data.nameLabel +"!"); } if (!dataSet.title) { return app.showModal("请填写联系标题!"); } if (!dataSet.content) { return app.showModal("请填写联络内容!"); } const { evalList1012, } = this.data.evalList; if (evalList1012.length == 0) { return app.showModal("请上传相关材料!"); } } var that = this; wx.request({ url: app.globalData.url + '/api/liaisonStation/save', data: dataSet, method: 'POST', header: { "Content-Type": "application/json" }, success: function(res) { if (res.data.code == 0) { if (status == 0) { title = '保存草稿成功!'; } else { title = '提交成功!'; } wx.showToast({ title, icon: 'success', duration: 2000 }) setTimeout(function () { wx.reLaunch({ url: '../index/index', }) }, 2000) } else { wx.showModal({ title: '提示', content: "提交失败!" }) } } }) }, //添加图片 joinPicture: function(e) { var that = this; app.joinPicture(e, that) }, // 删除图片 clearImg: function(e) { var that = this; app.clearImg(e, that) }, //预览图片 previewImage: function(e) { app.previewImage(e) }, goback: function() { wx.navigateBack({ changed: true }); //返回上一页 } })