IndividualAuth.vue 16 KB

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