const app = getApp();
|
var Validator = require("../../utils/validate.tools.js");
|
const verify = Validator.Validator;
|
Page({
|
data: {
|
array: ['男', '女'],
|
nations: ["汉族", "蒙古族", "回族", "藏族", "维吾尔族", "苗族", "彝族", "壮族", "布依族", "朝鲜族", "满族", "侗族", "瑶族", "白族", "土家族", "哈尼族", "哈萨克族", "傣族", "黎族", "傈僳族", "佤族", "畲族", "高山族", "拉祜族", "水族", "东乡族", "纳西族", "景颇族", "柯尔克孜族", "土族", "达斡尔族", "仫佬族", "羌族", "布朗族", "撒拉族", "毛南族", "仡佬族", "锡伯族", "阿昌族", "普米族", "塔吉克族", "怒族", "乌孜别克族", "俄罗斯族", "鄂温克族", "德昂族", "保安族", "裕固族", "京族", "塔塔尔族", "独龙族", "鄂伦春族", "赫哲族", "门巴族", "珞巴族", "基诺族"],
|
arrayDate: [],
|
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',
|
requestInfo: {},
|
disabled: false,
|
imgdisabled:false,
|
_button: true,
|
evalList: {},
|
excess: '',
|
},
|
|
inputChange: function (e) {
|
var name = e.currentTarget.dataset.name;
|
this.setData({
|
requestInfo: {
|
...this.data.requestInfo,
|
[name]: e.detail.value
|
}
|
})
|
},
|
|
selectChange: function (e) {
|
var name = e.currentTarget.dataset.name;
|
if (name === "userSex") {
|
this.setData({
|
requestInfo: {
|
...this.data.requestInfo,
|
"showUserSex": e.detail.value,
|
[name]: Number(e.detail.value) + 1
|
}
|
})
|
} else if (name === "userNation") {
|
this.setData({
|
requestInfo: {
|
...this.data.requestInfo,
|
'showUserNation': e.detail.value,
|
[name]: this.data.nations[e.detail.value]
|
}
|
})
|
} else {
|
this.setData({
|
requestInfo: {
|
...this.data.requestInfo,
|
[name]: e.detail.value
|
}
|
})
|
}
|
},
|
|
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=1' + '&openId=' + openId + '&excess=' + this.data.excess,
|
success: function (res) {
|
if (res.data.code == '0') {
|
var data = res.data.data;
|
if (data.userSex == 1 || data.userSex == 0 ) {
|
data.userSex = 1;
|
data.showUserSex = 0; //1为男,默认性别显示为男
|
} else {
|
data.showUserSex = 1;
|
}
|
data.userNation = data.userNation || '汉族';
|
data.birthday = data.birthday || '1985-01-01';
|
data.showUserNation = that.data.nations.findIndex(e => e == data.userNation);
|
var attList = data.attList || [];
|
var evalList1001 = attList.map(({
|
imgPath: pic,
|
attachmentId: id
|
}) => ({
|
pic,
|
id
|
}));
|
var evalList = { evalList1001 };
|
that.setData({
|
requestInfo: data,
|
evalList,
|
id: data.id
|
})
|
} else {
|
wx.showModal({
|
title: '提示',
|
content: "请求失败!"
|
})
|
}
|
}
|
})
|
},
|
|
submit: function (e) {
|
var userinfo = wx.getStorageSync("user");
|
var warn = ""; //弹框时提示的内容
|
var requestInfo = this.data.requestInfo;
|
console.log(requestInfo)
|
requestInfo.createId = userinfo.id;
|
requestInfo.busType = 10;
|
//判断的顺序依次是:姓名-手机号-地址-具体地址-预约日期-预约时间-开荒面积
|
if (!requestInfo.userName) {
|
return app.showModal("请填写姓名!");
|
}
|
if (!requestInfo.userSex) {
|
return app.showModal("请填写性别!");
|
}
|
if (!requestInfo.userBirthday) {
|
return app.showModal("请填写出生日期!");
|
}
|
if (!requestInfo.cardNo) {
|
return app.showModal("请填写身份证号码");
|
}
|
if (!requestInfo.userNation) {
|
return app.showModal("请填写民族");
|
}
|
if (!requestInfo.userJob) {
|
return app.showModal("请填写职业");
|
}
|
if (!requestInfo.address) {
|
return app.showModal("请填写现居住地");
|
}
|
if (!requestInfo.workPlace) {
|
return app.showModal("请填写工作单位!");
|
}
|
if (!requestInfo.mobile) {
|
return app.showModal("请填写手机号码!");
|
}
|
const { evalList1001 } = this.data.evalList;
|
if (evalList1001.length == 0) {
|
return app.showModal("请上传身份证证件");
|
}
|
if (evalList1001.length < 2) {
|
return app.showModal("请至少上传两张身份证附件!")
|
}
|
else{
|
if (!verify.carIdNumber(requestInfo.cardNo)) {
|
return app.showModal("身份证号码格式不正确!")
|
}
|
if (!verify.phone(requestInfo.mobile)) {
|
return app.showModal("手机号码格式不正确!")
|
}
|
if (requestInfo.email && !verify.email(requestInfo.email)) {
|
return app.showModal("电子邮箱格式不正确!")
|
}
|
}
|
var that = this;
|
wx.request({
|
url: app.globalData.url + '/api/v1/busPerson/save',
|
data: requestInfo,
|
method: 'POST',
|
header: {
|
"Content-Type": "application/json"
|
},
|
success: function (res) {
|
if (res.data.code == 0) {
|
wx.navigateTo({
|
url: '../compensation/compensation?icon2=true&id=' + requestInfo.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 });//返回上一页
|
}
|
|
})
|