-
zhangwei
2024-08-23 e6dccb3b16847f4bda31f305113070596677caff
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
<template>
    <view class="full-page">
        <view class="content">
            <up-form labelPosition="left" :model="enterpriseInfo" :rules="rules" ref="form1" labelWidth='90'>
                <up-form-item label="公司营业执照" prop="enterpriseInfo.businessLicense" required borderBottom 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>
                    </fui-upload>
                    <!-- <template #right>
                        <up-icon name="arrow-right"></up-icon>
                    </template> -->
                </up-form-item>
                <up-form-item label="企业名称" required prop="enterpriseInfo.suppliername" borderBottom ref="item1">
                    <up-input v-model="enterpriseInfo.suppliername" border="none" placeholder="请输入企业名称"
                        readonly></up-input>
                </up-form-item>
                <up-form-item label="企业注册号" required prop="enterpriseInfo.suppliercode" borderBottom ref="item1">
                    <up-input v-model="enterpriseInfo.suppliercode" border="none" placeholder="请输入企业注册号"
                        readonly></up-input>
                </up-form-item>
                <up-form-item label="注册时间" required prop="enterpriseInfo.regtime" borderBottom ref="item1">
                    <up-input v-model="enterpriseInfo.regtime" border="none" placeholder="请输入企业注册号" readonly></up-input>
                </up-form-item>
                <up-form-item label="企业注册地址" required prop="enterpriseInfo.address" borderBottom ref="item1">
                    <up-input v-model="enterpriseInfo.address" border="none" placeholder="请输入企业注册地址"
                        readonly></up-input>
                </up-form-item>
                <up-form-item label="联系人" required prop="enterpriseInfo.contact" borderBottom ref="item1">
                    <up-input v-model="enterpriseInfo.contact" border="none" placeholder="请输入联系人"></up-input>
                </up-form-item>
                <up-form-item label="联系电话" required prop="enterpriseInfo.phone" borderBottom ref="item1">
                    <up-input v-model="enterpriseInfo.phone" border="none" placeholder="请输入联系电话"></up-input>
                </up-form-item>
 
                <up-form-item label="公司简介" required prop="enterpriseInfo.resume" borderBottom ref="item1">
                    <up-textarea v-model="enterpriseInfo.resume" count placeholder="请输入公司简介"
                        maxlength='800'></up-textarea>
                </up-form-item>
                <view class="tabbtns">
                    <up-button color='#fece01' class="text-69" text="保存" @click="saveUserCompany"></up-button>
                </view>
            </up-form>
        </view>
 
    </view>
</template>
 
<script setup>
    import {
        apiBaseUrl
    } from '@/common/setting/constVarsHelper.js';
    import {
        onLoad,
        onShow
    } from "@dcloudio/uni-app";
 
    import {
        ref,
        reactive,
        getCurrentInstance
    } from 'vue';
    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({
        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 error = (e) => {}
    //选择图片或上传完成时触发
    const complete = (e) => {
        if (e.action == 'delete') {
            // 删除处理
        }
        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>
    .content {
        background-color: #fff;
        padding: 0 20rpx;
    }
</style>