auth.html 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171
  1. {extend name="public/base"/}
  2. {block name="css"}
  3. <style>
  4. .idcard-box {
  5. background:white;
  6. padding:10px 0;
  7. }
  8. .van-uploader,.van-uploader__input-wrapper {
  9. width:100%;
  10. }
  11. .image-tips {font-size:12px;color:#666;text-align:center;margin-top:5px;}
  12. .error {color:#ed6a0c;background:#FFFBE8;padding:5px 16px;font-size:14px;}
  13. </style>
  14. {/block}
  15. {block name="body"}
  16. <van-nav-bar
  17. class="nav-theme"
  18. :fixed="true"
  19. :placeholder="true"
  20. left-text="返回"
  21. left-arrow
  22. @click-left="onBack"
  23. >
  24. <template #title>
  25. <span class="text-white">实名认证</span>
  26. </template>
  27. </van-nav-bar>
  28. <van-notice-bar
  29. :scrollable="false"
  30. text="{$user.is_auth_text}"
  31. color="#1989fa"
  32. background="#ECF9FF"
  33. ></van-notice-bar>
  34. <div class="error" v-if="user.is_auth == 3">
  35. {$user.auth_check}
  36. </div>
  37. <van-cell-group v-if="user.is_auth == 2 || user.is_auth == 4">
  38. <van-field
  39. v-model="user.realname"
  40. readonly
  41. label="姓名"
  42. ></van-field>
  43. <van-field
  44. v-model="user.idcard"
  45. readonly
  46. label="身份证号"
  47. ></van-field>
  48. <div class="idcard-box">
  49. <van-row >
  50. <van-col span="9" offset="2">
  51. <van-image style="width:100%;height:90px;" :src="user.idcard_front_pic"></van-image>
  52. </van-col>
  53. <van-col span="9" offset="2">
  54. <van-image style="width:100%;height:90px;" :src="user.idcard_back_pic"></van-image>
  55. </van-col>
  56. </van-row>
  57. </div>
  58. </van-cell-group>
  59. <van-form @submit="onSubmit" v-if="user.is_auth == 1 || user.is_auth == 3">
  60. <van-cell-group>
  61. <van-field
  62. v-model="user.realname"
  63. required
  64. label="真实姓名"
  65. placeholder="请输入真实姓名"
  66. :rules="[{ required: true, message: '请输入真实姓名' }]"
  67. ></van-field>
  68. <van-field
  69. v-model="user.idcard"
  70. required
  71. label="身份证号"
  72. placeholder="请输入身份证号"
  73. :rules="[{ required: true, message: '请输入身份证号' }]"
  74. ></van-field>
  75. <div class="idcard-box">
  76. <van-row>
  77. <van-col span="9" offset="2">
  78. <van-uploader style="width:100%;" :after-read="afterRead" :before-read="uploadFront" :max-size="2 * 1024 * 1024" @oversize="onOversize">
  79. <van-image style="width:100%;height:90px;display:block;" :src="user.idcard_front_pic"></van-image>
  80. </van-uploader>
  81. <div class="image-tips">上传身份证(头像页)</div>
  82. </van-col>
  83. <van-col span="9" offset="2">
  84. <van-uploader style="width:100%;" :after-read="afterRead" :before-read="uploadBack" :max-size="2 * 1024 * 1024" @oversize="onOversize">
  85. <van-image style="width:100%;height:90px;display:block;" :src="user.idcard_back_pic"></van-image>
  86. </van-uploader>
  87. <div class="image-tips">上传身份证(国徽页)</div>
  88. </van-col>
  89. </van-row>
  90. </div>
  91. <div style="margin: 16px;">
  92. <van-button round block type="primary" native-type="submit">
  93. 提交
  94. </van-button>
  95. </div>
  96. </van-cell-group>
  97. </van-form>
  98. {/block}
  99. {block name="script"}
  100. <script>
  101. function v_setup() {
  102. let base = {};
  103. //基础
  104. let user = {$user};
  105. base.birthday = Vue.ref(user.birthday ? user.birthday.split('-') : []);
  106. base.has_account = (user.account !== '');
  107. base.user = Vue.reactive(user);
  108. base.onBack = () => {
  109. location.href = "{:url('my/index')}";
  110. };
  111. //头像
  112. base.avatar = Vue.computed(()=>{
  113. return base.user.avatar ? base.user.avatar : "__COMMON_IMAGES__/default_avatar.png";
  114. });
  115. base.beforeRead = (file) => {
  116. if (file.type.indexOf('image/') === -1) {
  117. vant.showToast('请上传图片');
  118. return false;
  119. }
  120. return true;
  121. };
  122. base.onOversize = () => {
  123. vant.showToast('文件大小不能超过2MB');
  124. return false;
  125. };
  126. base.uploadFront = (file) => {
  127. console.log(file);
  128. const formData = new FormData();
  129. formData.append("file", file);
  130. postFile("upload/image",formData).then(({data})=>{
  131. base.user.idcard_front_pic = data.src;
  132. });
  133. return true;
  134. };
  135. base.uploadBack = (file) => {
  136. const formData = new FormData();
  137. formData.append("file", file);
  138. postFile("upload/image",formData).then(({data})=>{
  139. base.user.idcard_back_pic = data.src;
  140. });
  141. return true;
  142. };
  143. //表单提交
  144. base.onSubmit = () => {
  145. if (base.user.idcard_front_pic === '') {
  146. vant.showToast('请上传身份证(头像页)');
  147. return false;
  148. }
  149. if (base.user.idcard_back_pic === '') {
  150. vant.showToast('请上传身份证(国徽页)');
  151. return false;
  152. }
  153. postJson('/my/authPost',base.user).then(() => {
  154. location.reload();
  155. });
  156. };
  157. return base;
  158. }
  159. </script>
  160. {/block}