// pages/complainAgent/complainAgent.js const app = getApp(); var Validator = require("../../utils/validate.tools.js"); const verify = Validator.Validator; Page({ /** * 页面的初始数据 */ data: { array: ['请选择性别','男', '女'], 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', disabled: false, appealInfo:{}, evalList: {}, }, inputChange: function (e) { var name = e.currentTarget.dataset.name; this.setData({ appealInfo: { ...this.data.appealInfo, [name]: e.detail.value } }) }, selectChange: function (e) { var name = e.currentTarget.dataset.name; this.setData({ appealInfo: { ...this.data.appealInfo, [name]: e.detail.value } }) }, onLoad: function(option) { this.setData({ urlStr: option.url, flag: option.flag || '', businessType: option.businessType }) if (option.disabled == 'true') { this.setData({ disabled: true }) } else { this.setData({ disabled: false }) } //接口 var openId = wx.getStorageSync("openId"); var that = this; wx.request({ url: app.globalData.url + '/api/v1/busPerson/find?busId=' + option.id + '&userType=1' + '&openId=' + openId + '&excess=申诉人', success: function (res) { if (res.data.code == '0') { var data = res.data.data; var attList = data.attList || []; var evalList1001 = app.where(attList, { type: 1001 }) || []; var evalList = { evalList1001 }; for (var i in evalList) { evalList[i] = evalList[i].map(({ imgPath: pic, attachmentId: id }) => ({ pic, id })) } that.setData({ appealInfo: data, status: option.status, evalList, id: data.id }) console.log(that.data.appealInfo) } else { wx.showModal({ title: '提示', content: "请求失败!" }) } } }) }, submit: function(e) { var userinfo = wx.getStorageSync("user"); var warn = ""; //弹框时提示的内容 var appealInfo = this.data.appealInfo; appealInfo.createId = userinfo.id; appealInfo.busType = this.data.businessType; appealInfo.age = parseInt(appealInfo.age); if (this.data.businessType) { appealInfo.stationType = parseInt(this.data.businessType); } if (!appealInfo.userName) { return app.showModal("请填写姓名!"); } if (!appealInfo.userSex) { return app.showModal("请选择性别!"); } if (!appealInfo.mobile) { return app.showModal("请填写手机号!"); }else{ if (!verify.phone(appealInfo.mobile)) { return app.showModal("手机号码格式不正确!") } } if (!appealInfo.address) { return app.showModal("请填写地址!"); } if (!appealInfo.cardNo) { return app.showModal("请填写身份证!"); }else{ if (!verify.carIdNumber(appealInfo.cardNo)) { return app.showModal("身份证格式不正确!") } } const { evalList1001 } = this.data.evalList; if (evalList1001.length == 0) { return app.showModal("请上传身份证证件"); } if (evalList1001.length < 2) { return app.showModal("请至少上传两张身份证附件!") } var that = this; wx.request({ url: app.globalData.url + '/api/v1/busPerson/save', data: appealInfo, method: 'POST', header: { "Content-Type": "application/json" }, success: function (res) { if (res.data.code == 0) { console.log(appealInfo) wx.navigateTo({ url: '..' + that.data.urlStr +'?icon1=true&id=' + appealInfo.busId + '&flag=' + that.data.flag, }) } } }) }, //添加图片 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 });//返回上一页 } })