officialAuthentication.vue 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  1. <template>
  2. <uni-section title="官方认证" type="line">
  3. <view class="example">
  4. <!-- 自定义表单校验 -->
  5. <uni-forms ref="customForm" :rules="customRules" :modelValue="form">
  6. <uni-forms-item label="企业名称" required name="enterpriseName">
  7. <uni-easyinput v-model="form.enterpriseName" placeholder="请输入企业名称" maxlength="20"/>
  8. </uni-forms-item>
  9. <uni-forms-item label="法人姓名" required name="legalName">
  10. <uni-easyinput v-model="form.legalName" placeholder="请输入法人姓名" maxlength="20"/>
  11. </uni-forms-item>
  12. <uni-forms-item label="联系电话" required name="phone">
  13. <uni-easyinput v-model="form.phone" placeholder="请输入联系电话" maxlength="13"/>
  14. </uni-forms-item>
  15. <uni-forms-item label="证照信息" required name="path">
  16. <upload :imgArr="imageList" name="path" v-model="form.path" :fileSize="1" :limit="2"
  17. @updateImg="updateImg"></upload>
  18. </uni-forms-item>
  19. </uni-forms>
  20. <button type="primary" @click="submitForm('customForm')">提交</button>
  21. </view>
  22. </uni-section>
  23. </template>
  24. <script>
  25. import upload from '../../components/upload/index.vue'
  26. import {appletAdd} from '@/api/me/officialAuthentication.js'
  27. export default {
  28. components: {
  29. upload
  30. },
  31. onReady() {
  32. // 设置自定义表单校验规则,必须在节点渲染完毕后执行
  33. this.$refs.customForm.setRules(this.customRules)
  34. },
  35. data() {
  36. return {
  37. form: {},
  38. // 表单校验
  39. customRules: {
  40. enterpriseName: {
  41. rules: [{
  42. required: true,
  43. errorMessage: '企业名称不能为空'
  44. }]
  45. },
  46. legalName: {
  47. rules: [{
  48. required: true,
  49. errorMessage: '法人姓名不能为空'
  50. }]
  51. },
  52. phone: {
  53. rules: [{
  54. required: true,
  55. errorMessage: '联系电话不能为空'
  56. },
  57. {
  58. pattern:'^1[3456789]\\d{9}$',
  59. errorMessage: '请填写正确的手机号'
  60. }]
  61. },
  62. path: {
  63. rules: [{
  64. required: true,
  65. errorMessage: '证照信息不能为空'
  66. }]
  67. },
  68. },
  69. imageList: []
  70. }
  71. },
  72. methods: {
  73. // 取消按钮
  74. cancel() {
  75. this.open = false;
  76. this.reset();
  77. },
  78. /** 提交按钮 */
  79. submitForm(e) {
  80. this.$refs[e].validate().then(res => {
  81. if(this.imageList.length!=2){
  82. uni.showToast({
  83. title: "证照信息照片为两张!",
  84. icon: "none"
  85. })
  86. }else{
  87. appletAdd(this.form).then(res => {
  88. console.log("1111111111")
  89. uni.navigateBack();
  90. console.log("2222222222222")
  91. });
  92. }
  93. })
  94. },
  95. updateImg(imgList) {
  96. this.imageList = imgList;
  97. this.form.path = this.imageList.join(',');
  98. }
  99. }
  100. };
  101. </script>
  102. <style>
  103. </style>