| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584 |
- <template>
- <view class="edit-auth-container">
- <!-- 自定义头部 -->
- <view class="custom-header">
- <view class="header-left" @click="navBack">
- <image class="back-icon" src="/static/icons/chevron_right_dark.svg" style="transform: rotate(180deg);"></image>
- </view>
- <text class="header-title">修改认证信息</text>
- <view class="header-right"></view>
- </view>
- <view class="header-placeholder"></view>
- <!-- 顶部警告提示 -->
- <view class="warning-tip">
- <text class="warning-icon">⚠</text>
- <text class="warning-text">若修改认证信息,将在审核通过后生效</text>
- </view>
- <!-- 身份认证 -->
- <view class="section-card">
- <view class="section-title">身份认证</view>
- <text class="section-subtitle">点击图片修改</text>
-
- <view class="id-card-row">
- <!-- 身份证正面 -->
- <view class="id-card-upload" @click="chooseImage('front')">
- <image v-if="idCardFront" :src="idCardFront" class="id-card-img" mode="aspectFill"></image>
- <view v-else class="id-card-placeholder">
- <text class="placeholder-text">ID Front</text>
- </view>
- <view class="delete-btn" v-if="idCardFront" @click.stop="deleteImage('front')">×</view>
- <view class="corner-tag">人像面</view>
- </view>
- <!-- 身份证反面 -->
- <view class="id-card-upload" @click="chooseImage('back')">
- <image v-if="idCardBack" :src="idCardBack" class="id-card-img" mode="aspectFill"></image>
- <view v-else class="id-card-placeholder">
- <text class="placeholder-text">ID Back</text>
- </view>
- <view class="delete-btn" v-if="idCardBack" @click.stop="deleteImage('back')">×</view>
- <view class="corner-tag">国徽面</view>
- </view>
- </view>
- </view>
- <!-- 服务类型 -->
- <view class="section-card">
- <view class="section-title">服务类型</view>
- <text class="section-subtitle">可多选</text>
-
- <view class="service-list">
- <view
- class="service-item"
- v-for="(service, index) in serviceOptions"
- :key="index"
- @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>
- </view>
- </view>
- </view>
- </view>
- <!-- 资质证书 -->
- <view class="section-card">
- <view class="section-title">资质证书</view>
- <text class="section-subtitle">请上传对应服务的资质</text>
-
- <!-- 动态渲染每个服务类型的资质上传 -->
- <view v-for="(service, index) in selectedServices" :key="index" class="qual-section">
- <text class="qual-title">{{ service }}资质</text>
-
- <view class="qual-upload-row">
- <!-- 已上传的资质图片 -->
- <view
- class="qual-item"
- v-for="(img, imgIndex) in qualifications[service]"
- :key="imgIndex"
- @click="previewImage(service, imgIndex)"
- >
- <image :src="img" class="qual-img" mode="aspectFill"></image>
- <view class="delete-btn" @click.stop="deleteQualImage(service, imgIndex)">×</view>
- </view>
-
- <!-- 上传按钮 -->
- <view class="qual-upload-btn" @click="chooseQualImage(service)">
- <text class="plus-icon">+</text>
- </view>
- </view>
- </view>
- <text v-if="selectedServices.length === 0" class="empty-hint">请先选择服务类型</text>
- </view>
- <!-- 底部提交按钮 -->
- <view class="bottom-btn-area">
- <button class="submit-btn" @click="submitAuth">提交审核</button>
- </view>
- </view>
- </template>
- <script>
- import { getAuthInfo, uploadFile, updateAuthInfo } from '@/api/fulfiller'
- export default {
- data() {
- return {
- idCardFront: '',
- idCardBack: '',
- idCardFrontOssId: '',
- idCardBackOssId: '',
- serviceOptions: ['宠物接送', '上门喂遛', '上门洗护'],
- selectedServices: [],
- qualifications: {},
- qualOssIds: {}
- }
- },
- onLoad() {
- this.loadAuthInfo()
- },
- methods: {
- async loadAuthInfo() {
- try {
- uni.showLoading({ title: '加载中...' })
- const res = await getAuthInfo()
- if (res.code === 200 && res.data) {
- this.idCardFront = res.data.idCardFrontUrl || ''
- this.idCardBack = res.data.idCardBackUrl || ''
- this.idCardFrontOssId = res.data.idCardFront || ''
- this.idCardBackOssId = res.data.idCardBack || ''
- this.selectedServices = res.data.serviceTypeList || []
-
- this.selectedServices.forEach(service => {
- this.qualifications[service] = []
- this.qualOssIds[service] = []
- })
-
- if (res.data.qualImageUrls && res.data.qualImageUrls.length > 0) {
- const firstService = this.selectedServices[0]
- if (firstService) {
- this.qualifications[firstService] = res.data.qualImageUrls
- }
- }
- }
- uni.hideLoading()
- } catch (e) {
- uni.hideLoading()
- console.error('加载认证信息失败', e)
- uni.showToast({ title: '加载失败', icon: 'none' })
- }
- },
- navBack() {
- uni.navigateBack({ delta: 1 })
- },
- chooseImage(side) {
- uni.chooseImage({
- count: 1,
- sizeType: ['compressed'],
- sourceType: ['album', 'camera'],
- success: async (res) => {
- const tempPath = res.tempFilePaths[0]
- if (side === 'front') {
- this.idCardFront = tempPath
- } else {
- this.idCardBack = tempPath
- }
-
- try {
- uni.showLoading({ title: '上传中...' })
- const uploadRes = await uploadFile(tempPath)
- if (side === 'front') {
- this.idCardFrontOssId = uploadRes.data.ossId
- } else {
- this.idCardBackOssId = uploadRes.data.ossId
- }
- uni.hideLoading()
- uni.showToast({ title: '上传成功', icon: 'success' })
- } catch (err) {
- uni.hideLoading()
- console.error('上传身份证图片失败:', err)
- uni.showToast({ title: '上传失败', icon: 'none' })
- }
- }
- })
- },
- deleteImage(side) {
- if (side === 'front') {
- this.idCardFront = ''
- this.idCardFrontOssId = ''
- } else {
- this.idCardBack = ''
- this.idCardBackOssId = ''
- }
- },
- toggleService(service) {
- const index = this.selectedServices.indexOf(service)
- if (index > -1) {
- this.selectedServices.splice(index, 1)
- delete this.qualifications[service]
- delete this.qualOssIds[service]
- } else {
- this.selectedServices.push(service)
- this.qualifications[service] = []
- this.qualOssIds[service] = []
- }
- this.$forceUpdate()
- },
- chooseQualImage(service) {
- uni.chooseImage({
- count: 9,
- sizeType: ['compressed'],
- sourceType: ['album', 'camera'],
- success: async (res) => {
- if (!this.qualifications[service]) {
- this.qualifications[service] = []
- this.qualOssIds[service] = []
- }
-
- for (const tempPath of res.tempFilePaths) {
- this.qualifications[service].push(tempPath)
- this.$forceUpdate()
-
- try {
- uni.showLoading({ title: '上传中...' })
- const uploadRes = await uploadFile(tempPath)
- this.qualOssIds[service].push(uploadRes.data.ossId)
- uni.hideLoading()
- } catch (err) {
- uni.hideLoading()
- console.error('上传资质图片失败:', err)
- }
- }
- }
- })
- },
- deleteQualImage(service, index) {
- this.qualifications[service].splice(index, 1)
- if (this.qualOssIds[service]) {
- this.qualOssIds[service].splice(index, 1)
- }
- this.$forceUpdate()
- },
- previewImage(service, index) {
- uni.previewImage({
- urls: this.qualifications[service],
- current: index
- })
- },
- async submitAuth() {
- if (!this.idCardFront || !this.idCardBack) {
- uni.showToast({ title: '请上传身份证正反面', icon: 'none' })
- return
- }
-
- if (this.selectedServices.length === 0) {
- uni.showToast({ title: '请选择服务类型', icon: 'none' })
- return
- }
-
- for (const service of this.selectedServices) {
- if (!this.qualifications[service] || this.qualifications[service].length === 0) {
- uni.showToast({ title: `请上传${service}资质`, icon: 'none' })
- return
- }
- }
-
- uni.showModal({
- title: '提示',
- content: '修改认证信息需要重新审核,审核期间无法接单,确定要继续吗?',
- success: (res) => {
- if (res.confirm) {
- this.doSubmit()
- }
- }
- })
- },
- async doSubmit() {
- const allQualOssIds = []
- Object.values(this.qualOssIds).forEach(ids => {
- allQualOssIds.push(...ids)
- })
-
- const submitData = {
- idCardFront: this.idCardFrontOssId,
- idCardBack: this.idCardBackOssId,
- serviceTypes: JSON.stringify(this.selectedServices),
- qualifications: JSON.stringify(allQualOssIds)
- }
-
- try {
- uni.showLoading({ title: '提交中...' })
- await updateAuthInfo(submitData)
- uni.hideLoading()
- uni.showToast({ title: '提交成功,等待审核', icon: 'success', duration: 1500 })
- setTimeout(() => {
- uni.navigateBack({ delta: 1 })
- }, 1500)
- } catch (err) {
- uni.hideLoading()
- console.error('提交失败:', err)
- uni.showToast({ title: '提交失败', icon: 'none' })
- }
- }
- }
- }
- </script>
- <style scoped>
- page {
- background-color: #F8F8F8;
- }
- .custom-header {
- position: fixed;
- top: 0;
- left: 0;
- width: 100%;
- height: 88rpx;
- padding-top: var(--status-bar-height);
- background-color: #fff;
- display: flex;
- align-items: center;
- justify-content: space-between;
- padding-left: 30rpx;
- padding-right: 30rpx;
- box-sizing: content-box;
- z-index: 100;
- }
- .header-placeholder {
- height: calc(88rpx + var(--status-bar-height));
- }
- .back-icon {
- width: 40rpx;
- height: 40rpx;
- }
- .header-title {
- font-size: 28rpx;
- font-weight: bold;
- color: #333;
- }
- .header-right {
- width: 40rpx;
- }
- .edit-auth-container {
- padding: 20rpx 30rpx;
- padding-bottom: 180rpx;
- }
- .warning-tip {
- background: linear-gradient(90deg, #FFF3E0 0%, #FFE0B2 100%);
- border-radius: 16rpx;
- padding: 24rpx 30rpx;
- display: flex;
- align-items: center;
- margin-bottom: 30rpx;
- }
- .warning-icon {
- font-size: 32rpx;
- margin-right: 16rpx;
- }
- .warning-text {
- font-size: 26rpx;
- color: #E65100;
- flex: 1;
- }
- .section-card {
- background-color: #fff;
- border-radius: 20rpx;
- padding: 30rpx;
- margin-bottom: 30rpx;
- }
- .section-title {
- font-size: 32rpx;
- font-weight: bold;
- color: #333;
- margin-bottom: 10rpx;
- }
- .section-subtitle {
- font-size: 24rpx;
- color: #999;
- display: block;
- margin-bottom: 30rpx;
- }
- .id-card-row {
- display: flex;
- justify-content: space-between;
- }
- .id-card-upload {
- width: 48%;
- height: 200rpx;
- border-radius: 16rpx;
- position: relative;
- overflow: hidden;
- background-color: #E8F5E9;
- }
- .id-card-img {
- width: 100%;
- height: 100%;
- }
- .id-card-placeholder {
- width: 100%;
- height: 100%;
- display: flex;
- align-items: center;
- justify-content: center;
- }
- .placeholder-text {
- font-size: 36rpx;
- color: #4CAF50;
- font-weight: bold;
- }
- .delete-btn {
- position: absolute;
- top: 10rpx;
- right: 10rpx;
- width: 40rpx;
- height: 40rpx;
- background-color: rgba(255, 87, 34, 0.9);
- border-radius: 50%;
- display: flex;
- align-items: center;
- justify-content: center;
- color: #fff;
- font-size: 32rpx;
- font-weight: bold;
- }
- .corner-tag {
- position: absolute;
- right: 0;
- bottom: 0;
- background-color: rgba(0, 0, 0, 0.5);
- color: #fff;
- font-size: 20rpx;
- padding: 4rpx 10rpx;
- border-top-left-radius: 8rpx;
- }
- .service-list {
- display: flex;
- flex-direction: column;
- }
- .service-item {
- background-color: #FFF8E1;
- border-radius: 16rpx;
- padding: 24rpx 30rpx;
- margin-bottom: 20rpx;
- display: flex;
- justify-content: space-between;
- align-items: center;
- }
- .service-item:last-child {
- margin-bottom: 0;
- }
- .service-name {
- font-size: 28rpx;
- color: #333;
- }
- .check-icon {
- width: 40rpx;
- height: 40rpx;
- border: 2rpx solid #FF9800;
- border-radius: 50%;
- display: flex;
- align-items: center;
- justify-content: center;
- color: #fff;
- font-size: 24rpx;
- }
- .check-icon.active {
- background-color: #FF9800;
- }
- .qual-section {
- margin-top: 30rpx;
- }
- .qual-section:first-child {
- margin-top: 0;
- }
- .qual-title {
- font-size: 26rpx;
- color: #666;
- display: block;
- margin-bottom: 20rpx;
- }
- .qual-upload-row {
- display: flex;
- flex-wrap: wrap;
- }
- .qual-item {
- width: 150rpx;
- height: 150rpx;
- border-radius: 12rpx;
- margin-right: 20rpx;
- margin-bottom: 20rpx;
- position: relative;
- overflow: hidden;
- }
- .qual-img {
- width: 100%;
- height: 100%;
- }
- .qual-upload-btn {
- width: 150rpx;
- height: 150rpx;
- border-radius: 12rpx;
- border: 2rpx dashed #ccc;
- display: flex;
- flex-direction: column;
- align-items: center;
- justify-content: center;
- background-color: #F5F5F5;
- }
- .plus-icon {
- font-size: 60rpx;
- color: #999;
- }
- .empty-hint {
- font-size: 26rpx;
- color: #999;
- text-align: center;
- display: block;
- padding: 40rpx 0;
- }
- .bottom-btn-area {
- position: fixed;
- bottom: 0;
- left: 0;
- right: 0;
- padding: 20rpx 40rpx;
- padding-bottom: calc(20rpx + env(safe-area-inset-bottom));
- background-color: #fff;
- box-shadow: 0 -4rpx 20rpx rgba(0, 0, 0, 0.05);
- box-sizing: border-box;
- z-index: 99;
- }
- .submit-btn {
- width: 100%;
- height: 88rpx;
- background-color: #FF5722;
- color: #fff;
- font-size: 32rpx;
- border-radius: 44rpx;
- border: none;
- line-height: 88rpx;
- text-align: center;
- margin: 0 auto;
- padding: 0;
- }
- </style>
|