officialAuthentication.vue 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134
  1. <template>
  2. <uni-section title="官方认证" type="line">
  3. <view class="example">
  4. <!-- 自定义表单校验 -->
  5. <uni-forms ref="customForm" :rules="customRules" :modelValue="form" class="form">
  6. <uni-forms-item label="企业名称" required name="enterpriseName">
  7. <uni-easyinput v-model="form.enterpriseName" placeholder="请输入企业名称" maxlength="20" style="width: 40%;"/>
  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 class="onePic" v-if="form.id != null">
  16. <image :src="loadImgSrcLocalhost(item)" v-for="(item, index1) in imageList" :key="index1">
  17. </image>
  18. </uni-forms-item>
  19. <uni-forms-item label="证照信息" required name="path" v-if="form.id == null">
  20. <upload :imgArr="imageList" name="path" v-model="form.path" :fileSize="1" :limit="2"
  21. style="position: relative;left: -5%;top: -10%;"
  22. @updateImg="updateImg"></upload>
  23. </uni-forms-item>
  24. </uni-forms>
  25. <button type="primary" @click="submitForm('customForm')" v-if="form.id==null">提交</button>
  26. </view>
  27. </uni-section>
  28. </template>
  29. <script>
  30. import upload from '../../../components/upload/index.vue'
  31. import {appletAdd,getUserInfo} from '@/api/me/officialAuthentication.js'
  32. export default {
  33. components: {
  34. upload
  35. },
  36. onReady() {
  37. // 设置自定义表单校验规则,必须在节点渲染完毕后执行
  38. this.$refs.customForm.setRules(this.customRules)
  39. this.userId = getApp().globalData.userId
  40. this.getUserInfoByUserId(this.userId)
  41. },
  42. data() {
  43. return {
  44. form: {},
  45. // 表单校验
  46. customRules: {
  47. enterpriseName: {
  48. rules: [{
  49. required: true,
  50. errorMessage: '企业名称不能为空'
  51. }]
  52. },
  53. legalName: {
  54. rules: [{
  55. required: true,
  56. errorMessage: '法人姓名不能为空'
  57. }]
  58. },
  59. phone: {
  60. rules: [{
  61. required: true,
  62. errorMessage: '联系电话不能为空'
  63. },
  64. {
  65. pattern:'^1[3456789]\\d{9}$',
  66. errorMessage: '请填写正确的手机号'
  67. }]
  68. },
  69. path: {
  70. rules: [{
  71. required: true,
  72. errorMessage: '证照信息不能为空'
  73. }]
  74. },
  75. },
  76. imageList: []
  77. }
  78. },
  79. methods: {
  80. // 取消按钮
  81. cancel() {
  82. this.open = false;
  83. this.reset();
  84. },
  85. /** 提交按钮 */
  86. submitForm(e) {
  87. this.$refs[e].validate().then(res => {
  88. if(this.imageList.length!=2){
  89. uni.showToast({
  90. title: "证照信息照片为两张!",
  91. icon: "none"
  92. })
  93. }else{
  94. appletAdd(this.form).then(res => {
  95. uni.navigateBack();
  96. });
  97. }
  98. })
  99. },
  100. //图片上传
  101. updateImg(imgList) {
  102. this.imageList = imgList;
  103. this.form.path = this.imageList.join(',');
  104. },
  105. //按userId查询实名认证信息
  106. getUserInfoByUserId(userId){
  107. getUserInfo(userId).then(res =>{
  108. if(res.data!=null){
  109. this.form = res.data;
  110. this.imageList = res.data.path.split(",")
  111. }
  112. })
  113. }
  114. }
  115. };
  116. </script>
  117. <style scoped>
  118. .form{
  119. width: 100%;
  120. padding-left: 3%;
  121. }
  122. ::v-deep .item--uni-forms-item__label{
  123. width: 19% !important;
  124. }
  125. ::v-deep .uni-section-content{
  126. padding: 0 2%;
  127. }
  128. </style>