IndividualAuthentication.vue 9.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308
  1. <template>
  2. <div class="create-container" v-loading="loading">
  3. <div class="create-body">
  4. <div class="title">个人信息认证</div>
  5. <el-form :model="authentication" :rules="rules" ref="authentication" label-width="12%" class="demo-report">
  6. <el-form-item label="姓名" prop="name">
  7. <el-input v-if="isModifyMode" v-model="authentication.realName"></el-input>
  8. <span v-if="!isModifyMode">{{authentication.realName}}</span>
  9. </el-form-item>
  10. <el-form-item prop="file" label="手持身份证照片">
  11. <el-upload
  12. v-if="isModifyMode"
  13. class="avatar-uploader"
  14. action=""
  15. :show-file-list="false"
  16. :http-request="uploadFile"
  17. :before-upload="beforeFileUpload">
  18. <img v-if="authentication.IDCardPhoto" :src="authentication.IDCardPhoto" class="avatar">
  19. <i v-else class="el-icon-plus avatar-uploader-icon"></i>
  20. </el-upload>
  21. <span v-if="!isModifyMode">
  22. <el-image
  23. style="width: 100px;"
  24. :src="authentication.IDCardPhoto"
  25. fit="scale-down"></el-image>
  26. </span>
  27. </el-form-item>
  28. <el-form-item label="身份证号" prop="name">
  29. <el-input v-if="isModifyMode" v-model="authentication.IDCard"></el-input>
  30. <span v-if="!isModifyMode">{{authentication.IDCard}}</span>
  31. </el-form-item>
  32. <el-form-item v-if="!isModifyMode" label="认证状态" prop="name">
  33. <el-tag :type="authentication.authStatus.style">{{authentication.authStatus.text}}</el-tag>
  34. </el-form-item>
  35. <el-form-item v-if="!isModifyMode && authentication.authStatus.text == '认证失败'" label="失败原因" prop="name">
  36. <el-link v-if="authentication.explain!=null&&authentication.explain!=''" type="danger" disabled>
  37. {{authentication.explain}}
  38. </el-link>
  39. <el-link v-if="authentication.explain==null || authentication.explain==''" type="danger" disabled>管理员未填写
  40. </el-link>
  41. </el-form-item>
  42. <el-form-item label="银行卡账户" prop="name">
  43. <el-input v-if="isModifyMode" v-model="authentication.bankAccount"></el-input>
  44. <span v-if="!isModifyMode">{{authentication.bankAccount}}</span>
  45. </el-form-item>
  46. <el-form-item label="地址" prop="name">
  47. <el-input v-if="isModifyMode" v-model="authentication.address"></el-input>
  48. <span v-if="!isModifyMode">{{authentication.address}}</span>
  49. </el-form-item>
  50. <el-form-item v-if="!isModifyMode">
  51. <div v-if="authentication.authStatus.text!='认证通过'" class="btn btn-medium btn-info" @click="modifyInfo()">修改
  52. </div>
  53. </el-form-item>
  54. <el-form-item v-if="isModifyMode">
  55. <div class="btn btn-primary btn-info" @click="updateAuthInfo()">提交</div>
  56. <div class="btn btn-primary" @click="cancelModify()">取消</div>
  57. </el-form-item>
  58. </el-form>
  59. </div>
  60. </div>
  61. </template>
  62. <script>
  63. import Http from '@/js/http'
  64. import Apis from '@/js/api'
  65. import {notify} from '@/constants/index'
  66. import {
  67. defaultValue,
  68. getAllAgencyResourceTypes,
  69. getAllServiceTypes,
  70. getCurrentIndividualAuthenInfo,
  71. getCurrentUser,
  72. getProvinceCodeByProvinceName,
  73. getProvinceNameByProvinceCode,
  74. getRolesPermissions,
  75. storageGet,
  76. storageSave,
  77. updateIndividualAuthInfo
  78. } from '@/js/index'
  79. export default {
  80. name: 'IndividualAuthentication',
  81. data () {
  82. return {
  83. userId: 0,
  84. user: {},
  85. loading: false,
  86. isModifyMode: false,
  87. authentication: {
  88. IDCardPhoto: defaultValue.image,
  89. realName: '',
  90. IDCard: '',
  91. bankAccount: '',
  92. address: '',
  93. authStatus: {},
  94. explain: ''
  95. },
  96. rules: {
  97. // name: [
  98. // {required: true, message: '请输入报告名称', trigger: 'blur'}
  99. // // { min: 3, max: 5, message: "长度在 3 到 5 个字符", trigger: "blur" }
  100. // ],
  101. // abstract: [
  102. // {
  103. // required: true,
  104. // message: '请输入摘要信息',
  105. // trigger: 'change'
  106. // }
  107. // ],
  108. // type: [
  109. // {required: true, message: '请选择报告类型', trigger: 'change'}
  110. // ],
  111. // conclusion: [
  112. // {required: true, message: '请输入报告结论', trigger: 'blur'}
  113. // ]
  114. }
  115. }
  116. },
  117. mounted () {
  118. this.$nextTick(() => {
  119. this.init()
  120. })
  121. },
  122. watch: {
  123. // authentication (val) {
  124. // this.authentication = val
  125. // },
  126. deep: true
  127. },
  128. methods: {
  129. //初始化数据
  130. init () {
  131. this.setUserInfo()
  132. this.getAuthInfo()
  133. },
  134. //加载数据
  135. getAuthInfo () {
  136. this.showLoading()
  137. getCurrentIndividualAuthenInfo(this.user.userVO.id, this.getAuthInfoSuccess, this.getAuthInfoFail)
  138. },
  139. getAuthInfoSuccess (res) {
  140. this.hideLoading()
  141. this.authentication.IDCardPhoto = res.idcardPhoto == null ? defaultValue.image : res.idcardPhoto
  142. this.authentication.realName = res.realName == null ? '暂未填写' : res.realName
  143. this.authentication.IDCard = res.idcard == null ? '暂未填写' : res.idcard
  144. this.authentication.bankAccount = res.bankAccount == null ? '暂未填写' : res.bankAccount
  145. this.authentication.address = res.address == null ? '暂未填写' : res.address
  146. this.authentication.authStatus = res.authStatus
  147. this.authentication.explain = res.explain
  148. console.log(this.authentication)
  149. },
  150. getAuthInfoFail (error) {
  151. this.hideLoading()
  152. notify('error', '加载认证信息失败:' + error.data)
  153. },
  154. //表单进入可编辑状态,可修改表单
  155. modifyInfo () {
  156. this.isModifyMode = true
  157. },
  158. //提交认证信息
  159. updateAuthInfo () {
  160. //this.isModifyMode = false
  161. this.showLoading()
  162. const newAuthentication = {
  163. userId: this.user.userVO.id,
  164. realName: this.authentication.realName,
  165. bankAccount: this.authentication.bankAccount,
  166. address: this.authentication.address,
  167. IDCardPhoto: this.authentication.IDCardPhoto,
  168. IDCard: this.authentication.IDCard,
  169. }
  170. //console.log(newAuthentication)
  171. updateIndividualAuthInfo(this.user.userVO.id, newAuthentication, this.updateAuthInfoSuccess, this.updateAuthInfoFail)
  172. },
  173. updateAuthInfoSuccess (res) {
  174. this.hideLoading()
  175. this.authentication.IDCardPhoto = res.idcardPhoto == null ? defaultValue.image : res.idcardPhoto
  176. this.authentication.realName = res.realName == null ? '暂未填写' : res.realName
  177. this.authentication.IDCard = res.idcard == null ? '暂未填写' : res.idcard
  178. this.authentication.bankAccount = res.bankAccount == null ? '暂未填写' : res.bankAccount
  179. this.authentication.address = res.address == null ? '暂未填写' : res.address
  180. this.cancelModify()
  181. notify('success', '认证信息修改成功,正在为您刷新用户信息')
  182. getCurrentUser().then(res => {
  183. storageSave('user', res)
  184. this.user = res
  185. //this.rolesPermissions = getRolesPermissions(res.roleList)
  186. storageSave('rolesPermissions', getRolesPermissions(res.roleList))
  187. this.hideLoading()
  188. notify('success', '用户信息刷新成功')
  189. }).catch((error) => {
  190. this.hideLoading()
  191. notify('error', '重新获取用户信息失败:' + error.data)
  192. })
  193. },
  194. updateAuthInfoFail (error) {
  195. this.hideLoading()
  196. notify('error', error.data)
  197. },
  198. //取消修改表单,表单进入不可编辑状态,不再使用
  199. cancelModify () {
  200. this.isModifyMode = false
  201. },
  202. //上传文件时移除文件的响应函数
  203. handleRemove (file, fileList) {
  204. console.log(file, fileList)
  205. },
  206. //添加文件时的响应函数
  207. handleExceed (files, fileList) {
  208. this.$message.warning(
  209. `当前限制选择 1 个文件,本次选择了 ${
  210. files.length
  211. } 个文件,共选择了 ${files.length + fileList.length} 个文件`
  212. )
  213. },
  214. //移除文件前的响应函数
  215. beforeRemove (file, fileList) {
  216. //return this.$confirm(`确定移除 ${file.name}?`)
  217. },
  218. //文件上传前的响应函数
  219. beforeFileUpload () {
  220. },
  221. //上传文件,此处为上传图片
  222. uploadFile (param) {
  223. const formData = new FormData()
  224. let config = {
  225. //添加请求头
  226. headers: {'Content-Type': 'multipart/form-data'},
  227. }
  228. formData.append('file', param.file)
  229. Http.upload(Apis.FILE.UPLOAD_IMAGE.replace('{userId}', this.user.userVO.id), formData, config).then((res) => {
  230. console.log('上传成功')
  231. this.authentication.photoUrl = res.data
  232. console.log(res.data)
  233. notify('success', '上传成功')
  234. }).catch(error => {
  235. notify('error', error.data.msg)
  236. })
  237. },
  238. //
  239. setUserInfo () {
  240. this.user = storageGet('user')
  241. },
  242. //
  243. showLoading () {
  244. this.loading = true
  245. },
  246. hideLoading () {
  247. this.loading = false
  248. }
  249. },
  250. created: function () {
  251. }
  252. }
  253. </script>
  254. <style scoped>
  255. .el-radio {
  256. margin: 10px 20px 10px 0;
  257. }
  258. .el-form-item /deep/ .el-tabs__content {
  259. max-height: 120px !important;
  260. overflow: auto;
  261. }
  262. .el-row {
  263. margin-bottom: 10px;
  264. }
  265. .el-input {
  266. width: 400px;
  267. }
  268. .avatar-uploader .el-upload {
  269. border: 1px dashed #d9d9d9;
  270. border-radius: 6px;
  271. cursor: pointer;
  272. position: relative;
  273. overflow: hidden;
  274. }
  275. .avatar-uploader .el-upload:hover {
  276. border-color: #409EFF;
  277. }
  278. .avatar-uploader-icon {
  279. border: 1px dashed #d9d9d9;
  280. border-radius: 6px;
  281. font-size: 28px;
  282. color: #8c939d;
  283. width: 176px;
  284. height: 178px;
  285. line-height: 178px;
  286. text-align: center;
  287. }
  288. .avatar-uploader-icon:hover {
  289. border-color: #409EFF;
  290. }
  291. .avatar {
  292. width: 178px;
  293. height: 178px;
  294. display: block;
  295. }
  296. </style>