|
|
@@ -53,12 +53,12 @@
|
|
|
<view
|
|
|
class="service-item"
|
|
|
v-for="(service, index) in serviceOptions"
|
|
|
- :key="index"
|
|
|
+ :key="service.id"
|
|
|
@click="toggleService(service)"
|
|
|
>
|
|
|
- <text class="service-name">{{ service }}</text>
|
|
|
- <view class="check-icon" :class="{ active: selectedServices.includes(service) }">
|
|
|
- <text v-if="selectedServices.includes(service)">✓</text>
|
|
|
+ <text class="service-name">{{ service.name }}</text>
|
|
|
+ <view class="check-icon" :class="{ active: selectedServices.includes(service.id) }">
|
|
|
+ <text v-if="selectedServices.includes(service.id)">✓</text>
|
|
|
</view>
|
|
|
</view>
|
|
|
</view>
|
|
|
@@ -70,23 +70,23 @@
|
|
|
<text class="section-subtitle">请上传对应服务的资质</text>
|
|
|
|
|
|
<!-- 动态渲染每个服务类型的资质上传 -->
|
|
|
- <view v-for="(service, index) in selectedServices" :key="index" class="qual-section">
|
|
|
- <text class="qual-title">{{ service }}资质</text>
|
|
|
+ <view v-for="(serviceId, index) in selectedServices" :key="serviceId" class="qual-section">
|
|
|
+ <text class="qual-title">{{ getServiceName(serviceId) }}资质</text>
|
|
|
|
|
|
<view class="qual-upload-row">
|
|
|
<!-- 已上传的资质图片 -->
|
|
|
<view
|
|
|
class="qual-item"
|
|
|
- v-for="(img, imgIndex) in qualifications[service]"
|
|
|
+ v-for="(img, imgIndex) in qualifications[getServiceName(serviceId)]"
|
|
|
:key="imgIndex"
|
|
|
- @click="previewImage(service, imgIndex)"
|
|
|
+ @click="previewImage(getServiceName(serviceId), imgIndex)"
|
|
|
>
|
|
|
<image :src="img" class="qual-img" mode="aspectFill"></image>
|
|
|
- <view class="delete-btn" @click.stop="deleteQualImage(service, imgIndex)">×</view>
|
|
|
+ <view class="delete-btn" @click.stop="deleteQualImage(getServiceName(serviceId), imgIndex)">×</view>
|
|
|
</view>
|
|
|
|
|
|
<!-- 上传按钮 -->
|
|
|
- <view class="qual-upload-btn" @click="chooseQualImage(service)">
|
|
|
+ <view class="qual-upload-btn" @click="chooseQualImage(getServiceName(serviceId))">
|
|
|
<text class="plus-icon">+</text>
|
|
|
</view>
|
|
|
</view>
|
|
|
@@ -103,7 +103,7 @@
|
|
|
</template>
|
|
|
|
|
|
<script>
|
|
|
-import { getAuthInfo, uploadFile, updateAuthInfo } from '@/api/fulfiller'
|
|
|
+import { getAuthInfo, uploadFile, updateAuthInfo, getServiceTypes } from '@/api/fulfiller'
|
|
|
|
|
|
export default {
|
|
|
data() {
|
|
|
@@ -112,16 +112,28 @@ export default {
|
|
|
idCardBack: '',
|
|
|
idCardFrontOssId: '',
|
|
|
idCardBackOssId: '',
|
|
|
- serviceOptions: ['宠物接送', '上门喂遛', '上门洗护'],
|
|
|
+ serviceOptions: [],
|
|
|
selectedServices: [],
|
|
|
qualifications: {},
|
|
|
qualOssIds: {}
|
|
|
}
|
|
|
},
|
|
|
- onLoad() {
|
|
|
+ async onLoad() {
|
|
|
+ await this.loadServiceOptions()
|
|
|
this.loadAuthInfo()
|
|
|
},
|
|
|
methods: {
|
|
|
+ async loadServiceOptions() {
|
|
|
+ try {
|
|
|
+ const res = await getServiceTypes()
|
|
|
+ this.serviceOptions = (res.data || []).map(item => ({
|
|
|
+ id: Number(item.id),
|
|
|
+ name: item.name
|
|
|
+ }))
|
|
|
+ } catch (e) {
|
|
|
+ console.error('加载服务类型失败', e)
|
|
|
+ }
|
|
|
+ },
|
|
|
async loadAuthInfo() {
|
|
|
try {
|
|
|
uni.showLoading({ title: '加载中...' })
|
|
|
@@ -131,19 +143,33 @@ export default {
|
|
|
this.idCardBack = res.data.idCardBackUrl || ''
|
|
|
this.idCardFrontOssId = res.data.idCardFront || ''
|
|
|
this.idCardBackOssId = res.data.idCardBack || ''
|
|
|
- this.selectedServices = res.data.serviceTypeList || []
|
|
|
+ // 解析服务类型ID列表(逗号分隔,去重)
|
|
|
+ let serviceIds = []
|
|
|
+ if (res.data.serviceTypes) {
|
|
|
+ serviceIds = [...new Set(
|
|
|
+ res.data.serviceTypes.replace(/[\[\]"]/g, '').split(',')
|
|
|
+ .map(s => s.trim()).filter(s => s)
|
|
|
+ .map(Number)
|
|
|
+ .filter(id => !isNaN(id) && id > 0)
|
|
|
+ )]
|
|
|
+ }
|
|
|
+ this.selectedServices = serviceIds
|
|
|
|
|
|
- this.selectedServices.forEach(service => {
|
|
|
- this.qualifications[service] = []
|
|
|
- this.qualOssIds[service] = []
|
|
|
- })
|
|
|
+ // 解析资质图片URL和OSS ID
|
|
|
+ const qualUrlList = res.data.qualImageUrls ? res.data.qualImageUrls.split(',').filter(Boolean) : []
|
|
|
+ const qualOssIdList = res.data.qualImages ? res.data.qualImages.replace(/[\[\]"]/g, '').split(',').map(s => s.trim()).filter(Boolean) : []
|
|
|
|
|
|
- if (res.data.qualImageUrls && res.data.qualImageUrls.length > 0) {
|
|
|
- const firstService = this.selectedServices[0]
|
|
|
- if (firstService) {
|
|
|
- this.qualifications[firstService] = res.data.qualImageUrls
|
|
|
- }
|
|
|
- }
|
|
|
+ // 收集有效的服务名称列表
|
|
|
+ const validNames = serviceIds.map(sid => this.getServiceName(sid)).filter(Boolean)
|
|
|
+
|
|
|
+ // 为每个已选服务类型初始化资质数据,并均匀分配已有图片
|
|
|
+ validNames.forEach((name, idx) => {
|
|
|
+ // 将已有资质图片按服务类型数量均匀分配
|
|
|
+ const start = Math.floor(idx * qualUrlList.length / validNames.length)
|
|
|
+ const end = Math.floor((idx + 1) * qualUrlList.length / validNames.length)
|
|
|
+ this.$set(this.qualifications, name, qualUrlList.slice(start, end))
|
|
|
+ this.$set(this.qualOssIds, name, qualOssIdList.slice(start, end))
|
|
|
+ })
|
|
|
}
|
|
|
uni.hideLoading()
|
|
|
} catch (e) {
|
|
|
@@ -195,16 +221,20 @@ export default {
|
|
|
this.idCardBackOssId = ''
|
|
|
}
|
|
|
},
|
|
|
+ getServiceName(serviceId) {
|
|
|
+ const found = this.serviceOptions.find(s => s.id === serviceId)
|
|
|
+ return found ? found.name : ''
|
|
|
+ },
|
|
|
toggleService(service) {
|
|
|
- const index = this.selectedServices.indexOf(service)
|
|
|
+ const index = this.selectedServices.indexOf(service.id)
|
|
|
if (index > -1) {
|
|
|
this.selectedServices.splice(index, 1)
|
|
|
- delete this.qualifications[service]
|
|
|
- delete this.qualOssIds[service]
|
|
|
+ this.$delete(this.qualifications, service.name)
|
|
|
+ this.$delete(this.qualOssIds, service.name)
|
|
|
} else {
|
|
|
- this.selectedServices.push(service)
|
|
|
- this.qualifications[service] = []
|
|
|
- this.qualOssIds[service] = []
|
|
|
+ this.selectedServices.push(service.id)
|
|
|
+ this.$set(this.qualifications, service.name, [])
|
|
|
+ this.$set(this.qualOssIds, service.name, [])
|
|
|
}
|
|
|
this.$forceUpdate()
|
|
|
},
|
|
|
@@ -260,9 +290,10 @@ export default {
|
|
|
return
|
|
|
}
|
|
|
|
|
|
- for (const service of this.selectedServices) {
|
|
|
- if (!this.qualifications[service] || this.qualifications[service].length === 0) {
|
|
|
- uni.showToast({ title: `请上传${service}资质`, icon: 'none' })
|
|
|
+ for (const serviceId of this.selectedServices) {
|
|
|
+ const name = this.getServiceName(serviceId)
|
|
|
+ if (!this.qualifications[name] || this.qualifications[name].length === 0) {
|
|
|
+ uni.showToast({ title: `请上传${name}资质`, icon: 'none' })
|
|
|
return
|
|
|
}
|
|
|
}
|
|
|
@@ -286,8 +317,8 @@ export default {
|
|
|
const submitData = {
|
|
|
idCardFront: this.idCardFrontOssId,
|
|
|
idCardBack: this.idCardBackOssId,
|
|
|
- serviceTypes: JSON.stringify(this.selectedServices),
|
|
|
- qualifications: JSON.stringify(allQualOssIds)
|
|
|
+ serviceTypes: this.selectedServices.join(','), // 逗号分隔的服务类型ID
|
|
|
+ qualifications: allQualOssIds.join(',') // 逗号分隔的资质图片OSS ID
|
|
|
}
|
|
|
|
|
|
try {
|