feat: 登录异常问题调整

This commit is contained in:
duanshuwen
2025-12-26 22:59:44 +08:00
parent dfadb06934
commit ea56695099
8 changed files with 115 additions and 187 deletions

View File

@@ -1,5 +1,5 @@
{
"appid": "wx5e79df5996572539",
"appid": "wx23f86d809ae80259",
"compileType": "miniprogram",
"libVersion": "3.8.10",
"packOptions": {

View File

@@ -2,11 +2,16 @@
import { onLaunch, onShow, onHide } from "@dcloudio/uni-app";
import { getEvnUrl } from "@/request/api/config";
import { refreshToken } from "@/hooks/useGoLogin";
import { checkPhone } from "@/manager/LoginManager";
import { getStorageSyncToken } from "@/constant/token";
onLaunch(async () => {
await getEvnUrl({ versionValue: "1.0.3" });
const token = getStorageSyncToken();
if (token) {
refreshToken();
}
});
onShow(() => {

View File

@@ -12,7 +12,7 @@ import rawConfigs from '../../client-configs.json' with { type: 'json' };
export const CLIENT_CONFIGS = rawConfigs;
// 获取当前用户端配置
export const getCurrentConfig = () => CLIENT_CONFIGS.zhinian;
export const getCurrentConfig = () => CLIENT_CONFIGS.duohua;
export const clientId = getCurrentConfig().clientId;
export const appId = getCurrentConfig().appId;

View File

@@ -1,5 +1,5 @@
import { wxLogin } from "../request/api/LoginApi";
import { loginAuth, bindPhone, checkPhone } from "@/manager/LoginManager";
import { wxLogin, checkUserPhone } from "../request/api/LoginApi";
import { loginAuth, bindPhone } from "@/manager/LoginManager";
import { clientId } from "@/constant/base";
import { NOTICE_EVENT_LOGIN_SUCCESS } from "@/constant/constant";
import { getStorageSyncToken, setStorageSyncToken } from "../constant/token";
@@ -22,8 +22,9 @@ export const onLogin = async (e) => {
}
await loginAuth(e).then(async () => {
console.log("loginAuth resolve success");
// 检查手机号是否绑定
const checkRes = await checkPhone();
const checkRes = await checkUserPhone();
if (checkRes.data) {
resolve();
return;
@@ -63,24 +64,10 @@ export const checkToken = () => {
// 刷新token
export const refreshToken = () => {
return new Promise(async (resolve) => {
const token = getStorageSyncToken();
if (!token) {
resolve(true);
return;
}
const checkRes = await checkPhone();
if (!checkRes.data) {
resolve(true);
return;
}
uni.login({
provider: "weixin", //使用微信登录
success: async ({ code }) => {
console.log("refreshToken", code);
console.log("进入 refreshToken success", code);
const params = {
openIdCode: [code],
grant_type: "wechat",
@@ -88,6 +75,7 @@ export const refreshToken = () => {
clientId: clientId,
};
console.log("获取到的微信授权params:", JSON.stringify(params));
const response = await wxLogin(params);
if (response.access_token) {

View File

@@ -4,7 +4,6 @@ import {
checkUserPhone,
} from "../request/api/LoginApi";
import { getWeChatAuthCode } from "./AuthManager";
import { useAppStore } from "@/store";
import { clientId } from "@/constant/base";
import { NOTICE_EVENT_LOGIN_SUCCESS } from "@/constant/constant";
import { removeStorageSyncToken, setStorageSyncToken } from "../constant/token";
@@ -26,6 +25,7 @@ const loginAuth = (e) => {
console.log("获取到的微信授权response:", response);
if (response.access_token) {
console.log("进入条件");
setStorageSyncToken(response.access_token);
// 登录成功后,触发登录成功事件
uni.$emit(NOTICE_EVENT_LOGIN_SUCCESS);
@@ -45,9 +45,4 @@ const bindPhone = async (params) => {
}
};
const checkPhone = async () => {
const response = await checkUserPhone();
return response;
};
export { loginAuth, bindPhone, checkPhone };
export { loginAuth, bindPhone };

View File

@@ -60,7 +60,7 @@
wx23f86d809ae80259
*/
"mp-weixin": {
"appid": "wx5e79df5996572539",
"appid": "wx23f86d809ae80259",
"setting": {
"urlCheck": false,
"minified": true

View File

@@ -2,79 +2,42 @@
<view class="flex flex-col h-screen">
<!-- 顶部自定义导航栏 -->
<view class="header" :style="{ paddingTop: statusBarHeight + 'px' }">
<ChatTopNavBar
ref="topNavBarRef"
:mainPageDataModel="mainPageDataModel"
/>
<ChatTopNavBar ref="topNavBarRef" :mainPageDataModel="mainPageDataModel" />
</view>
<!-- 消息列表可滚动区域 -->
<scroll-view
class="main flex-full overflow-hidden scroll-y"
scroll-y
:scroll-top="scrollTop"
:scroll-with-animation="true"
@scroll="handleScroll"
@scrolltolower="handleScrollToLower"
>
<scroll-view class="main flex-full overflow-hidden scroll-y" scroll-y :scroll-top="scrollTop"
:scroll-with-animation="true" @scroll="handleScroll" @scrolltolower="handleScrollToLower">
<!-- welcome栏 -->
<ChatTopWelcome ref="welcomeRef" :mainPageDataModel="mainPageDataModel" />
<view
class="area-msg-list-content"
v-for="item in chatMsgList"
:key="item.msgId"
:id="item.msgId"
>
<view class="area-msg-list-content" v-for="item in chatMsgList" :key="item.msgId" :id="item.msgId">
<template v-if="item.msgType === MessageRole.AI">
<ChatCardAI
class="flex flex-justify-start"
:key="`ai-${item.msgId}-${item.msg ? item.msg.length : 0}`"
:text="item.msg || ''"
:isLoading="item.isLoading"
>
<ChatCardAI class="flex flex-justify-start" :key="`ai-${item.msgId}-${item.msg ? item.msg.length : 0}`"
:text="item.msg || ''" :isLoading="item.isLoading">
<template #content v-if="item.toolCall">
<QuickBookingComponent
v-if="item.toolCall.componentName === CompName.quickBookingCard"
/>
<DiscoveryCardComponent
v-else-if="
<QuickBookingComponent v-if="item.toolCall.componentName === CompName.quickBookingCard" />
<DiscoveryCardComponent v-else-if="
item.toolCall.componentName === CompName.discoveryCard
"
/>
<CreateServiceOrder
v-else-if="
" />
<CreateServiceOrder v-else-if="
item.toolCall.componentName === CompName.callServiceCard
"
:toolCall="item.toolCall"
/>
<Feedback
v-else-if="
" :toolCall="item.toolCall" />
<Feedback v-else-if="
item.toolCall.componentName === CompName.feedbackCard
"
:toolCall="item.toolCall"
/>
<DetailCardCompontent
v-else-if="
" :toolCall="item.toolCall" />
<DetailCardCompontent v-else-if="
item.toolCall.componentName ===
CompName.pictureAndCommodityCard
"
:toolCall="item.toolCall"
/>
<AddCarCrad
v-else-if="
" :toolCall="item.toolCall" />
<AddCarCrad v-else-if="
item.toolCall.componentName === CompName.enterLicensePlateCard
"
:toolCall="item.toolCall"
/>
" :toolCall="item.toolCall" />
</template>
<template #footer>
<!-- 这个是底部 -->
<AttachListComponent
v-if="item.question"
:question="item.question"
/>
<AttachListComponent v-if="item.question" :question="item.question" />
</template>
</ChatCardAI>
</template>
@@ -85,21 +48,15 @@
<template v-else>
<ChatCardOther class="flex flex-justify-center" :text="item.msg">
<ActivityListComponent
v-if="
<ActivityListComponent v-if="
mainPageDataModel.activityList &&
mainPageDataModel.activityList.length > 0
"
:activityList="mainPageDataModel.activityList"
/>
" :activityList="mainPageDataModel.activityList" />
<RecommendPostsComponent
v-if="
<RecommendPostsComponent v-if="
mainPageDataModel.recommendTheme &&
mainPageDataModel.recommendTheme.length > 0
"
:recommendThemeList="mainPageDataModel.recommendTheme"
/>
" :recommendThemeList="mainPageDataModel.recommendTheme" />
</ChatCardOther>
</template>
</view>
@@ -108,17 +65,9 @@
<!-- 输入框区域 -->
<view class="pb-safe-area">
<ChatQuickAccess />
<ChatInputArea
ref="inputAreaRef"
v-model="inputMessage"
:holdKeyboard="holdKeyboard"
:is-session-active="isSessionActive"
:stop-request="stopRequest"
@send="sendMessageAction"
@noHideKeyboard="handleNoHideKeyboard"
@keyboardShow="handleKeyboardShow"
@keyboardHide="handleKeyboardHide"
/>
<ChatInputArea ref="inputAreaRef" v-model="inputMessage" :holdKeyboard="holdKeyboard"
:is-session-active="isSessionActive" :stop-request="stopRequest" @send="sendMessageAction"
@noHideKeyboard="handleNoHideKeyboard" @keyboardShow="handleKeyboardShow" @keyboardHide="handleKeyboardHide" />
</view>
</view>
</template>

View File

@@ -17,17 +17,9 @@
<view class="login-agreement flex flex-items-center">
<CheckBox v-model="isAgree">
<text class="font-size-12 color-525866">我已阅读并同意</text>
<text
class="font-size-12 color-2D91FF ml-4 mr-4"
@click.stop="handleAgreeClick('service')"
>服务协议</text
>
<text class="font-size-12 color-2D91FF ml-4 mr-4" @click.stop="handleAgreeClick('service')">服务协议</text>
<text class="font-size-12 color-525866"></text>
<text
class="font-size-12 color-2D91FF ml-4 mr-4"
@click.stop="handleAgreeClick('privacy')"
>隐私协议</text
>
<text class="font-size-12 color-2D91FF ml-4 mr-4" @click.stop="handleAgreeClick('privacy')">隐私协议</text>
<text class="font-size-12 color-525866">\n</text>
<text class="font-size-12 color-525866 ml-30">授权与账号关联操作</text>
</CheckBox>
@@ -37,23 +29,13 @@
<view class="login-btn-area">
<!-- 同意隐私协议并获取手机号按钮 -->
<button
class="login-btn"
type="primary"
:open-type="needWxLogin ? 'getPhoneNumber' : ''"
@getphonenumber="getPhoneNumber"
@click="handleAgreeAndGetPhone"
>
<button class="login-btn" type="primary" :open-type="needWxLogin ? 'getPhoneNumber' : ''"
@getphonenumber="getPhoneNumber" @click="handleAgreeAndGetPhone">
手机号快捷登录
</button>
</view>
<AgreePopup
ref="agreePopup"
:visible="visible"
:agreement="computedAgreement"
@close="visible = false"
/>
<AgreePopup ref="agreePopup" :visible="visible" :agreement="computedAgreement" @close="visible = false" />
</view>
</template>
@@ -63,12 +45,14 @@ import { ref, computed } from "vue";
import {
getServiceAgreement,
getPrivacyAgreement,
checkUserPhone
} from "@/request/api/LoginApi";
import { onLogin, goBack, refreshToken } from "@/hooks/useGoLogin";
import CheckBox from "@/components/CheckBox/index.vue";
import AgreePopup from "./components/AgreePopup/index.vue";
import { zniconsMap } from "@/static/fonts/znicons.js";
import { zniconsMap } from "@/static/fonts/znicons";
import { getCurrentConfig } from "@/constant/base";
import { getStorageSyncToken } from "@/constant/token";
const needWxLogin = ref(false);
const isAgree = ref(false);
@@ -142,14 +126,21 @@ getPrivacyAgreementData();
// 页面显示时刷新token
onShow(async () => {
const res = await refreshToken();
const token = getStorageSyncToken();
needWxLogin.value = res;
if (token) {
const res = await checkUserPhone();
needWxLogin.value = res.data;
} else {
needWxLogin.value = true;
}
});
</script>
<style lang="scss" scoped>
@import "./styles/index.scss";
@font-face {
font-family: znicons;
src: url("@/static/fonts/znicons.ttf");