Explorar el Código

fix(vendor): 已有多角色身份时允许申请其他服务商角色

- checkExistingApply: status=1(已通过) 不再强制跳转服务商中心,
  改为展示当前身份卡片,保留申请入口
- 新增 handleAddRole: 点击'申请其他角色'进入表单,selectedRoles清空
- 新增 hasApprovedRole/approvedRoleLabel computed,表单顶部提示
  '当前已是XX,可勾选下方新增其他角色'
- 模板 approved 状态卡片增加'申请其他角色'按钮(紫色渐变)
- 后端 submit 本已支持多角色(只拦截pending),无改动
Sisyphus hace 4 días
padre
commit
8554fd0645
Se han modificado 1 ficheros con 44 adiciones y 3 borrados
  1. 44 3
      cfc-frontend/pages/profile/service-role-apply.vue

+ 44 - 3
cfc-frontend/pages/profile/service-role-apply.vue

@@ -21,12 +21,18 @@
         <button v-if="applyStatus === 'approved'" class="btn-center" @click="goToCenter">
           进入服务商中心
         </button>
+        <button v-if="applyStatus === 'approved'" class="btn-add-role" @click="handleAddRole">
+          申请其他角色
+        </button>
         <button class="btn-back" @click="goBack">返回首页</button>
       </view>
     </view>
 
     <!-- 申请表单 -->
     <view v-else class="form-wrap">
+      <view v-if="hasApprovedRole" class="multi-role-hint">
+        <text>📌 您当前已是 {{ approvedRoleLabel }},可勾选下方新增其他角色</text>
+      </view>
       <view class="header">
         <text class="title">服务角色申请</text>
         <text class="subtitle">选择申请角色,提交资质信息</text>
@@ -181,6 +187,18 @@ export default {
       const s = this.applyRecord.status
       return s === 0 ? 'pending' : s === 1 ? 'approved' : 'rejected'
     },
+    hasApprovedRole() {
+      return this.applyRecord && this.applyRecord.status === 1
+    },
+    approvedRoleLabel() {
+      if (!this.applyRecord || !this.applyRecord.roles) return ''
+      try {
+        const roles = JSON.parse(this.applyRecord.roles)
+        // 取第一个角色名称作为展示
+        const roleMap = { planner: '规划师', nutritionist: '营养师', butler: '管家', vendor: '服务商', article_admin: '文章管理员', activity_provider: '活动提供商' }
+        return roles.map(r => roleMap[r] || r).join('、') || '服务商'
+      } catch (e) { return '服务商' }
+    },
     statusIcon() {
       return { pending: '⏳', approved: '✅', rejected: '❌' }[this.applyStatus] || '📋'
     },
@@ -190,7 +208,7 @@ export default {
     statusDesc() {
       return {
         pending: '您的申请正在审核中,请留意消息通知',
-        approved: '恭喜!您已成功通过审核,可以开始使用服务商功能',
+        approved: '已开通服务商身份,可继续申请其他服务角色',
         rejected: '您的申请未通过审核,可查看原因后重新提交'
       }[this.applyStatus] || ''
     }
@@ -216,10 +234,11 @@ export default {
           this.applyRecord = res.data
           const status = res.data.status
           if (status === 0) {
+            // 审核中,展示进度
             this.showStatusView = true
           } else if (status === 1) {
-            // 已通过,跳转服务商中心
-            setTimeout(() => uni.redirectTo({ url: '/pages/vendor/center' }), 800)
+            // 已通过:不再强制跳转,显示当前身份卡片 + 允许申请其他角色
+            this.showStatusView = true
           } else if (status === 2) {
             // 已拒绝,显示原因
             this.showStatusView = true
@@ -370,6 +389,13 @@ export default {
     },
     goToCenter() {
       uni.redirectTo({ url: '/pages/vendor/center' })
+    },
+    handleAddRole() {
+      // 清空申请状态,展示表单,提示可多选
+      this.applyRecord = null
+      this.showStatusView = false
+      this.selectedRoles = []
+      uni.showToast({ title: '可多选新增角色', icon: 'none', duration: 2000 })
     }
   }
 }
@@ -746,4 +772,19 @@ export default {
   font-size: 24rpx;
   color: #9CA3AF;
 }
+.multi-role-hint {
+  background: linear-gradient(135deg, #EFF6FF, #DBEAFE);
+  border: 2rpx solid #BFDBFE;
+  border-radius: 12rpx;
+  padding: 18rpx 24rpx;
+  margin-bottom: 20rpx;
+}
+.multi-role-hint text {
+  font-size: 26rpx;
+  color: #1D4ED8;
+}
+.btn-add-role {
+  background: linear-gradient(135deg, #6366F1, #818CF8);
+  color: #fff;
+}
 </style>