|
@@ -1,5 +1,6 @@
|
|
|
const app = require('../../utils/util.js');
|
|
|
var util = require('../../utils/md5.js')
|
|
|
+import WxValidate from '../../utils/WxValidate';
|
|
|
Page({
|
|
|
data: {
|
|
|
postindex: null,
|
|
@@ -10,24 +11,48 @@ Page({
|
|
|
educationtext: '请选择',
|
|
|
|
|
|
postList: [{
|
|
|
- name: '群众'
|
|
|
+ name: '在职人员'
|
|
|
},
|
|
|
{
|
|
|
- name: '团员'
|
|
|
+ name: '两委人员'
|
|
|
},
|
|
|
{
|
|
|
- name: '党员'
|
|
|
+ name: '社会组织人员'
|
|
|
+ },
|
|
|
+ {
|
|
|
+ name: '志愿者'
|
|
|
+ },
|
|
|
+ {
|
|
|
+ name: '学生'
|
|
|
+ },
|
|
|
+ {
|
|
|
+ name: '其他'
|
|
|
},
|
|
|
],
|
|
|
|
|
|
incomeList: [{
|
|
|
- name: '1000'
|
|
|
+ name: '没有收入'
|
|
|
+ },
|
|
|
+ {
|
|
|
+ name: '500元以下'
|
|
|
+ },
|
|
|
+ {
|
|
|
+ name: '500-1000元'
|
|
|
+ },
|
|
|
+ {
|
|
|
+ name: '1000-2000元'
|
|
|
},
|
|
|
{
|
|
|
- name: '2000'
|
|
|
+ name: '2000-5000元'
|
|
|
},
|
|
|
{
|
|
|
- name: '3000'
|
|
|
+ name: '5000元-1万元'
|
|
|
+ },
|
|
|
+ {
|
|
|
+ name: '1-2万元'
|
|
|
+ },
|
|
|
+ {
|
|
|
+ name: '2万元以上'
|
|
|
},
|
|
|
],
|
|
|
|
|
@@ -40,10 +65,16 @@ Page({
|
|
|
{
|
|
|
name: '高中'
|
|
|
},
|
|
|
+ {
|
|
|
+ name: '大专'
|
|
|
+ },
|
|
|
+ {
|
|
|
+ name: '本科'
|
|
|
+ },
|
|
|
+ {
|
|
|
+ name: '本科以上'
|
|
|
+ },
|
|
|
],
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
},
|
|
|
goOcr() {
|
|
|
wx.showLoading({
|
|
@@ -138,26 +169,97 @@ Page({
|
|
|
})
|
|
|
},
|
|
|
|
|
|
-
|
|
|
+ initValidate() {
|
|
|
+ const rules = {
|
|
|
+ name: {
|
|
|
+ required: true,
|
|
|
+ },
|
|
|
+ sex: {
|
|
|
+ required: true,
|
|
|
+ },
|
|
|
+ card: {
|
|
|
+ required: true,
|
|
|
+ idcard: true,
|
|
|
+ },
|
|
|
+ age: {
|
|
|
+ required: true,
|
|
|
+ },
|
|
|
+ post: {
|
|
|
+ required: true,
|
|
|
+ },
|
|
|
+ income: {
|
|
|
+ required: true,
|
|
|
+ },
|
|
|
+ education: {
|
|
|
+ required: true,
|
|
|
+ },
|
|
|
|
|
|
|
|
|
+ };
|
|
|
+ const messages = {
|
|
|
+ name: {
|
|
|
+ required: '姓名不能为空',
|
|
|
+ },
|
|
|
+ sex: {
|
|
|
+ required: '性别不能为空',
|
|
|
+ },
|
|
|
+ card: {
|
|
|
+ required: '身份证号不能为空',
|
|
|
+ idcard: '身份证号格式错误 ',
|
|
|
+ },
|
|
|
+ age: {
|
|
|
+ required: '年龄不能为空',
|
|
|
+ },
|
|
|
+ post: {
|
|
|
+ required: '职务不能为空',
|
|
|
+ },
|
|
|
+ income: {
|
|
|
+ required: '收入不能为空',
|
|
|
+ },
|
|
|
+ education: {
|
|
|
+ required: '学历不能为空',
|
|
|
+ },
|
|
|
+ };
|
|
|
+ // 创建实例对象
|
|
|
+ this.WxValidate = new WxValidate(rules, messages)
|
|
|
+ },
|
|
|
+ showModal(error) {
|
|
|
+ wx.showToast({
|
|
|
+ title: error.msg,
|
|
|
+ icon: 'none',
|
|
|
+ duration: 2000,
|
|
|
+ })
|
|
|
+ },
|
|
|
formSubmit(e) {
|
|
|
console.log(e.detail, "daying");
|
|
|
- // wx.request({
|
|
|
- // url: app.globalData.publicUrl + '/applet/bing',
|
|
|
- // method: "GET",
|
|
|
- // data: {
|
|
|
- // name: e.detail.value.name,
|
|
|
- // pwd: util.hexMD5(password),
|
|
|
- // appletsId: wx.getStorageSync('openId')
|
|
|
- // },
|
|
|
- // success: (res) => {
|
|
|
+ /***4-3(表单提交校验)*/
|
|
|
+ const params = e.detail.value
|
|
|
+ if (!this.WxValidate.checkForm(params)) {
|
|
|
+ const error = this.WxValidate.errorList[0]
|
|
|
+ this.showModal(error)
|
|
|
+ return false
|
|
|
+ }
|
|
|
+ /*** 这里添写验证成功以后的逻辑**/
|
|
|
+ //验证通过以后->
|
|
|
+ this.submitInfo(params);
|
|
|
+ },
|
|
|
+ submitInfo(params) {
|
|
|
+ wx.request({
|
|
|
+ url: app.globalData.publicUrl + '/wxinfo/listByOpenid',
|
|
|
+ method: "GET",
|
|
|
+ data: params,
|
|
|
+ header: {
|
|
|
+ appletsId: wx.getStorageSync('openId')
|
|
|
+ },
|
|
|
+ success: (res) => {
|
|
|
+ if (res.data.code == 0) {
|
|
|
+ console.log(res, "0000");
|
|
|
|
|
|
- // }
|
|
|
- // })
|
|
|
- // wx.switchTab({
|
|
|
- // url: '/pages/index/index',
|
|
|
- // })
|
|
|
+ }
|
|
|
+ }
|
|
|
+ })
|
|
|
+ },
|
|
|
+ onLoad: function () {
|
|
|
+ this.initValidate();
|
|
|
},
|
|
|
- onLoad: function () {},
|
|
|
})
|