roose 4 years ago
parent
commit
816745e851
2 changed files with 131 additions and 30 deletions
  1. 127 25
      pages/finishInfo/finishInfo.js
  2. 4 5
      pages/finishInfo/finishInfo.wxml

+ 127 - 25
pages/finishInfo/finishInfo.js

@@ -1,5 +1,6 @@
 const app = require('../../utils/util.js');
 const app = require('../../utils/util.js');
 var util = require('../../utils/md5.js')
 var util = require('../../utils/md5.js')
+import WxValidate from '../../utils/WxValidate';
 Page({
 Page({
   data: {
   data: {
     postindex: null,
     postindex: null,
@@ -10,24 +11,48 @@ Page({
     educationtext: '请选择',
     educationtext: '请选择',
 
 
     postList: [{
     postList: [{
-        name: '群众'
+        name: '在职人员'
       },
       },
       {
       {
-        name: '员'
+        name: '两委人员'
       },
       },
       {
       {
-        name: '党员'
+        name: '社会组织人员'
+      },
+      {
+        name: '志愿者'
+      },
+      {
+        name: '学生'
+      },
+      {
+        name: '其他'
       },
       },
     ],
     ],
 
 
     incomeList: [{
     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: '本科'
+      },
+      {
+        name: '本科以上'
+      },
     ],
     ],
-
-
-
   },
   },
   goOcr() {
   goOcr() {
     wx.showLoading({
     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) {
   formSubmit(e) {
     console.log(e.detail, "daying");
     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 () {},
 })
 })

+ 4 - 5
pages/finishInfo/finishInfo.wxml

@@ -17,7 +17,7 @@
 					<van-radio >男</van-radio>
 					<van-radio >男</van-radio>
 					<van-radio value="女">女</van-radio>
 					<van-radio value="女">女</van-radio>
 				</van-radio-group> -->
 				</van-radio-group> -->
-				<radio-group name="sex" >
+				<radio-group name="sex">
 					<radio color='#009FE9' value='男'>男</radio>
 					<radio color='#009FE9' value='男'>男</radio>
 					<radio color='#009FE9' value='女'>女</radio>
 					<radio color='#009FE9' value='女'>女</radio>
 				</radio-group>
 				</radio-group>
@@ -32,7 +32,7 @@
 			</view>
 			</view>
 			<view class="flex-box">
 			<view class="flex-box">
 				<view class="small-box">职务</view>
 				<view class="small-box">职务</view>
-				<picker bindchange="postListChange" name="ensure_id" value="{{postList[postindex].name}}" range-key="{{'name'}}" range="{{postList}}">
+				<picker bindchange="postListChange" name="post" value="{{postList[postindex].name}}" range-key="{{'name'}}" range="{{postList}}">
 					<view class="picker">
 					<view class="picker">
 						{{postList[postindex].name}} <text class="wenzi">{{posttext}}</text>
 						{{postList[postindex].name}} <text class="wenzi">{{posttext}}</text>
 					</view>
 					</view>
@@ -40,16 +40,15 @@
 			</view>
 			</view>
 			<view class="flex-box">
 			<view class="flex-box">
 				<view class="small-box">收入</view>
 				<view class="small-box">收入</view>
-				<picker bindchange="incomeListChange" name="ensure_id" value="{{incomeList[incomeindex].name}}" range-key="{{'name'}}" range="{{incomeList}}">
+				<picker bindchange="incomeListChange" name="income" value="{{incomeList[incomeindex].name}}" range-key="{{'name'}}" range="{{incomeList}}">
 					<view class="picker">
 					<view class="picker">
 						{{incomeList[incomeindex].name}} <text class="wenzi">{{incometext}}</text>
 						{{incomeList[incomeindex].name}} <text class="wenzi">{{incometext}}</text>
 					</view>
 					</view>
 				</picker>
 				</picker>
 			</view>
 			</view>
-
 			<view class="flex-box">
 			<view class="flex-box">
 				<view class="small-box">学历</view>
 				<view class="small-box">学历</view>
-				<picker bindchange="educationListChange" name="ensure_id" value="{{educationList[educationindex].name}}" range-key="{{'name'}}" range="{{educationList}}">
+				<picker bindchange="educationListChange" name="education" value="{{educationList[educationindex].name}}" range-key="{{'name'}}" range="{{educationList}}">
 					<view class="picker">
 					<view class="picker">
 						{{educationList[educationindex].name}} <text class="wenzi">{{educationtext}}</text>
 						{{educationList[educationindex].name}} <text class="wenzi">{{educationtext}}</text>
 					</view>
 					</view>