123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314 |
- <template>
- <div class="create-container" v-loading="loading">
- <div class="create-body">
- <div class="title">个人信息认证</div>
- <el-form :model="authentication" :rules="rules" ref="authentication" label-width="12%" class="demo-report">
- <el-form-item label="姓名" prop="realName">
- <el-input size="small" v-if="isModifyMode" v-model="authentication.realName"></el-input>
- <!--<span v-if="!isModifyMode">{{authentication.name}}</span>-->
- </el-form-item>
- <el-form-item prop="IDCardPhoto" label="手持身份证照片">
- <el-upload
- class="avatar-uploader"
- action=""
- :show-file-list="false"
- :http-request="uploadFile"
- :before-upload="beforeFileUpload">
- <img v-if="authentication.IDCardPhoto" :src="authentication.IDCardPhoto" class="avatar">
- <i v-else class="el-icon-plus avatar-uploader-icon"></i>
- </el-upload>
- <!--<div v-if="!isModifyMode">-->
- <!--<span v-if="authentication.photo==null">暂无文件</span>-->
- <!--<a :href="authentication.photo" v-if="authentication.photo!=null"><i class="fa fa-file-text-o"></i>-->
- <!--{{authentication.photo}}</a>-->
- <!--</div>-->
- </el-form-item>
- <el-form-item label="身份证号" prop="IDCard">
- <el-input size="small" v-if="isModifyMode" v-model="authentication.IDCard"></el-input>
- <!--<span v-if="!isModifyMode">{{authentication.name}}</span>-->
- </el-form-item>
- <el-form-item label="银行卡账户" prop="bankAccount">
- <el-input size="small" v-if="isModifyMode" v-model="authentication.bankAccount"></el-input>
- <!--<span v-if="!isModifyMode">{{authentication.bankAccount}}</span>-->
- </el-form-item>
- <el-form-item label="地址" prop="address">
- <el-input size="small" v-if="isModifyMode" v-model="authentication.address"></el-input>
- <!--<span v-if="!isModifyMode">{{authentication.address}}</span>-->
- </el-form-item>
- <!--<el-form-item v-if="!isModifyMode">-->
- <!--<div class="btn btn-medium btn-info" @click="modifyInfo()">修改</div>-->
- <!--<div class="btn btn-medium" @click="cancelModify()">返回</div>-->
- <!--</el-form-item>-->
- <el-form-item v-if="isModifyMode">
- <div class="btn btn-primary btn-info" @click="submitInfo()">提交</div>
- <!--<div class="btn btn-primary" @click="cancelModify()">取消</div>-->
- </el-form-item>
- </el-form>
- </div>
- </div>
- </template>
- <script>
- import Http from '@/js/http'
- import Apis from '@/js/api'
- import {notify} from '@/constants/index'
- import {
- getAllAgencyResourceTypes,
- getAllServiceTypes,
- getCurrentUser,
- getProvinceCodeByProvinceName,
- getProvinceNameByProvinceCode,
- getRolesPermissions,
- storageGet,
- storageSave,
- uploadIndividualAuthenticationInfo,
- } from '@/js/index'
- export default {
- name: 'IndividualAuthenticationCreate',
- data () {
- return {
- userId: 0,
- user: {},
- isModifyMode: true,
- loading: false,
- authentication: {
- IDCardPhoto: '',
- realName: '',
- IDCard: '',
- bankAccount: '',
- address: '',
- },
- rules: {
- IDCard: [
- {required: true, message: '请输入身份证号', trigger: 'blur'},
- {min: 18, max: 18, message: '身份证号输入有误', trigger: 'blur'}
- ],
- realName: [
- {required: true, message: '请输入身份证上的姓名', trigger: 'blur'},
- ],
- IDCardPhoto: [
- {
- validator: (rule, value, callback) => {
- console.log(value);
- if (value == null || value == '') {
- callback(new Error('手持身份证照片不能为空'))
- } else {
- callback()
- }
- },
- trigger: 'blue'
- },
- ],
- bankAccount: [
- {required: true, message: '请输入银行卡账户', trigger: 'blur'},
- {
- validator: (rule, value, callback) => {
- if (!this.checkNumber(value)) {
- callback(new Error('银行卡账户输入有误'))
- } else {
- callback()
- }
- }, trigger: 'blur'
- },
- ],
- address: [
- {required: true, message: '请输入地址', trigger: 'blur'}
- ],
- }
- }
- },
- mounted () {
- this.$nextTick(() => {
- this.init()
- })
- },
- methods: {
- //初始化数据
- init () {
- this.setUserInfo()
- },
- //加载数据
- loadData: function () {
- },
- //表单进入可编辑状态,可修改表单,不再使用
- modifyInfo () {
- this.isModifyMode = true
- },
- //提交认证信息
- submitInfo () {
- //this.isModifyMode = false
- this.$refs['authentication'].validate(valid => {
- if (valid) {
- this.showLoading()
- const newAuthentication = {
- userId: this.user.userVO.id,
- realName: this.authentication.realName,
- IDCard: this.authentication.IDCard,
- IDCardPhoto: this.authentication.IDCardPhoto,
- bankAccount: this.authentication.bankAccount,
- address: this.authentication.address
- }
- uploadIndividualAuthenticationInfo(this.user.userVO.id, newAuthentication, this.submitInfoSuccess, this.submitInfoFail)
- } else {
- notify('error', '表单填写错误!')
- return false
- }
- })
- },
- submitInfoSuccess (res) {
- console.log(res)
- getCurrentUser().then(res => {
- storageSave('user', res)
- this.user = res
- //this.rolesPermissions = getRolesPermissions(res.roleList)
- storageSave('rolesPermissions', getRolesPermissions(res.roleList))
- this.hideLoading()
- //notify('success', '用户信息刷新成功')
- this.sendBusMessage()
- this.$confirm('认证信息提交成功,将于10个工作日内审核完成')
- .then(_ => {
- //done()
- this.$router.push({
- name: 'IndividualAuthentication',
- params: {userId: this.user.userVO.id}
- })
- this.hideDialog()
- })
- .catch(_ => {
- this.$router.push({
- name: 'IndividualAuthentication',
- params: {userId: this.user.userVO.id}
- })
- })
- }).catch((error) => {
- this.hideLoading()
- notify('error', '重新获取用户信息失败:' + error.data)
- })
- },
- submitInfoFail (error) {
- this.hideLoading()
- notify('error', error.data)
- },
- //取消修改表单,表单进入不可编辑状态,不再使用
- cancelModify () {
- this.isModifyMode = false
- },
- //上传文件时移除文件的响应函数
- handleRemove (file, fileList) {
- console.log(file, fileList)
- },
- //添加文件时的响应函数
- handleExceed (files, fileList) {
- this.$message.warning(
- `当前限制选择 1 个文件,本次选择了 ${
- files.length
- } 个文件,共选择了 ${files.length + fileList.length} 个文件`
- )
- },
- //移除文件前的响应函数
- beforeRemove (file, fileList) {
- //return this.$confirm(`确定移除 ${file.name}?`)
- },
- //文件上传前的响应函数
- beforeFileUpload () {
- },
- //上传文件,此处为上传图片
- uploadFile (param) {
- this.showLoading()
- const formData = new FormData()
- let config = {
- //添加请求头
- headers: {'Content-Type': 'multipart/form-data'},
- }
- formData.append('file', param.file)
- Http.upload(Apis.FILE.UPLOAD_IMAGE.replace('{userId}', this.user.userVO.id), formData, config).then((res) => {
- this.hideLoading()
- console.log('上传成功')
- this.authentication.IDCardPhoto = res.data
- console.log(res.data)
- notify('success', '上传成功')
- this.$refs['authentication'].validateField('IDCardPhoto');
- }).catch(error => {
- this.hideLoading()
- notify('error', error.data.msg)
- })
- },
- //
- setUserInfo () {
- this.user = storageGet('user')
- },
- showLoading () {
- this.loading = true
- },
- hideLoading () {
- this.loading = false
- },
- sendBusMessage () {
- this.$root.$emit('user', this.user)
- },
- checkNumber(value){
- return /^\d+$/.test(value);
- },
- },
- created: function () {
- }
- }
- </script>
- <style scoped>
- .el-radio {
- margin: 10px 20px 10px 0;
- }
- .el-form-item /deep/ .el-tabs__content {
- max-height: 120px !important;
- overflow: auto;
- }
- .el-row {
- margin-bottom: 10px;
- }
- .el-input {
- width: 400px;
- }
- .avatar-uploader .el-upload {
- border: 1px dashed #d9d9d9;
- border-radius: 6px;
- cursor: pointer;
- position: relative;
- overflow: hidden;
- }
- .avatar-uploader .el-upload:hover {
- border-color: #409EFF;
- }
- .avatar-uploader-icon {
- border: 1px dashed #d9d9d9;
- border-radius: 6px;
- font-size: 28px;
- color: #8c939d;
- width: 176px;
- height: 178px;
- line-height: 178px;
- text-align: center;
- }
- .avatar-uploader-icon:hover {
- border-color: #409EFF;
- }
- .avatar {
- width: 178px;
- height: 178px;
- display: block;
- }
- </style>
|