-
zhangwei
2024-08-23 e6dccb3b16847f4bda31f305113070596677caff
src/pages/enterprise/enterprise.vue
@@ -41,7 +41,7 @@
                  maxlength='800'></up-textarea>
            </up-form-item>
            <view class="tabbtns">
               <up-button color='#fece01' class="text-69" text="保存"></up-button>
               <up-button color='#fece01' class="text-69" text="保存" @click="saveUserCompany"></up-button>
            </view>
         </up-form>
      </view>
@@ -54,20 +54,35 @@
      apiBaseUrl
   } from '@/common/setting/constVarsHelper.js';
   import {
      onLoad,
      onShow
   } from "@dcloudio/uni-app";
   import {
      ref,
      reactive
      reactive,
      getCurrentInstance
   } from 'vue';
   // 使用 reactive 创建响应式状态
   const state = reactive({
      showSex: false,
      radio: '',
      switchVal: false,
   });
   const {
      $upload,
      $api,
      $util,
      $db
   } = getCurrentInstance().appContext.config.globalProperties
   onLoad(() => {
      let data = JSON.parse($db.get('userInfo')).userCompany
      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
      }
   })
   // 使用 ref 创建响应式引用  
   const formRef = ref(null);
   const enterpriseInfo = reactive({
@@ -83,14 +98,18 @@
   })
   //上传成功时触发
   const success = (text, e) => {
   const success = (e) => {
      //e.res 为服务器返回数据
      //上传成功回调,处理服务器返回数据【此处根据实际返回数据进行处理】
      let res = JSON.parse(e.res.data.replace(/\ufeff/g, "") || "{}")
      console.log(res.data, 'res.data');
      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 //联系人
      }
   }
   //上传失败时触发
@@ -103,6 +122,19 @@
      console.log(e, '删除')
   }
   const saveUserCompany = () => {
      $api.saveUserCompany(enterpriseInfo).then(res => {
         if (res.code == 1) {
            $api.getUser().then(res => {
               $db.set('userInfo', JSON.stringify(res.data))
            })
            $util.showToast({
               title: "保存成功!",
               icon: "success"
            })
         }
      })
   }
</script>
<style>