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', agentInfo: {}, disabled: false, imgdisabled:false, _button: true, evalList: {}, excess: '' }, inputChange: function(e) { var name = e.currentTarget.dataset.name; this.setData({ agentInfo: { ...this.data.agentInfo, [name]: e.detail.value } }) }, selectChange: function(e) { var name = e.currentTarget.dataset.name; this.setData({ agentInfo: { ...this.data.agentInfo, "showCardType": e.detail.value, [name]: Number(e.detail.value) + 1 } }) }, back: function(e) { wx.navigateBack({ changed: true }); }, onLoad: function(option) { var excess = option.excess; if (excess == "请求人") { excess = "申诉人" } this.setData({ excess, status: option.status }) if (option.disabled == 'true') { this.setData({ disabled: true }) } else { this.setData({ disabled: false }) } if (option.imgdisabled == 'true') { this.setData({ imgdisabled: true }) } else { this.setData({ imgdisabled: false }) } //接口 var openId = wx.getStorageSync("openId"); var that = this; wx.request({ url: app.globalData.url + '/api/v1/busPerson/find?busId=' + option.id + '&userType=2' + '&openId=' + openId + '&excess=' + this.data.excess, success: function(res) { if (res.data.code == '0') { var data = res.data.data; var attList = data.attList || []; // if (data.attList){ var evalList1002 = app.where(attList, { type: 1002 }) || []; var evalList1003 = app.where(attList, { type: 1003 }) || []; var evalList1004 = app.where(attList, { type: 1004 }) || []; var evalList1005 = app.where(attList, { type: 1005 }) || []; var evalList = { evalList1002, evalList1003, evalList1004, evalList1005 }; for (var i in evalList) { evalList[i] = evalList[i].map(({ imgPath: pic, attachmentId: id }) => ({ pic, id })) } if (data.cardType == 1 || data.cardType == 0) { data.showCardType = 0 //身份证 默认显示 } else { data.showCardType = 1 //律师证 } that.setData({ agentInfo: data, evalList, id: data.id }) } else { wx.showModal({ title: '提示', content: "请求失败!" }) } } }) }, submit: function(e) { var userinfo = wx.getStorageSync("user"); var agentInfo = this.data.agentInfo; agentInfo.createId = userinfo.id; agentInfo.busType=10; if (!agentInfo.userName) { return app.showModal("请填写姓名/单位名称!"); } if (!agentInfo.cardNo) { return app.showModal("请填写证件号码!"); } if (!agentInfo.workPlace) { return app.showModal("请填写工作单位!"); } const { evalList1002, evalList1003, evalList1004, evalList1005 } = this.data.evalList; if (evalList1002.length == 0) { return app.showModal("请上传律师执业证书!"); } if (evalList1003.length == 0) { return app.showModal("请上传律师事务所证明!"); } if (evalList1004.length == 0 && evalList1005.length == 0) { return app.showModal("请上传授权委托书或者法律援助公函!"); } else { if (agentInfo.cardType == 0 || agentInfo.cardType == 1) { console.log('没选择类型或者选了身份证') agentInfo.cardType = 1; if (!verify.carIdNumber(agentInfo.cardNo)) { return app.showModal("证件号码格式不正确!") } } } var that = this; wx.request({ url: app.globalData.url + '/api/v1/busPerson/save', data: agentInfo, method: 'POST', header: { "Content-Type": "application/json" }, success: function (res) { if (res.data.code == 0) { wx.navigateTo({ url: '../compensation/compensation?icon2=true&id=' + agentInfo.busId + "&name=" + that.data.excess, }) } } }) }, //添加图片 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 });//返回上一页 } })