| | |
| | | <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> |
| | | <image src="/static/positive.png" mode="widthFix" style="width: 300rpx;height: 150rpx;"></image> |
| | | </fui-upload> |
| | | <!-- <template #right> |
| | | <up-icon name="arrow-right"></up-icon> |
| | |
| | | <fui-upload immediate :url="`${apiBaseUrl}/api/UpFile/UploadIdCord?PageName=Back`" ref="uploadB" |
| | | max='1' background='#fff' @success="success('Back',$event)" @error="error" @complete="complete" |
| | | width="300" height="150"> |
| | | <image :src="userInfo.idCardBack?userInfo.idCardBack:'/static/negative.png'" mode="widthFix" |
| | | style="width: 300rpx;height: 150rpx;"></image> |
| | | <image src="/static/negative.png" mode="widthFix" style="width: 300rpx;height: 150rpx;"></image> |
| | | </fui-upload> |
| | | </up-form-item> |
| | | <up-form-item label="姓名" required prop="name" ref="item1"> |
| | |
| | | <!-- <tem-session/> --> |
| | | <!-- </up-popup> --> |
| | | <view class="tabbtns"> |
| | | <up-button color='#fece01' class="text-69" text="保存" @click='saveUserWorker'></up-button> |
| | | <up-button color='#fece01' text="保存" :loading='isLoading' loadingText="保存中" |
| | | @click='saveUserWorker'></up-button> |
| | | </view> |
| | | </up-form> |
| | | </view> |
| | |
| | | onShow, |
| | | onReady |
| | | } from "@dcloudio/uni-app"; |
| | | |
| | | import { |
| | | apiBaseUrl |
| | | } from '@/common/setting/constVarsHelper.js'; |
| | | import { |
| | | onMounted, |
| | | getCurrentInstance |
| | | getCurrentInstance, |
| | | computed |
| | | } from 'vue' |
| | | import { |
| | | useStore |
| | | } from 'vuex' |
| | | const store = useStore() |
| | | const { |
| | | $upload, |
| | | $api, |
| | |
| | | |
| | | // 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') || null |
| | | if (data && data.userWorker) { |
| | | userInfo.idCardFace = data.userWorker?data.userWorker.idCardFace:'' //身份证正面路径 |
| | | userInfo.idCardBack = data.userWorker?data.userWorker.idCardBack:'' //身份证反面路径 |
| | | userInfo.idCardFace = data.userWorker ? data.userWorker.idCardFace : '' //身份证正面路径 |
| | | userInfo.idCardBack = data.userWorker ? data.userWorker.idCardBack : '' //身份证反面路径 |
| | | userInfo.name = data.userWorker.name //姓名 |
| | | userInfo.phone = data.userWorker.phone //电话号码 |
| | | userInfo.idCode = data.userWorker.idCode //身份证号 |
| | | userInfo.address = data.userWorker.address //联系地址 |
| | | userInfo.resume = data.userWorker.resume //简历描述 |
| | | userInfo.id = data.userWorker.id |
| | | |
| | | } |
| | | console.log(userInfo,data && data.userWorker,'data && data.userWorker'); |
| | | console.log(userInfo, data && data.userWorker, 'data && data.userWorker'); |
| | | }) |
| | | let uploadF = ref() |
| | | let uploadB = ref() |
| | | let isLoading = ref(false) |
| | | let rules = { |
| | | idCardFace: { |
| | | required: true, |
| | |
| | | message: '简历描述不能为空', |
| | | trigger: ['blur', 'change'] |
| | | }, //公司简介 |
| | | phone: { |
| | | phone: [{ |
| | | required: true, |
| | | message: '电话号码不能为空', |
| | | message: '联系电话不能为空', |
| | | trigger: ['blur', 'change'] |
| | | } |
| | | // , |
| | | // { |
| | | // // 自定义验证函数,见上说明 |
| | | // validator: (rule, value, callback) => { |
| | | // // 上面有说,返回true表示校验通过,返回false表示不通过 |
| | | // // uni.$u.test.mobile()就是返回true或者false的 |
| | | // return uni.$u.test.mobile(value); |
| | | // }, |
| | | // message: '联系电话不正确', |
| | | // // 触发器可以同时用blur和change |
| | | // trigger: ['change','blur'], |
| | | // }, |
| | | ] |
| | | } |
| | | let status = ref(false) |
| | | const formRef = ref() |
| | | onReady(() => { |
| | | formRef.value.setRules(rules); |
| | | if (userInfo.idCardBack) { |
| | | uploadB.value.urls = [userInfo.idCardBack] |
| | | uploadB.value.status = ['success'] |
| | | } |
| | | if (userInfo.idCardFace) { |
| | | uploadF.value.urls = [userInfo.idCardFace] |
| | | uploadF.value.status = ['success'] |
| | | } |
| | | |
| | | }) |
| | | onMounted(() => { |
| | | formRef.value.setRules(rules); |
| | |
| | | resume: '', //简历描述 |
| | | id: 0 |
| | | }) |
| | | |
| | | const IaiAddPerso = (e) => { |
| | | |
| | | const getUserInfo = () => { |
| | | store.dispatch('getUserInfo') |
| | | } |
| | | |
| | | const saveUserWorkerApi = () => { |
| | | $api.saveUserWorker(userInfo).then(res => { |
| | | if (res.code == 1) { |
| | | getUserInfo() |
| | | uni.navigateBack() |
| | | $util.showToast({ |
| | | title: "保存成功!", |
| | | icon: "success" |
| | | }) |
| | | } |
| | | isLoading.value = false |
| | | }) |
| | | } |
| | | const saveUserWorker = (e) => { |
| | | formRef.value.validate().then(res => { |
| | | let obj = { |
| | | imgBase64: idCardFaceBase64, |
| | | cordId: userInfo.idCode, //身份证号码 |
| | | name: userInfo.name, //姓名 |
| | | gender: gender.value == '男' ? 1 : 2 //性别 |
| | | } |
| | | $api.IaiAddPersoBase64(obj).then(res => { |
| | | if (res.data.isOK == true) { |
| | | $api.saveUserWorker(userInfo).then(res => { |
| | | if (res.code == 1) { |
| | | $util.showToast({ |
| | | title: "保存成功!", |
| | | icon: "success" |
| | | }) |
| | | } |
| | | }) |
| | | isLoading.value = true |
| | | console.log(idCardFaceBase64.value, 'idCardFaceBase64.value’'); |
| | | if (idCardFaceBase64.value) { |
| | | let obj = { |
| | | imgBase64: idCardFaceBase64.value, |
| | | cordId: userInfo.idCode, //身份证号码 |
| | | name: userInfo.name, //姓名 |
| | | gender: gender.value == '男' ? 1 : 2 //性别 |
| | | } |
| | | }) |
| | | $api.IaiAddPersoBase64(obj).then(res => { |
| | | if (res.data && res.data.isOK == true) { |
| | | saveUserWorkerApi() |
| | | } else { |
| | | $util.showToast({ |
| | | title: res.error |
| | | }) |
| | | isLoading.value = false |
| | | } |
| | | }) |
| | | } else { |
| | | saveUserWorkerApi() |
| | | } |
| | | |
| | | }).catch(errors => { |
| | | console.log(errors) |
| | | uni.$u.toast(errors[0].message) |
| | |
| | | //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 => { |
| | | idCardFaceBase64 = res |
| | | idCardFaceBase64.value = res |
| | | console.log(idCardFaceBase64, idCardFaceBase64.value); |
| | | }) |
| | | } |
| | | const complete = (e) => { |
| | |
| | | .fui-upload__item { |
| | | margin-top: 20rpx !important; |
| | | } |
| | | .u-form-item__body { |
| | | padding: 5px 0 !important; |
| | | } |
| | | </style> |