myCompany.vue
4.99 KB
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
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
<template>
<view class="pd200">
<uni-forms ref="baseForm" :modelValue="baseFormData">
<view class="wItem">
<uni-forms-item label="企业名称" required >
<uni-easyinput v-model="baseFormData.entName" :disabled="baseFormData.entStatus == '0'||baseFormData.entStatus == '1'" placeholder="请输入企业名称" />
</uni-forms-item>
<uni-forms-item label="联系人" required >
<uni-easyinput v-model="baseFormData.entContacts" :disabled="baseFormData.entStatus == '0'||baseFormData.entStatus == '1'" placeholder="请输入联系人" />
</uni-forms-item>
<uni-forms-item label="电话号码" required >
<uni-easyinput v-model="baseFormData.entPhone" :disabled="baseFormData.entStatus == '0'||baseFormData.entStatus == '1'" placeholder="请输入手机号" />
</uni-forms-item>
<!-- <uni-forms-item label="所在地区" required >
<uni-easyinput v-model="baseFormData.phohenumber" placeholder="请输入手机号" />
</uni-forms-item> -->
<uni-forms-item label="地址" required >
<uni-easyinput type="textarea" :disabled="baseFormData.entStatus == '0'||baseFormData.entStatus == '1'" v-model="baseFormData.entAddress" placeholder="详细地址" />
</uni-forms-item>
</view>
<view class="wItem">
<uni-forms-item label="企业统一社会信用代码" required label-position="top" label-width="300">
<uni-easyinput :disabled="baseFormData.entStatus == '0'||baseFormData.entStatus == '1'" v-model="baseFormData.entCredit" placeholder="企业统一社会信用代码" />
</uni-forms-item>
<uni-forms-item label="营业执照" required label-position="top">
<uni-file-picker v-if="baseFormData.entStatus == null||baseFormData.entStatus == '2'" v-model="license" limit="1" @select="upPhoto" @delete="delLicense" return-type="object"></uni-file-picker>
<image v-else :src="license.url" @click="showImg"></image>
</uni-forms-item>
</view>
</uni-forms>
<view class="fixedBottom">
<button type="primary" v-if="baseFormData.entStatus == null||baseFormData.entStatus == '2'" class="btn btn1" @click="submit">提交</button>
<view v-if="baseFormData.entStatus == '0'" class="btn btn1" style="opacity: 0.8;">审核中</view>
<button type="primary" v-if="baseFormData.entStatus == '1'" class="btn btn2">审核通过</button>
</view>
</view>
</template>
<script setup>
import * as api from '@/common/api.js';
import * as loginServer from '@/common/login.js';
import config from '@/config.js';
import { ref } from 'vue';
import { onLoad, onShow } from '@dcloudio/uni-app';
const baseFormData = ref({})
const license = ref({})
onShow(()=>{
init()
})
function init(){
uni.showLoading({
title:'加载中'
})
api.getCurrentUserInfo().then(res=>{
uni.setStorageSync('currUser', res.data);
baseFormData.value.userProperty = 1
baseFormData.value.entName = res.data.entName
baseFormData.value.entPhone = res.data.entPhone
baseFormData.value.entAddress = res.data.entAddress
baseFormData.value.entContacts = res.data.entContacts
baseFormData.value.entStatus = res.data.entStatus
if(res.data.entLicense){
var obj = {
url:config.baseUrl_api + res.data.entLicense,
name: '图片',
extname: 'png'
}
license.value = obj
console.log(license.value)
}
baseFormData.value.entCredit = res.data.entCredit
uni.hideLoading()
})
}
function upPhoto(e) {
api.uploadImg(e).then(data => {
baseFormData.value.entLicense = data.data
license.value = {
url:config.baseUrl_api + data.data,
name: '图片',
extname: 'png'
}
});
}
function delLicense(){
baseFormData.value.entLicense = ''
license.value = {}
}
function submit(){
console.log(license.value)
if(!baseFormData.value.entName){
uni.showToast({
title:'请输入企业名称',
icon:'none'
})
return
}
if(!baseFormData.value.entContacts){
uni.showToast({
title:'请输入联系人',
icon:'none'
})
return
}
if(!baseFormData.value.entPhone){
uni.showToast({
title:'请输入联系电话',
icon:'none'
})
return
}
if(!baseFormData.value.entAddress){
uni.showToast({
title:'请输入地址',
icon:'none'
})
return
}
if(!baseFormData.value.entCredit){
uni.showToast({
title:'请输入信用代码',
icon:'none'
})
return
}
if(!license.value||!license.value.url){
uni.showToast({
title:'请上传营业执照',
icon:'none'
})
return
}
baseFormData.value.entStatus = '0'
uni.showLoading({
title:'加载中'
})
api.updateUserInfo(baseFormData.value).then(res=>{
uni.showToast({
title:'提交成功,等待审核',
icon:'none'
})
init()
})
}
function showImg(){
uni.previewImage({
urls: [license.value.url],
success: function(res) {
console.log('success', res)
},
fail: function(res) {
console.log('fail', res)
},
complete: function(res) {
console.log('complete', res)
}
})
}
</script>
<style scoped lang="scss">
.wItem{background-color: #fff;margin: 30rpx auto;padding: 30rpx;
width: 700rpx;box-sizing: border-box;
}
.pd200{padding-bottom: 200rpx;}
</style>