hanfucheng преди 1 година
родител
ревизия
a78a7bdb63
променени са 2 файла, в които са добавени 186 реда и са изтрити 147 реда
  1. 95 74
      pages/me/nameAuthentication.vue
  2. 91 73
      pages/me/officialAuthentication.vue

+ 95 - 74
pages/me/nameAuthentication.vue

@@ -1,81 +1,102 @@
 <template>
-	<uni-section title="自定义校验规则" type="line">
-			<view class="example">
-				<!-- 自定义表单校验 -->
-				<uni-forms ref="customForm" :rules="customRules" :modelValue="form">
-					<uni-forms-item label="姓名" required name="name">
-						<uni-easyinput v-model="form.name" placeholder="请输入姓名" />
-					</uni-forms-item>
-					<uni-forms-item label="电话" required name="phone">
-						<uni-easyinput v-model="form.phone" placeholder="请输入电话" />
-					</uni-forms-item>
-					<uni-forms-item label="身份证号" required name="idCard">
-						<uni-easyinput v-model="form.idCard" placeholder="请输入身份证号" />
-					</uni-forms-item>
-					<uni-forms-item label="身份证正反面" required name="path">
-						<upload :imgArr="imageList" name="path" v-model="form.path" :fileSize="1" :limit="2" @updateImg="updateImg"></upload>
-					</uni-forms-item>
-				</uni-forms>
-				<button type="primary" @click="submitForm('customForm')">提交</button>
-			</view>
-		</uni-section>
+    <uni-section title="实名认证" type="line">
+        <view class="example">
+            <!-- 自定义表单校验 -->
+            <uni-forms ref="customForm" :rules="customRules" :modelValue="form">
+                <uni-forms-item label="姓名" required name="name">
+                    <uni-easyinput v-model="form.name" placeholder="请输入姓名" maxlength="20"/>
+                </uni-forms-item>
+                <uni-forms-item label="电话" required name="phone">
+                    <uni-easyinput v-model="form.phone" placeholder="请输入电话" maxlength="13"/>
+                </uni-forms-item>
+                <uni-forms-item label="身份证号" required name="idCard">
+                    <uni-easyinput v-model="form.idCard" placeholder="请输入身份证号" maxlength="18"/>
+                </uni-forms-item>
+                <uni-forms-item label="身份证正反面" required name="path">
+                    <upload :imgArr="imageList" name="path" v-model="form.path" :fileSize="1" :limit="2"
+                            @updateImg="updateImg"></upload>
+                </uni-forms-item>
+            </uni-forms>
+            <button type="primary" @click="submitForm('customForm')">提交</button>
+        </view>
+    </uni-section>
 </template>
 
 <script>
-import upload from '../../components/upload/index.vue'
-import {appletAdd} from '@/api/me/nameAuthentication.js'
-export default {
-	components: {
-		upload
-	},
-	onReady() {
-		// 设置自定义表单校验规则,必须在节点渲染完毕后执行
-		this.$refs.customForm.setRules(this.customRules)
-	},
-	data() {
-		return{
-			form:{
-				
-			},
-			// 表单校验
-			customRules: {
-				name: {
-					rules: [{
-						required: true,
-						errorMessage: '姓名不能为空'
-					}]
-				},
-			},
-			imageList:[]
-		}
-	},
-	methods: {
-	    // 取消按钮
-	    cancel() {
-	      this.open = false;
-	      this.reset();
-	    },
-	    /** 提交按钮 */
-	    submitForm(e) {
-			console.log("11111")
-			this.$refs[e].validate().then(res => {
-				console.log('success', res);
-				uni.showToast({
-				  title: `校验通过`
-				})
-			  }).catch(err => {
-				console.log('err', err);
-			})
-			let path = this.imageList.join(',');
-			console.log(path)
-			this.form.path = path
-			appletAdd(this.form).then(res =>{})
-	    },
-		updateImg(imgList){
-			this.imageList = imgList;
-		}
-	}
-};
+    import upload from '../../components/upload/index.vue'
+    import {appletAdd} from '@/api/me/nameAuthentication.js'
+
+    export default {
+        components: {
+            upload
+        },
+        onReady() {
+            // 设置自定义表单校验规则,必须在节点渲染完毕后执行
+            this.$refs.customForm.setRules(this.customRules)
+        },
+        data() {
+            return {
+                form: {},
+                // 表单校验
+                customRules: {
+                    name: {
+                        rules: [{
+                            required: true,
+                            errorMessage: '姓名不能为空'
+                        }]
+                    },
+                    phone: {
+                        rules: [{
+                            required: true,
+                            errorMessage: '电话不能为空'
+                        },
+						{
+						  pattern:'^1[3456789]\\d{9}$',
+						  errorMessage: '请填写正确的手机号'
+						}]
+                    },
+                    idCard: {
+                        rules: [{
+                            required: true,
+                            errorMessage: '身份证号不能为空'
+                        },
+						{
+						  pattern: '/(^\\d{15}$)|(^\\d{18}$)|(^\\d{17}(\\d|X|x)$)/',
+						  errorMessage: '请填写正确的身份号'
+						}]
+                    },
+                    path: {
+                        rules: [{
+                            required: true,
+                            errorMessage: '身份证正反面不能为空'
+                        }]
+                    },
+                },
+                imageList: []
+            }
+        },
+        methods: {
+            // 取消按钮
+            cancel() {
+                this.open = false;
+                this.reset();
+            },
+            /** 提交按钮 */
+            submitForm(e) {
+                this.$refs[e].validate().then(res => {
+                    appletAdd(this.form).then(res => {
+						uni.navigateBack();
+					});
+                }).catch(err => {
+                })
+            },
+
+            updateImg(imgList) {
+                this.imageList = imgList;
+                this.form.path = this.imageList.join(',');
+            }
+        }
+    };
 </script>
 
 <style>

+ 91 - 73
pages/me/officialAuthentication.vue

@@ -1,80 +1,98 @@
 <template>
-	<uni-section title="自定义校验规则" type="line">
-			<view class="example">
-				<!-- 自定义表单校验 -->
-				<uni-forms ref="customForm" :rules="customRules" :modelValue="form">
-					<uni-forms-item label="企业名称" required name="enterpriseName">
-						<uni-easyinput v-model="form.enterpriseName" placeholder="请输入企业名称" />
-					</uni-forms-item>
-					<uni-forms-item label="法人姓名" required name="legalName">
-						<uni-easyinput v-model="form.legalName" placeholder="请输入法人姓名" />
-					</uni-forms-item>
-					<uni-forms-item label="联系电话" required name="phone">
-						<uni-easyinput v-model="form.phone" placeholder="请输入联系电话" />
-					</uni-forms-item>
-					<uni-forms-item label="证照信息" required name="path">
-						<upload :imgArr="imageList" name="path" v-model="form.path" :fileSize="1" :limit="3" @updateImg="updateImg"></upload>
-					</uni-forms-item>
-				</uni-forms>
-				<button type="primary" @click="submitForm('customForm')">提交</button>
-			</view>
-		</uni-section>
+    <uni-section title="官方认证" type="line">
+        <view class="example">
+            <!-- 自定义表单校验 -->
+            <uni-forms ref="customForm" :rules="customRules" :modelValue="form">
+                <uni-forms-item label="企业名称" required name="enterpriseName">
+                    <uni-easyinput v-model="form.enterpriseName" placeholder="请输入企业名称" maxlength="20"/>
+                </uni-forms-item>
+                <uni-forms-item label="法人姓名" required name="legalName">
+                    <uni-easyinput v-model="form.legalName" placeholder="请输入法人姓名" maxlength="32"/>
+                </uni-forms-item>
+                <uni-forms-item label="联系电话" required name="phone">
+                    <uni-easyinput v-model="form.phone" placeholder="请输入联系电话" maxlength="13"/>
+                </uni-forms-item>
+                <uni-forms-item label="证照信息" required name="path">
+                    <upload :imgArr="imageList" name="path" v-model="form.path" :fileSize="1" :limit="3"
+                            @updateImg="updateImg"></upload>
+                </uni-forms-item>
+            </uni-forms>
+            <button type="primary" @click="submitForm('customForm')">提交</button>
+        </view>
+    </uni-section>
 </template>
 
 <script>
-import upload from '../../components/upload/index.vue'
-import {appletAdd} from '@/api/me/officialAuthentication.js'
-export default {
-	components: {
-		upload
-	},
-	onReady() {
-		// 设置自定义表单校验规则,必须在节点渲染完毕后执行
-		this.$refs.customForm.setRules(this.customRules)
-	},
-	data() {
-		return{
-			form:{
-				
-			},
-			// 表单校验
-			customRules: {
-				name: {
-					rules: [{
-						required: true,
-						errorMessage: '姓名不能为空'
-					}]
-				},
-			},
-			imageList:[]
-		}
-	},
-	methods: {
-	    // 取消按钮
-	    cancel() {
-	      this.open = false;
-	      this.reset();
-	    },
-	    /** 提交按钮 */
-	    submitForm(e) {
-			console.log("11111")
-			this.$refs[e].validate().then(res => {
-				console.log('success', res);
-				uni.showToast({
-				  title: `校验通过`
-				})
-			  }).catch(err => {
-				console.log('err', err);
-			})
-			let path = this.imageList.join(',');
-			this.form.path = path
-			appletAdd(this.form).then(res =>{})
-	    },
-		updateImg(imgList){
-			this.imageList = imgList;
-		}
-	}
-};
+    import upload from '../../components/upload/index.vue'
+    import {appletAdd} from '@/api/me/officialAuthentication.js'
+
+    export default {
+        components: {
+            upload
+        },
+        onReady() {
+            // 设置自定义表单校验规则,必须在节点渲染完毕后执行
+            this.$refs.customForm.setRules(this.customRules)
+        },
+        data() {
+            return {
+                form: {},
+                // 表单校验
+                customRules: {
+                    enterpriseName: {
+                        rules: [{
+                            required: true,
+                            errorMessage: '企业名称不能为空'
+                        }]
+                    },
+                    legalName: {
+                        rules: [{
+                            required: true,
+                            errorMessage: '法人姓名不能为空'
+                        }]
+                    },
+                    phone: {
+                        rules: [{
+                            required: true,
+                            errorMessage: '联系电话不能为空'
+                        },
+						{
+						  pattern:'^1[3456789]\\d{9}$',
+						  errorMessage: '请填写正确的手机号'
+						}]
+                    },
+                    path: {
+                        rules: [{
+                            required: true,
+                            errorMessage: '证照信息不能为空'
+                        }]
+                    },
+                },
+                imageList: []
+            }
+        },
+        methods: {
+            // 取消按钮
+            cancel() {
+                this.open = false;
+                this.reset();
+            },
+            /** 提交按钮 */
+            submitForm(e) {
+                this.$refs[e].validate().then(res => {
+					appletAdd(this.form).then(res => {
+						uni.navigateBack();
+					})
+                }).catch(err => {
+                    console.log('err', err);
+                })
+            },
+            updateImg(imgList) {
+                this.imageList = imgList;
+                this.form.path = this.imageList.join(',');
+            }
+        }
+    };
 </script>
 
 <style>