| | |
| | | <template> |
| | | <view class="full-page"> |
| | | <view class="full-page-fff"> |
| | | <view class="content"> |
| | | <up-form labelPosition="left" :model="enterpriseInfo" :rules="rules" ref="formRef" labelWidth='90'> |
| | | <up-form-item label="营业执照" prop="enterpriseInfo.businessLicense" required ref="item1"> |
| | | <fui-upload immediate :url="`${apiBaseUrl}api/UpFile/UpBizLicense`" ref="uploadB" max='1' |
| | | <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" |
| | | height="150"> |
| | | <image |
| | | :src="enterpriseInfo.businessLicense?enterpriseInfo.businessLicense:'/static/enterprise.png'" |
| | | mode="widthFix" style="width: 300rpx;height: 150rpx;"></image> |
| | | :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> |
| | |
| | | <up-input v-model="enterpriseInfo.regtime" border="none" placeholder="请输入企业注册号" readonly></up-input> |
| | | </up-form-item> |
| | | <up-form-item label="企业地址" required prop="address" ref="item1"> |
| | | <up-input v-model="enterpriseInfo.address" border="none" placeholder="请输入企业地址" |
| | | readonly></up-input> |
| | | <up-input v-model="enterpriseInfo.address" border="none" placeholder="请输入企业地址" readonly></up-input> |
| | | </up-form-item> |
| | | <up-form-item label="联系人" required prop="contact" ref="item1"> |
| | | <up-input v-model="enterpriseInfo.contact" border="none" placeholder="请输入联系人"></up-input> |
| | |
| | | <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="保存" @click="saveUserCompany"></up-button> |
| | | <up-button color='#fece01' text="保存" :loading='isLoading' loadingText="保存中" |
| | | @click="saveUserCompany"></up-button> |
| | | </view> |
| | | </up-form> |
| | | </view> |
| | |
| | | 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'] |
| | | }, //公司简介 |
| | | phone: { |
| | | 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, |
| | |
| | | $util, |
| | | $db |
| | | } = getCurrentInstance().appContext.config.globalProperties |
| | | let uploadB = ref() |
| | | onLoad(() => { |
| | | let data = JSON.parse($db.get('userInfo')).userCompany |
| | | 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.resume = data.resume |
| | | } |
| | | }) |
| | | |
| | | let isLoading = ref(false) |
| | | // 使用 ref 创建响应式引用 |
| | | const formRef = ref(null); |
| | | onReady(() => { |
| | | formRef.value.setRules(rules); |
| | | if (enterpriseInfo.businessLicense) { |
| | | uploadB.value.urls = [enterpriseInfo.businessLicense] |
| | | uploadB.value.status = ['success'] |
| | | } |
| | | }) |
| | | onMounted(() => { |
| | | formRef.value.setRules(rules); |
| | |
| | | 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) => {} |
| | | //选择图片或上传完成时触发 |
| | |
| | | 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) { |
| | | $api.getUser().then(res => { |
| | | $db.set('userInfo', JSON.stringify(res.data)) |
| | | }) |
| | | getUserInfo() |
| | | |
| | | } else { |
| | | $util.showToast({ |
| | | title: "保存成功!", |
| | | icon: "success" |
| | | title: res.msg ? res.msg : res.error |
| | | }) |
| | | } |
| | | isLoading.value = false |
| | | }) |
| | | }).catch(errors => { |
| | | console.log(errors) |
| | |
| | | background-color: #fff; |
| | | padding: 0 20rpx; |
| | | } |
| | | .u-form-item__body{ |
| | | |
| | | .u-form-item__body { |
| | | padding: 5px 0 !important; |
| | | } |
| | | </style> |