feat: 新增身份选择弹窗并优化登录跳转逻辑
- 新增身份选择组件,用户登录后未选择身份时弹出选择框 - 优化登录跳转逻辑,支持页面栈返回模式 - 修复跳转时参数处理的边界情况 - 新增服务配置缓存机制,减少重复请求 - 优化小程序跳转逻辑,增加防重复点击锁 - 修复订单页联系人信息初始化逻辑
这个提交包含在:
@@ -0,0 +1,155 @@
|
||||
<template>
|
||||
<view v-if="visible" class="identity-mask">
|
||||
<view class="identity-dialog">
|
||||
<text class="identity-title">请选择用户类型</text>
|
||||
<text class="identity-description">请选择您的使用身份,确认后不可自行修改</text>
|
||||
<view
|
||||
class="identity-option"
|
||||
:class="{ selected: identityChoice === 'personal' }"
|
||||
@tap="identityChoice = 'personal'"
|
||||
>
|
||||
<text class="identity-option-title">个人用户</text>
|
||||
<text class="identity-option-desc">家庭或个人使用</text>
|
||||
</view>
|
||||
<view
|
||||
class="identity-option"
|
||||
:class="{ selected: identityChoice === 'merchant' }"
|
||||
@tap="identityChoice = 'merchant'"
|
||||
>
|
||||
<text class="identity-option-title">商家用户</text>
|
||||
<text class="identity-option-desc">商家或企业使用</text>
|
||||
</view>
|
||||
<button
|
||||
class="identity-confirm"
|
||||
:disabled="!identityChoice || selectingIdentity"
|
||||
@tap="confirmIdentity"
|
||||
>
|
||||
{{ selectingIdentity ? '提交中...' : '确认选择' }}
|
||||
</button>
|
||||
</view>
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import { ref, watch } from 'vue';
|
||||
import api from '@/utils/api.js';
|
||||
import { setUser } from '@/utils/request.js';
|
||||
|
||||
const props = defineProps({
|
||||
visible: {
|
||||
type: Boolean,
|
||||
default: false
|
||||
}
|
||||
});
|
||||
|
||||
const emit = defineEmits(['update:visible', 'confirmed']);
|
||||
|
||||
const identityChoice = ref('');
|
||||
const selectingIdentity = ref(false);
|
||||
|
||||
watch(() => props.visible, (val) => {
|
||||
if (val) {
|
||||
identityChoice.value = '';
|
||||
}
|
||||
});
|
||||
|
||||
async function confirmIdentity() {
|
||||
if (!identityChoice.value || selectingIdentity.value) return;
|
||||
selectingIdentity.value = true;
|
||||
try {
|
||||
const res = await api.selectIdentity({ user_type: identityChoice.value });
|
||||
setUser(res.userinfo);
|
||||
emit('update:visible', false);
|
||||
emit('confirmed', res.userinfo);
|
||||
} catch (e) {
|
||||
// 网络响应丢失但服务端可能已保存身份时,回查 profile 确认状态
|
||||
try {
|
||||
const current = await api.profile();
|
||||
if (current && current.identity_selected) {
|
||||
setUser(current);
|
||||
emit('update:visible', false);
|
||||
emit('confirmed', current);
|
||||
}
|
||||
} catch (profileError) {}
|
||||
} finally {
|
||||
selectingIdentity.value = false;
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
@import '@/uni.scss';
|
||||
|
||||
.identity-mask {
|
||||
position: fixed;
|
||||
inset: 0;
|
||||
z-index: 999;
|
||||
background: rgba(0, 0, 0, 0.5);
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
padding: 48rpx;
|
||||
}
|
||||
|
||||
.identity-dialog {
|
||||
width: 100%;
|
||||
background: $yjyf-bg-card;
|
||||
border-radius: 24rpx;
|
||||
padding: 40rpx;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
}
|
||||
|
||||
.identity-title {
|
||||
font-size: 36rpx;
|
||||
font-weight: 700;
|
||||
color: $yjyf-text-main;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.identity-description {
|
||||
margin: 16rpx 0 32rpx;
|
||||
font-size: 25rpx;
|
||||
color: $yjyf-text-secondary;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.identity-option {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
padding: 24rpx;
|
||||
margin-bottom: 20rpx;
|
||||
border: 2rpx solid $yjyf-border-color;
|
||||
border-radius: 16rpx;
|
||||
}
|
||||
|
||||
.identity-option.selected {
|
||||
border-color: $yjyf-primary;
|
||||
background: $yjyf-primary-bg;
|
||||
}
|
||||
|
||||
.identity-option-title {
|
||||
font-size: 30rpx;
|
||||
font-weight: 600;
|
||||
color: $yjyf-text-main;
|
||||
}
|
||||
|
||||
.identity-option-desc {
|
||||
margin-top: 8rpx;
|
||||
font-size: 24rpx;
|
||||
color: $yjyf-text-secondary;
|
||||
}
|
||||
|
||||
.identity-confirm {
|
||||
width: 100%;
|
||||
margin-top: 12rpx;
|
||||
background: $yjyf-gradient-primary;
|
||||
color: $yjyf-bg-card;
|
||||
border-radius: 16rpx;
|
||||
font-size: 30rpx;
|
||||
}
|
||||
|
||||
.identity-confirm[disabled] {
|
||||
opacity: 0.5;
|
||||
}
|
||||
</style>
|
||||
@@ -315,8 +315,16 @@
|
||||
}
|
||||
}
|
||||
|
||||
function openMasterApp() {
|
||||
api.openMasterMiniProgram('pages/master/apply');
|
||||
const openingMasterApp = ref(false);
|
||||
|
||||
async function openMasterApp() {
|
||||
if (openingMasterApp.value) return;
|
||||
openingMasterApp.value = true;
|
||||
try {
|
||||
await api.openMasterMiniProgram('pages/master/hall');
|
||||
} finally {
|
||||
setTimeout(() => { openingMasterApp.value = false; }, 600);
|
||||
}
|
||||
}
|
||||
|
||||
function logout() {
|
||||
|
||||
在新工单中引用
屏蔽一个用户