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,
|
_button: true,
|
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,
|
"showUserSex": e.detail.value,
|
[name]: Number(e.detail.value) + 1
|
}
|
})
|
|
},
|
|
onLoad: function (option) {
|
var excess = option.excess;
|
if (excess === "信访人") {
|
excess = "申诉人"
|
}
|
this.setData({
|
excess: excess
|
})
|
|
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=2' + '&openId=' + openId + '&excess=' + this.data.excess,
|
success: function (res) {
|
if (res.data.code == '0') {
|
var data = res.data.data;
|
if (data.userSex == 1) {
|
data.showUserSex = 0;
|
} else {
|
data.showUserSex = 1;
|
}
|
|
that.setData({
|
agentInfo: data,
|
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 = 14;
|
|
if (!agentInfo.userName) {
|
return app.showModal("请填写姓名!");
|
}
|
if (!agentInfo.mobile) {
|
return app.showModal("请填写手机号码!");
|
}
|
if (!agentInfo.cardNo) {
|
return app.showModal("请填写身份证号码");
|
}
|
if (!agentInfo.address) {
|
return app.showModal("请填写地址!");
|
}else{
|
if (!verify.phone(agentInfo.mobile)) {
|
return app.showModal("手机号码格式不正确!")
|
}
|
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: '../petitionLetters/petitionLetters?icon1=true&id=' + agentInfo.busId,
|
})
|
}
|
}
|
})
|
},
|
|
goback: function () {
|
wx.navigateBack({ changed: true });//返回上一页
|
}
|
|
})
|