IndividualAuthentication.vue 7.8 KB

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