| | |
| | | <template> |
| | | <view class="full-page"> |
| | | <view class="full-page-fff"> |
| | | <view class="content"> |
| | | <up-form labelPosition="left" :model="model1" :rules="rules" ref="form1" labelWidth='90'> |
| | | <up-form-item label="公司营业执照" prop="userInfo.sex" required borderBottom @click="showSex = true; hideKeyboard()" |
| | | ref="item1"> |
| | | <tem-upload src='/static/upload.png'/> |
| | | <up-form labelPosition="left" :model="enterpriseInfo" :rules="rules" ref="formRef" labelWidth='90'> |
| | | <up-form-item label="营业执照" prop="businessLicense" required ref="item1"> |
| | | <fui-upload immediate :url="`${apiBaseUrl}/api/UpFile/UpBizLicense`" ref="uploadB" max='1' |
| | | background='#fff' @success="success" @error="error" @complete="complete" width="300" |
| | | :sizeType='sizeType' height="150"> |
| | | <image src="/static/enterprise.png" mode="widthFix" style="width: 300rpx;height: 150rpx;"> |
| | | </image> |
| | | </fui-upload> |
| | | <!-- <template #right> |
| | | <up-icon name="arrow-right"></up-icon> |
| | | </template> --> |
| | | </up-form-item> |
| | | <up-form-item label="企业名称" required prop="userInfo.name" borderBottom ref="item1"> |
| | | <up-input v-model="state.model1.userInfo.name" border="none" placeholder="请输入企业名称"></up-input> |
| | | <up-form-item label="企业名称" required prop="suppliername" ref="item1"> |
| | | <up-input v-model="enterpriseInfo.suppliername" border="none" placeholder="请输入企业名称" |
| | | readonly></up-input> |
| | | </up-form-item> |
| | | <up-form-item label="企业注册地址" required prop="userInfo.name" borderBottom ref="item1"> |
| | | <up-input v-model="state.model1.userInfo.name" border="none" placeholder="请输入企业注册地址"></up-input> |
| | | <up-form-item label="企业注册号" required prop="suppliercode" ref="item1"> |
| | | <up-input v-model="enterpriseInfo.suppliercode" border="none" placeholder="请输入企业注册号" |
| | | readonly></up-input> |
| | | </up-form-item> |
| | | <up-form-item label="联系人" required prop="userInfo.name" borderBottom ref="item1"> |
| | | <up-input v-model="state.model1.userInfo.name" border="none" placeholder="请输入联系人"></up-input> |
| | | <up-form-item label="注册时间" required prop="regtime" ref="item1"> |
| | | <up-input v-model="enterpriseInfo.regtime" border="none" placeholder="请输入企业注册号" readonly></up-input> |
| | | </up-form-item> |
| | | <up-form-item label="联系电话" required prop="userInfo.name" borderBottom ref="item1"> |
| | | <up-input v-model="state.model1.userInfo.name" border="none" placeholder="请输入联系电话"></up-input> |
| | | <up-form-item label="企业地址" required prop="address" ref="item1"> |
| | | <up-input v-model="enterpriseInfo.address" border="none" placeholder="请输入企业地址" readonly></up-input> |
| | | </up-form-item> |
| | | |
| | | <up-form-item label="公司简介" required prop="userInfo.name" borderBottom ref="item1"> |
| | | <up-textarea v-model="state.model1.userInfo.name" placeholder="请输入公司简介" ></up-textarea> |
| | | <up-form-item label="联系人" required prop="contact" ref="item1"> |
| | | <up-input v-model="enterpriseInfo.contact" border="none" placeholder="请输入联系人"></up-input> |
| | | </up-form-item> |
| | | <up-form-item label="联系电话" required prop="phone" ref="item1"> |
| | | <up-input v-model="enterpriseInfo.phone" border="none" placeholder="请输入联系电话"></up-input> |
| | | </up-form-item> |
| | | |
| | | <up-form-item label="公司简介" required prop="resume" ref="item1"> |
| | | |
| | | </up-form-item> |
| | | <up-textarea v-model="enterpriseInfo.resume" count placeholder="请输入公司简介" height='200' |
| | | maxlength='800'></up-textarea> |
| | | <view class="tabbtns"> |
| | | <up-button color='#fece01' class="text-69" text="保存"></up-button> |
| | | <up-button color='#fece01' text="保存" :loading='isLoading' loadingText="保存中" |
| | | @click="saveUserCompany"></up-button> |
| | | </view> |
| | | </up-form> |
| | | </view> |
| | |
| | | |
| | | <script setup> |
| | | import { |
| | | apiBaseUrl |
| | | } from '@/common/setting/constVarsHelper.js'; |
| | | import { |
| | | onLoad, |
| | | onShow, |
| | | onReady |
| | | } from "@dcloudio/uni-app"; |
| | | import { |
| | | useStore |
| | | } from 'vuex' |
| | | const store = useStore() |
| | | let sizeType = ['compressed'] |
| | | let rules = { |
| | | businessLicense: { |
| | | required: true, |
| | | message: '营业执照不能为空', |
| | | trigger: ['blur', 'change'] |
| | | }, //营业执照路径 |
| | | suppliername: { |
| | | required: true, |
| | | message: '企业名称不能为空', |
| | | trigger: ['blur', 'change'] |
| | | }, //企业名称 |
| | | regtime: { |
| | | required: true, |
| | | message: '注册时间不能为空', |
| | | trigger: ['blur', 'change'] |
| | | }, //注册时间 |
| | | address: { |
| | | required: true, |
| | | message: '企业地址不能为空', |
| | | trigger: ['blur', 'change'] |
| | | }, //联系地址 |
| | | suppliercode: { |
| | | required: true, |
| | | message: '企业注册号不能为空', |
| | | trigger: ['blur', 'change'] |
| | | }, //企业注册号 |
| | | contact: { |
| | | required: true, |
| | | message: '联系人不能为空', |
| | | trigger: ['blur', 'change'] |
| | | }, //联系人 |
| | | resume: { |
| | | required: true, |
| | | message: '公司简介不能为空', |
| | | trigger: ['blur', 'change'] |
| | | }, //公司简介 |
| | | phone: [{ |
| | | required: true, |
| | | 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'], |
| | | // }, |
| | | ] |
| | | } |
| | | import { |
| | | ref, |
| | | reactive |
| | | reactive, |
| | | getCurrentInstance, |
| | | onMounted |
| | | } from 'vue'; |
| | | |
| | | // 使用 reactive 创建响应式状态 |
| | | const state = reactive({ |
| | | showSex: false, |
| | | model1: { |
| | | userInfo: { |
| | | name: '', |
| | | sex: '', |
| | | }, |
| | | }, |
| | | actions: [{ |
| | | name: '男' |
| | | }, |
| | | { |
| | | name: '女' |
| | | }, |
| | | { |
| | | name: '保密' |
| | | }, |
| | | ], |
| | | |
| | | radio: '', |
| | | switchVal: false, |
| | | }); |
| | | |
| | | const { |
| | | $upload, |
| | | $api, |
| | | $util, |
| | | $db |
| | | } = getCurrentInstance().appContext.config.globalProperties |
| | | let uploadB = ref() |
| | | onLoad(() => { |
| | | 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') ? $db.get('userInfo').userCompany : null |
| | | if (data) { |
| | | enterpriseInfo.businessLicense = data.businessLicense |
| | | enterpriseInfo.suppliername = data.suppliername //企业名称 |
| | | enterpriseInfo.regtime = data.regtime //注册时间 |
| | | enterpriseInfo.address = data.address //联系地址 |
| | | enterpriseInfo.suppliercode = data.suppliercode //企业注册号 |
| | | enterpriseInfo.contact = data.contact //联系人 |
| | | enterpriseInfo.phone = data.phone //联系电话 |
| | | enterpriseInfo.id = data.id |
| | | enterpriseInfo.resume = data.resume |
| | | } |
| | | }) |
| | | let isLoading = ref(false) |
| | | // 使用 ref 创建响应式引用 |
| | | const formRef = ref(null); |
| | | |
| | | // 定义方法 |
| | | function sexSelect(e) { |
| | | state.model1.userInfo.sex = e.name; |
| | | if (formRef.value) { |
| | | formRef.value.validateField('userInfo.sex'); |
| | | onReady(() => { |
| | | formRef.value.setRules(rules); |
| | | if (enterpriseInfo.businessLicense) { |
| | | uploadB.value.urls = [enterpriseInfo.businessLicense] |
| | | uploadB.value.status = ['success'] |
| | | } |
| | | }) |
| | | onMounted(() => { |
| | | formRef.value.setRules(rules); |
| | | console.log(formRef.value, 'formRef'); // 访问子组件Demo中的属性 |
| | | }); |
| | | const enterpriseInfo = reactive({ |
| | | id: 0, //用户公司Id |
| | | businessLicense: '', //营业执照路径 |
| | | suppliername: '', //企业名称 |
| | | regtime: '', //注册时间 |
| | | address: '', //联系地址 |
| | | suppliercode: '', //企业注册号 |
| | | contact: '', //联系人 |
| | | phone: '', //联系电话 |
| | | resume: '', //公司简介 |
| | | }) |
| | | |
| | | //上传成功时触发 |
| | | const success = (e) => { |
| | | //e.res 为服务器返回数据 |
| | | //上传成功回调,处理服务器返回数据【此处根据实际返回数据进行处理】 |
| | | let res = JSON.parse(e.res.data.replace(/\ufeff/g, "") || "{}") |
| | | console.log(res.data); |
| | | if (res.data.url) { |
| | | enterpriseInfo.businessLicense = res.data.url |
| | | enterpriseInfo.suppliername = res.data.info.name //企业名称 |
| | | enterpriseInfo.regtime = res.data.info.setDate //注册时间 |
| | | enterpriseInfo.address = res.data.info.address //联系地址 |
| | | enterpriseInfo.suppliercode = res.data.info.regNum //企业注册号 |
| | | enterpriseInfo.contact = res.data.info.person //联系人 |
| | | } |
| | | } |
| | | const isTelephone = (value) => { |
| | | value = value.replace(/[^-|\d]/g, ''); |
| | | return /^((\+86)|(86))?(1)\d{10}$/.test(value) || /^0[0-9-]{10,13}$/.test(value); |
| | | } |
| | | |
| | | |
| | | //上传失败时触发 |
| | | const error = (e) => {} |
| | | //选择图片或上传完成时触发 |
| | | const complete = (e) => { |
| | | if (e.action == 'delete') { |
| | | // 删除处理 |
| | | } |
| | | console.log(e, '删除') |
| | | |
| | | } |
| | | const getUserInfo = async () => { |
| | | await store.dispatch('getUserInfo') |
| | | uni.navigateBack() |
| | | $util.showToast({ |
| | | title: "保存成功!", |
| | | icon: "success" |
| | | }) |
| | | } |
| | | const saveUserCompany = () => { |
| | | formRef.value.validate().then(res => { |
| | | isLoading.value = true |
| | | $api.saveUserCompany(enterpriseInfo).then(res => { |
| | | if (res.code == 1) { |
| | | getUserInfo() |
| | | |
| | | } else { |
| | | $util.showToast({ |
| | | title: res.msg ? res.msg : res.error |
| | | }) |
| | | } |
| | | isLoading.value = false |
| | | }) |
| | | }).catch(errors => { |
| | | console.log(errors) |
| | | uni.$u.toast(errors[0].message) |
| | | }) |
| | | |
| | | } |
| | | </script> |
| | | |
| | | <style> |
| | | .content{ |
| | | .content { |
| | | background-color: #fff; |
| | | padding: 0 20rpx; |
| | | } |
| | | |
| | | .u-form-item__body { |
| | | padding: 5px 0 !important; |
| | | } |
| | | </style> |