IndividualAuth.vue 13 KB

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