// pages/apply/applyperson.js
//获取应用实例
var app = getApp();
var util = require('../../utils/util.js');
var inputContent = {};//输入内容
import WxValidate from '../../utils/validate'
Page({
data: {
isLogin: util.isLogin(),
date: new Date().Format("yyyy-MM-dd"),
entranceDate: new Date().Format("yyyy"),
credentialsIndex: 0,
credentials: ["身份证", "台湾居民往来大陆通行证", "港澳居民往来大陆通行证", "军人证件", "护照"],
nationIndex: 0,
nation: ["汉", "蒙古", "回", "藏", "维吾尔", "苗", "彝", "壮", "布依", "朝鲜", "侗", "瑶", "白", "土家", "哈尼", "哈萨克", "傣", "黎", "其他"],//民族
professionIndex: 0,
profession: ["学生", "事业单位负责人", "企业负责人", "军人", "不便分类的其他从业人员", "失业(含待业及无业人员)", "其他专业技术人员", "行政办公人员", "医疗卫生辅助服务人员", "社会服务和居民生活服务人员", "其他行业"],
cultureIndex: 0,
culture: ["大专", "本科", "硕士"],
degreeIndex: 0,
degree: ["学士", "硕士", "博士", "无学位"],
cultureTypeIndex: 0,
cultureType: ["全日制", "非全日制"],
sexIndex: 0,
sex: ["男", "女"]
},
onLoad: function (options) {
console.log(options);
// 页面初始化 options为页面跳转所带来的参数
inputContent = JSON.parse(options.inputContent);//接受上一步操作参数
//考试的动态填写字段获取 不同的考试,有些自己特有的字段
util.https(app.globalData.api + "/GetExamTypeFieldList", "GET", {
inputJson: {
ExamTypeId: inputContent.ExamType //考试类型ID
},
praviteKey: app.globalData.praviteKey
},
this.getExamTypeFieldList
)
//获取地理位置信息 高德web api
/* util.https("https://restapi.amap.com/v3/geocode/regeo", "GET", {
key: '972cafdc2472d8f779c5274db770ac22',
location: Number(wx.getStorageSync("longitude")).toFixed(6) + "," + Number(wx.getStorageSync("latitude")).toFixed(6)
},
this.getCurrentCityInfo
)*/
//初始化数据
inputContent["IDType"] = 1;
inputContent["Nation"] = this.data.nation[0];
inputContent["Job"] = this.data.profession[0];
inputContent["Admssion"] = this.data.entranceDate[0];
inputContent["Education"] = this.data.culture[0];
if (this.data.credentialsIndex != 0) {
inputContent["Birthday"] = this.data.date.replace(/-/g, "");
inputContent["Gender"] = 1;
}
inputContent.AutoData = [];
},
onReady: function () {
// 页面渲染完成
},
onShow: function () {
// 页面显示
this.setData({
isLogin: util.isLogin(),
userData: wx.getStorageSync("userData") || ""//用户信息
})
console.log(wx.getStorageSync("userData"));
//验证表单
this.wxValidate();
if (this.data.isLogin) { //已登录
//民族
inputContent["Nation"] = this.data.userData.Nation || this.data.nation[0];
if (this.data.userData.Nation) {
this.setData({
nationIndex: this.data.nation.indexOf(this.data.userData.Nation)
})
}
//职业
inputContent["Job"] = this.data.userData.Job || this.data.profession[0];
if (this.data.userData.Job) {
this.setData({
professionIndex: this.data.profession.indexOf(this.data.userData.Job)
})
}
//学历
inputContent["Education"] = this.data.userData.Education || this.data.culture[0];
if (this.data.userData.Education) {
this.setData({
cultureIndex: this.data.culture.indexOf(this.data.userData.Education)
})
}
//入学时间
inputContent["Admssion"] = this.data.userData.Admssion || this.data.entranceDate[0];
if (this.data.userData.Admssion) {
this.setData({
entranceDate: this.data.userData.Admssion
})
}
}
},
onHide: function () {
// 页面隐藏
},
onUnload: function () {
// 页面关闭
},
wxValidate: function () {
//验证表单
this.WxValidate = new WxValidate({
IDCard: { //验证规则 input name值
required: true,
idcard: true
},
Name: {
required: true,
minlength: 2
},
TelNum: {
required: true,
tel: true
},
QQNumber: {
required: true,
digits: true,
minlength: 5
},
SearchPwd: {
required: !this.data.isLogin,
minlength: 6,
maxlength: 18
},
University: {
required: true,
minlength: 4
},
Colledge: {
required: true
},
MajorCode: {
required: true
},
ClassCode: {
required: true
},
},
{
IDCard: { //提示信息
required: "请填写身份证号"
},
Name: { //提示信息
required: "请填写真实姓名",
minlength: "姓名至少输入两个字符"
},
TelNum: { //提示信息
required: "请填写真实手机号码"
},
QQNumber: { //提示信息
required: "请填写QQ号码"
},
SearchPwd: { //提示信息
required: "请填写密码",
minlength: "密码至少输入6个字符",
maxlength: "密码最多输入18个字符"
},
University: { //提示信息
required: "请填写学校名称",
minlength: "学校名称至少输入四个字符"
},
Colledge: { //提示信息
required: "请填写学院信息"
},
MajorCode: { //提示信息
required: "请填写专业信息"
},
ClassCode: { //提示信息
required: "请填写班级信息"
}
})
},
//考试的动态填写字段获取 不同的考试,有些自己特有的字段
getExamTypeFieldList: function (data) {
console.log(data);
this.setData({
examTypeFieldList: data.Data
})
},
//获取地理位置信息 高德web api
/* getCurrentCityInfo: function (data) {
console.log(data);
this.setData({
currentCityAddress: data.status == 1 ? data.regeocode.formatted_address : ""
})
},*/
//证件类型选择
bindCredentialsPickerChange: function (e) {
this.setData({
credentialsIndex: e.detail.value
})
inputContent[e.currentTarget.id] = Number(e.detail.value) + 1;
},
//民族类型选择
bindNationPickerChange: function (e) {
this.setData({
nationIndex: e.detail.value
})
inputContent[e.currentTarget.id] = this.data.nati