const app = getApp(); var Validator = require("../../utils/validate.tools.js"); const verify = Validator.Validator; Page({ /** * 页面的初始数据 */ data: { array: ['请选择性别', '男', '女'], nations: ['请选择民族', "汉族", "蒙古族", "回族", "藏族", "维吾尔族", "苗族", "彝族", "壮族", "布依族", "朝鲜族", "满族", "侗族", "瑶族", "白族", "土家族", "哈尼族", "哈萨克族", "傣族", "黎族", "傈僳族", "佤族", "畲族", "高山族", "拉祜族", "水族", "东乡族", "纳西族", "景颇族", "柯尔克孜族", "土族", "达斡尔族", "仫佬族", "羌族", "布朗族", "撒拉族", "毛南族", "仡佬族", "锡伯族", "阿昌族", "普米族", "塔吉克族", "怒族", "乌孜别克族", "俄罗斯族", "鄂温克族", "德昂族", "保安族", "裕固族", "京族", "塔塔尔族", "独龙族", "鄂伦春族", "赫哲族", "门巴族", "珞巴族", "基 诺族" ], userType: ['普通用户', '律师', '人大代表', '政协委员', '人民监督员', '特约检察员'], 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', peopleInfo: {}, evalList: {}, url: '', id: '' }, inputChange: function(e) { var name = e.currentTarget.dataset.name; if (name == 'idcard') { var birthday = app.IdCard(e.detail.value, 1); var wxSex = app.IdCard(e.detail.value, 2); this.setData({ peopleInfo: { ...this.data.peopleInfo, [name]: e.detail.value, birthday: birthday, wxSex: wxSex } }) } else { this.setData({ peopleInfo: { ...this.data.peopleInfo, [name]: e.detail.value } }) } }, selectChange: function(e) { var name = e.currentTarget.dataset.name; this.setData({ peopleInfo: { ...this.data.peopleInfo, [name]: e.detail.value } }) }, onLoad: function(option) { this.setData({ url: decodeURIComponent(option.url), }) console.log(this.data.url) //接口 var openId = wx.getStorageSync("openId"); var that = this; wx.request({ url: app.globalData.url + '/api/ma/user/findByOpenId?openId=' + openId, success: function(res) { if (res.data.code == '0') { var data = res.data.data; if (data.idcard) { if (!data.birthday) { data.birthday = app.IdCard(data.idcard, 1); } if (!data.wxSex) { data.wxSex = app.IdCard(data.idcard, 2); } } else { data.birthday = '1985-01-01' } if (data.nation == "0") { data.nation = 0; } else { data.nation = that.data.nations.findIndex(e => e == data.nation); } if (!data.userType) { data.userType = 0 } var attList = data.attachments || []; var evalList1001 = app.where(attList, { associateTypeId: 1001 }) || []; var evalList1002 = app.where(attList, { associateTypeId: 1002 }) || []; var evalList1018 = app.where(attList, { associateTypeId: 1018 }) || []; var evalList = { evalList1001, evalList1002, evalList1018 } for (var i in evalList) { evalList[i] = evalList[i].map(({ path: pic, id: id }) => ({ pic, id })) } that.setData({ peopleInfo: data, evalList, id: data.id }) } else { wx.showModal({ title: '提示', content: "请求失败!" }) } } }) }, submit: function(e) { var userinfo = wx.getStorageSync("user"); var peopleInfo = this.data.peopleInfo; var { evalList1001, evalList1002, evalList1018 } = this.data.evalList; if (!peopleInfo.userName) { return app.showModal("请填写姓名!"); } if (!peopleInfo.mobile) { return app.showModal("请填写手机号码!") } else { if (!verify.phone(peopleInfo.mobile)) { return app.showModal("手机号码格式不正确!") } } if (!peopleInfo.wxSex) { return app.showModal("请填写性别!"); } if (peopleInfo.nation == 0) { return app.showModal("请填写民族!"); } if (!peopleInfo.birthday) { return app.showModal("请填写出生日期!"); } if (!peopleInfo.idcard) { return app.showModal("请填写身份证号!"); } else { if (!verify.carIdNumber(peopleInfo.idcard)) { return app.showModal("身份证格式不正确!") } } if (!peopleInfo.address) { return app.showModal("请填写现居住地!") } if (!peopleInfo.bornAddress) { return app.showModal("请填写户籍所在地!") } if (peopleInfo.email) { if (!verify.email(peopleInfo.email)) { return app.showModal("电子邮箱格式不正确!") } } if (peopleInfo.nation) { peopleInfo.nation = this.data.nations[peopleInfo.nation] } if (evalList1001.length == 0) { return app.showModal("请上传身份证附件!") } if (evalList1001.length < 2) { return app.showModal("请至少上传两张身份证附件!") } if (peopleInfo.userType > 1) { if (!(peopleInfo.userType && peopleInfo.userTypeId && evalList1018.length > 0)) { return app.showModal("监督员信息不完整!") } } if (peopleInfo.userType == 1) { if (!(peopleInfo.lawyerOffice && peopleInfo.lawyerNo && evalList1002.length > 0)) { return app.showModal("律师信息不完整!") } } var that = this; wx.request({ url: app.globalData.url + '/api/ma/user/supplement', data: peopleInfo, method: 'POST', header: { "Content-Type": "application/json" }, success: function(res) { if (res.data.code == 0) { wx.showToast({ title: '提交成功!', icon: 'success' }, wx.navigateTo({ url: that.data.url, })) } 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 }); //返回上一页 } })