IndividualAuth.vue 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476
  1. <template>
  2. <div class="right-modifyPsw" id="individualAuth" v-loading="loading">
  3. <div class="right-modifyPsw-title">
  4. <span style="font-size: 18px;font-weight: bold;margin-right: 10px">个人认证</span>
  5. <el-tag :type="authStatus.style" v-if="authType===1">{{authStatus.text}}</el-tag>
  6. <el-tag type="danger" v-if="authType===0">未认证</el-tag>
  7. <!-- <el-button type="primary" class="pull-right" size="small" v-if="canEdit" @click="canEdit = true">编辑</el-button>-->
  8. </div>
  9. <!-- <div class="individual-steps-wrapper">-->
  10. <!-- <el-steps :active="active" process-status="finish" style="margin-bottom: 20px;width: 300px">-->
  11. <!-- <el-step title="填写认证信息"></el-step>-->
  12. <!-- <el-step title="认证结果"></el-step>-->
  13. <!-- </el-steps>-->
  14. <!-- </div>-->
  15. <el-alert
  16. v-if="failureReason&&failureReason!==''"
  17. :title="failureReason"
  18. type="error">
  19. </el-alert>
  20. <el-form ref="individualForm" :model="individualForm" :rules="rules" label-width="140px" style="width: 70%;margin-top: 10px">
  21. <el-form-item label="真实姓名" prop="realName">
  22. <el-input :disabled="!canEdit" v-model="individualForm.realName" placeholder="请输入您的姓名,需与身份证保持一致"></el-input>
  23. </el-form-item>
  24. <el-form-item label="身份证号码" prop="idCard">
  25. <el-input :disabled="!canEdit" v-model="individualForm.idCard" placeholder="身份证前后不能有空格"></el-input>
  26. </el-form-item>
  27. <el-form-item label="性别" prop="gender">
  28. <el-radio-group v-model="individualForm.gender" :disabled="!canEdit">
  29. <el-radio label="男"></el-radio>
  30. <el-radio label="女"></el-radio>
  31. </el-radio-group>
  32. </el-form-item>
  33. <el-form-item label="身份证到期时间" prop="idCardDeadTime">
  34. <el-date-picker
  35. v-model="individualForm.idCardDeadTime"
  36. style="width: 100%"
  37. align="right"
  38. type="date"
  39. placeholder="请按身份证背面“有效期限”如实填写"
  40. :disabled="!canEdit"
  41. >
  42. </el-date-picker>
  43. </el-form-item>
  44. <el-form-item label="家庭或单位地址" prop="address">
  45. <el-input :disabled="!canEdit" v-model="individualForm.address"></el-input>
  46. </el-form-item>
  47. <el-form-item label="认证权限" prop="roleList">
  48. <el-checkbox-group v-model="individualForm.roleList" :disabled="!canEdit">
  49. <el-checkbox :label="0">发包</el-checkbox>
  50. <el-checkbox :label="1">接包</el-checkbox>
  51. </el-checkbox-group>
  52. </el-form-item>
  53. </el-form>
  54. <div class="upload-wrapper">
  55. <el-row style="width: 100%">
  56. <el-col :span="9" style="padding-left: 30px">
  57. <div style="width: 280px">
  58. <el-upload
  59. class="avatar-uploader"
  60. style="border: lightgrey 1px solid"
  61. action="https://jsonplaceholder.typicode.com/posts/"
  62. :before-upload="beforeFileUpload"
  63. :http-request="uploadFile"
  64. :data="{type:0}"
  65. :disabled="!canEdit"
  66. >
  67. <img v-if="individualForm.idCardPositivePhoto" :src="individualForm.idCardPositivePhoto" class="avatar">
  68. <i v-else class="el-icon-plus avatar-uploader-icon card-uploader-icon"></i>
  69. </el-upload>
  70. <div style="text-align: center">身份证正面照<span style="color:red">(必填)</span></div>
  71. </div>
  72. </el-col>
  73. <el-col :span="15">
  74. <div class="authentication-detail">
  75. <div class="authentication-detail-title">证件要求</div>
  76. <el-row>
  77. <el-col :span="11">
  78. <div class="idcard-example1"></div>
  79. </el-col>
  80. <el-col :span="13" style="padding-left: 10px">
  81. <ul class="authentication-detail-list">
  82. <li>请上传本人<span class="authentication-detail-list-blue">手持</span>身份证正面头部照片和上 半身照片</li>
  83. <li>照片为免冠、未化妆的数码照片原始图片<span class="authentication-detail-list-blue">请勿用任何软件编辑修改</span></li>
  84. <li>必须看清证件信息,且证件信息不能被遮挡, 持证人五官清晰可见</li>
  85. <li>仅支持.jpg .bmp .png .gif的图片格式,图 片大小不超过3M</li>
  86. <li>核实手持证件与原件方向一致,对焦身份证 进行拍照</li>
  87. <li>您提供的照片众测服务平台将予以保护,不 会用于其他用途</li>
  88. </ul>
  89. <!-- <a class="authentication-detail-list-blue">实名认证帮助></a>-->
  90. </el-col>
  91. </el-row>
  92. </div>
  93. </el-col>
  94. </el-row>
  95. <el-row style="width: 100%">
  96. <el-col :span="9" style="padding-left: 30px">
  97. <div>
  98. <el-upload
  99. class="avatar-uploader"
  100. style="border: lightgrey 1px solid"
  101. action="https://jsonplaceholder.typicode.com/posts/"
  102. :before-upload="beforeFileUpload"
  103. :http-request="uploadFile"
  104. :data="{type:1}"
  105. >
  106. <img v-if="individualForm.idCardBackPhoto" :src="individualForm.idCardBackPhoto" class="avatar">
  107. <i v-else class="el-icon-plus avatar-uploader-icon card-uploader-icon"></i>
  108. </el-upload>
  109. <div style="text-align: center">身份证反面照<span style="color:red">(必填)</span></div>
  110. </div>
  111. </el-col>
  112. <el-col :span="15">
  113. <div class="authentication-detail">
  114. <div style="height: 40px;width: 100%"></div>
  115. <el-row>
  116. <el-col :span="11">
  117. <div class="idcard-example2"></div>
  118. </el-col>
  119. <el-col :span="13" style="padding-left: 10px">
  120. <ul class="authentication-detail-list">
  121. <li>必须看清证件信息,且证件信息不能被遮挡</li>
  122. <li>仅支持.jpg .bmp .png .gif的图片格式,图 片大小不超过3M</li>
  123. <li>您提供的照片众测服务平台将予以保护,不 会用于其他用途</li>
  124. </ul>
  125. </el-col>
  126. </el-row>
  127. </div>
  128. </el-col>
  129. </el-row>
  130. </div>
  131. <div class="enterprise-brn-wrapper">
  132. <!-- <button class="enterprise-btn previousBtn">上一步</button>-->
  133. <el-button type="primary" style="cursor: pointer" @click="submitIndividualAuth" v-if="canEdit && authType === 0">提交审核</el-button>
  134. <el-button type="primary" style="cursor: pointer" @click="submitIndividualAuth" v-if="canEdit && authType != 0">修改审核</el-button>
  135. </div>
  136. </div>
  137. </template>
  138. <script>
  139. import Apis from '@/js/api'
  140. import Http from '@/js/http'
  141. import {notify} from '@/constants/index'
  142. import {storageGet} from '@/js/index'
  143. import idcardPositive from '../../assets/img/idcard-positive.png'
  144. import idcardBack from '../../assets/img/idcard-back.png'
  145. export default {
  146. name: "IndividualAuth",
  147. data() {
  148. return {
  149. loading: false,
  150. active: 0,
  151. user: {},
  152. individualForm: {
  153. roleList: [],//0是发包 1是接包 如果两个都有那么权限都有。
  154. realName: "",
  155. gender: "",
  156. idCard: "",
  157. idCardPositivePhoto: '',
  158. idCardBackPhoto: '',
  159. idCardDeadTime: "",
  160. address: ""
  161. },
  162. failureReason: '',
  163. authType: -1,
  164. authDetail: {},
  165. authStatus: '',
  166. canEdit: false,
  167. rules:{
  168. realName: [
  169. { required: true, message: '请输入真实姓名', trigger: 'blur' },
  170. ],
  171. idCard: [
  172. { required: true, message: '请输入身份证号码', trigger: 'blur' },
  173. ],
  174. address:[
  175. { required: true, message: '请输入家庭或单位地址', trigger: 'blur' },
  176. ],
  177. gender: [
  178. { required: true, message: '请选择性别', trigger: 'blur' }
  179. ],
  180. roleList: [
  181. { type: 'array', required: true, message: '请至少选择一个认证权限', trigger: 'change' }
  182. ],
  183. idCardDeadTime: [
  184. { required: true, message: '请选择身份证过期时间', trigger: 'change' }
  185. ]
  186. }
  187. }
  188. },
  189. methods: {
  190. setUserInfo() {
  191. this.type = this.$route.query.type;
  192. this.user = storageGet('user') && storageGet('user').userVO;
  193. },
  194. submitIndividualAuth() {
  195. this.$refs['individualForm'].validate(valid => {
  196. if (!valid) {
  197. notify('error', '信息填写不规范');
  198. return false
  199. }
  200. })
  201. if(!this.individualForm.idCardPositivePhoto){
  202. notify('error', '身份证正面照片上传不规范');
  203. return false;
  204. }
  205. if(!this.individualForm.idCardBackPhoto){
  206. notify('error', '身份证反面照片上传不规范');
  207. return false;
  208. }
  209. this.showLoading();
  210. let firstSubmit = this.$route.query.type;
  211. if(firstSubmit == 1){
  212. Http.post(`/api/user/${this.user.id}/personalAuth`, this.individualForm).then(res => {
  213. if (res) {
  214. notify('success', '提交成功');
  215. this.$router.push('/personal/authentication')
  216. }
  217. }).catch(err => {
  218. this.hideLoading();
  219. notify('error', err.data)
  220. })
  221. }else{
  222. Http.put(`/api/user/${this.user.id}/personalAuth`, this.individualForm).then(res => {
  223. if (res) {
  224. notify('success', '修改成功');
  225. this.$router.push('/personal/authentication')
  226. }
  227. }).catch(err => {
  228. console.log("错误信息");
  229. console.log(err);
  230. this.hideLoading();
  231. notify('error', err.data)
  232. })
  233. }
  234. },
  235. //获取当前认证状态
  236. getAuthStatus() {
  237. Http.get(`/api/user/${this.user.id}`).then(res => {
  238. if (res.personalAuthVO) {
  239. this.authType = 1 //个人已参与认证
  240. this.authStatus = res.personalAuthVO.authStatus
  241. //成功状态不可编辑,认证失败和审核中状态可编辑
  242. this.authStatus.style !== 'success' ? this.canEdit = true : null
  243. this.failureReason = res.personalAuthVO.explain
  244. this.setFormInfo(res.personalAuthVO);
  245. } else {
  246. this.authType = 0 //未参与个人认证
  247. this.canEdit = true
  248. }
  249. }).catch(err => {
  250. notify('error', err.data)
  251. })
  252. },
  253. setFormInfo(detail) {
  254. //回显认证信息
  255. this.individualForm.roleList = detail.roleList,
  256. this.individualForm.realName = detail.realName,
  257. this.individualForm.gender = detail.gender,
  258. this.individualForm.idCard = detail.idCard,
  259. this.individualForm.address = detail.address,
  260. this.individualForm.idCardPositivePhoto = detail.idCardPositivePhoto,
  261. this.individualForm.idCardBackPhoto = detail.idCardBackPhoto,
  262. this.individualForm.idCardDeadTime = detail.idCardDeadTime
  263. },
  264. //文件上传前的响应函数
  265. beforeFileUpload(file) {
  266. // 文件大小不能超过10M
  267. if (file.size > 10 * 1000 * 1000) {
  268. notify('error', '单个文件大小不能超过5M')
  269. return false;
  270. }
  271. let fileName = file.name
  272. let index = fileName.lastIndexOf('.');
  273. // 文件不能没有后缀
  274. if (index <= 0) {
  275. notify('error', '只能上传png/jpg/jpeg格式的文件')
  276. return false;
  277. }
  278. let fileSuffix = fileName.substr(index)
  279. // 文件后缀必须是.png或者.jpg
  280. if (fileSuffix !== '.jpg' && fileSuffix !== '.png' && fileSuffix !== '.jpeg') {
  281. notify('error', '只能上传png/jpg/jpeg格式的文件')
  282. return false;
  283. }
  284. },
  285. //上传文件,此处为上传图片
  286. uploadFile(param) {
  287. const formData = new FormData()
  288. let config = {
  289. //添加请求头
  290. headers: {'Content-Type': 'multipart/form-data'},
  291. }
  292. formData.append('file', param.file)
  293. //console.log(JSON.parse(this.user).userVO)
  294. Http.upload(Apis.FILE.UPLOAD_IMAGE.replace('{userId}', this.user.id), formData, config).then((res) => {
  295. if (param.data.type === 0) {
  296. this.individualForm.idCardPositivePhoto = res.data
  297. } else {
  298. this.individualForm.idCardBackPhoto = res.data
  299. }
  300. notify('success', '上传成功')
  301. }).catch(error => {
  302. notify('error', error.data)
  303. })
  304. },
  305. showLoading() {
  306. this.loading = true
  307. },
  308. hideLoading() {
  309. this.loading = false
  310. },
  311. },
  312. mounted() {
  313. this.setUserInfo();
  314. this.getAuthStatus()
  315. }
  316. }
  317. </script>
  318. <style scoped lang="less">
  319. .avatar-uploader {
  320. border-radius: 6px;
  321. cursor: pointer;
  322. position: relative;
  323. overflow: hidden;
  324. margin-right: 30px;
  325. width: 270px;
  326. height: 170px;
  327. }
  328. .avatar-uploader .el-upload {
  329. width: 270px !important;
  330. height: 170px !important;
  331. border-color: #409EFF;
  332. }
  333. .avatar-uploader .el-upload:hover {
  334. border-color: #409EFF;
  335. }
  336. .avatar-uploader-icon {
  337. font-size: 28px;
  338. color: #8c939d;
  339. width: 270px;
  340. height: 170px;
  341. line-height: 178px;
  342. text-align: center;
  343. }
  344. .avatar {
  345. width: 270px;
  346. height: 170px;
  347. display: block;
  348. }
  349. .right-modifyPsw {
  350. padding: 20px;
  351. background: rgba(255, 255, 255, 1);
  352. box-shadow: 0px 1px 6px 0px rgba(8, 6, 6, 0.13);
  353. .right-modifyPsw-title {
  354. padding: 10px;
  355. border-bottom: 1px solid #ccc;
  356. margin-bottom: 20px;
  357. }
  358. .individual-steps-wrapper {
  359. display: flex;
  360. justify-content: center;
  361. }
  362. .upload-wrapper {
  363. /*display: flex;*/
  364. /*padding: 0 30px;*/
  365. .idcard-uploader {
  366. width: 100%;
  367. .avatar {
  368. width: 100%;
  369. }
  370. .el-upload .el-upload--text {
  371. width: 100%;
  372. }
  373. }
  374. .authentication-detail {
  375. padding-left: 20px;
  376. border-left: 1px solid rgba(220, 220, 220, 1);
  377. .authentication-detail-title {
  378. font-size: 16px;
  379. font-family: Source Han Sans CN;
  380. font-weight: 600;
  381. border-bottom: 1px dashed rgba(220, 220, 220, 1);
  382. margin-bottom: 10px;
  383. padding-bottom: 5px;
  384. }
  385. .idcard-example1 {
  386. height: 140px;
  387. background-image: url("../../assets/img/idcard-example1.png");
  388. background-size: 100% 100%;
  389. }
  390. .idcard-example2 {
  391. height: 140px;
  392. background-image: url("../../assets/img/idcard-example2.png");
  393. background-size: 100% 100%;
  394. }
  395. }
  396. .authentication-detail-list {
  397. list-style-type: none;
  398. padding-left: 0;
  399. font-size: 12px;
  400. font-family: Source Han Sans CN;
  401. font-weight: 400;
  402. color: rgba(153, 153, 153, 1);
  403. li:before {
  404. content: "\2022";
  405. color: rgba(153, 153, 153, 1);
  406. font-size: 16px;
  407. margin-right: 10px;
  408. }
  409. .authentication-detail-list-blue {
  410. color: #148AE0;
  411. }
  412. }
  413. }
  414. .enterprise-brn-wrapper {
  415. margin-top: 40px;
  416. display: flex;
  417. justify-content: center;
  418. .enterprise-btn {
  419. border: 1px solid rgba(0, 118, 203, 1);
  420. width: 150px;
  421. background-color: white;
  422. color: rgba(0, 118, 203, 1);
  423. padding: 10px;
  424. margin: 0 30px;
  425. }
  426. .nextBtn {
  427. background-color: rgba(0, 118, 203, 1);
  428. color: white;
  429. }
  430. }
  431. }
  432. </style>
  433. <style lang="less">
  434. #individualAuth {
  435. .avatar-uploader .idcard-uploader {
  436. width: 100%;
  437. .avatar {
  438. width: 100%;
  439. }
  440. .el-upload .el-upload--text {
  441. width: 100% !important;
  442. }
  443. }
  444. }
  445. </style>