| | |
| | | <up-form labelPosition="left" :model="userInfo" :rules="rules" ref="formRef" labelWidth='80'> |
| | | <up-form-item label="身份证正面" prop="idCardFace" required> |
| | | <fui-upload immediate :url="`${apiBaseUrl}/api/UpFile/UploadIdCord?PageName=FRONT`" ref="uploadF" |
| | | max='1' background='#fff' @success="success('FRONT',$event)" @error="error" |
| | | max='1' background='#fff' @success="success('FRONT',$event)" @error="errorFront" |
| | | @complete="completeFront" width="300" height="150"> |
| | | <image :src="userInfo.idCardFace?userInfo.idCardFace:'/static/positive.png'" mode="widthFix" |
| | | style="width: 300rpx;height: 150rpx;"></image> |
| | |
| | | onShow, |
| | | onReady |
| | | } from "@dcloudio/uni-app"; |
| | | |
| | | import { |
| | | apiBaseUrl |
| | | } from '@/common/setting/constVarsHelper.js'; |
| | |
| | | |
| | | // let webgl = ref() |
| | | onLoad(() => { |
| | | let data = JSON.parse($db.get('userInfo')) |
| | | const userToken = $db.get("userToken"); |
| | | if (!userToken) { |
| | | uni.showToast({ |
| | | title: '请先登录!', |
| | | icon: 'none', |
| | | duration: 1000, |
| | | complete: function() { |
| | | setTimeout(function() { |
| | | uni.hideToast(); |
| | | uni.navigateTo({ |
| | | url: '/pages/login/index' |
| | | }); |
| | | }, |
| | | 1000); |
| | | } |
| | | }); |
| | | } |
| | | let data = $db.get('userInfo') ? JSON.parse($db.get('userInfo')) : null |
| | | if (data && data.userWorker) { |
| | | userInfo.idCardFace = data.userWorker ? data.userWorker.idCardFace : '' //身份证正面路径 |
| | | userInfo.idCardBack = data.userWorker ? data.userWorker.idCardBack : '' //身份证反面路径 |
| | |
| | | } |
| | | console.log(userInfo, data && data.userWorker, 'data && data.userWorker'); |
| | | }) |
| | | let uploadF = ref() |
| | | let uploadB = ref() |
| | | let isLoading = ref(false) |
| | | let rules = { |
| | | idCardFace: { |
| | |
| | | title: "保存成功!", |
| | | icon: "success" |
| | | }) |
| | | $api.getUser().then(res => { |
| | | $db.set('userInfo', JSON.stringify(res.data)) |
| | | }) |
| | | uni.navigateBack() |
| | | } |
| | | isLoading.value = false |
| | |
| | | //e.res 为服务器返回数据 |
| | | //上传成功回调,处理服务器返回数据【此处根据实际返回数据进行处理】 |
| | | let res = JSON.parse(e.res.data.replace(/\ufeff/g, "") || "{}") |
| | | console.log(res.data.url, text, res.data.url && text == 'FRONT'); |
| | | if (res.data.url && text == 'FRONT') { |
| | | userInfo.idCardFace = res.data.url //身份证正面路径 |
| | | userInfo.idCode = res.data.info.idNum //身份证号 |
| | | userInfo.name = res.data.info.name |
| | | userInfo.address = res.data.info.address |
| | | gender.value = res.data.info.sex |
| | | if (res.code == 1) { |
| | | if (res.data.url && text == 'FRONT') { |
| | | userInfo.idCardFace = res.data.url //身份证正面路径 |
| | | userInfo.idCode = res.data.info.idNum //身份证号 |
| | | userInfo.name = res.data.info.name |
| | | userInfo.address = res.data.info.address |
| | | gender.value = res.data.info.sex |
| | | } else { |
| | | userInfo.idCardBack = res.data.url //身份证反面路径 |
| | | } |
| | | } else { |
| | | userInfo.idCardBack = res.data.url //身份证反面路径 |
| | | uni.$u.toast(res.error) |
| | | if (text == 'FRONT') { |
| | | uploadF.value.deleteImage() |
| | | } else { |
| | | uploadB.value.deleteImage() |
| | | } |
| | | } |
| | | |
| | | } |
| | | //上传失败时触发 |
| | | const error = (e) => {} |
| | | const errorFront = (e) => { |
| | | console.log(e, '--------------'); |
| | | } |
| | | //选择图片或上传完成时触发 |
| | | const completeFront = (e) => { |
| | | if (e.action == 'delete') { |
| | |
| | | userInfo.name = '' |
| | | userInfo.address = '' |
| | | gender.value = '' |
| | | return |
| | | } |
| | | console.log(e, '删除') |
| | | $util.pathToBase64(e.urls[0]).then(res => { |