feat: 登录异常问题调整
This commit is contained in:
@@ -1,5 +1,5 @@
|
|||||||
{
|
{
|
||||||
"appid": "wx5e79df5996572539",
|
"appid": "wx23f86d809ae80259",
|
||||||
"compileType": "miniprogram",
|
"compileType": "miniprogram",
|
||||||
"libVersion": "3.8.10",
|
"libVersion": "3.8.10",
|
||||||
"packOptions": {
|
"packOptions": {
|
||||||
|
|||||||
@@ -2,11 +2,16 @@
|
|||||||
import { onLaunch, onShow, onHide } from "@dcloudio/uni-app";
|
import { onLaunch, onShow, onHide } from "@dcloudio/uni-app";
|
||||||
import { getEvnUrl } from "@/request/api/config";
|
import { getEvnUrl } from "@/request/api/config";
|
||||||
import { refreshToken } from "@/hooks/useGoLogin";
|
import { refreshToken } from "@/hooks/useGoLogin";
|
||||||
import { checkPhone } from "@/manager/LoginManager";
|
import { getStorageSyncToken } from "@/constant/token";
|
||||||
|
|
||||||
onLaunch(async () => {
|
onLaunch(async () => {
|
||||||
await getEvnUrl({ versionValue: "1.0.3" });
|
await getEvnUrl({ versionValue: "1.0.3" });
|
||||||
|
|
||||||
|
const token = getStorageSyncToken();
|
||||||
|
|
||||||
|
if (token) {
|
||||||
refreshToken();
|
refreshToken();
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
onShow(() => {
|
onShow(() => {
|
||||||
|
|||||||
@@ -12,7 +12,7 @@ import rawConfigs from '../../client-configs.json' with { type: 'json' };
|
|||||||
export const CLIENT_CONFIGS = rawConfigs;
|
export const CLIENT_CONFIGS = rawConfigs;
|
||||||
|
|
||||||
// 获取当前用户端配置
|
// 获取当前用户端配置
|
||||||
export const getCurrentConfig = () => CLIENT_CONFIGS.zhinian;
|
export const getCurrentConfig = () => CLIENT_CONFIGS.duohua;
|
||||||
export const clientId = getCurrentConfig().clientId;
|
export const clientId = getCurrentConfig().clientId;
|
||||||
export const appId = getCurrentConfig().appId;
|
export const appId = getCurrentConfig().appId;
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
import { wxLogin } from "../request/api/LoginApi";
|
import { wxLogin, checkUserPhone } from "../request/api/LoginApi";
|
||||||
import { loginAuth, bindPhone, checkPhone } from "@/manager/LoginManager";
|
import { loginAuth, bindPhone } from "@/manager/LoginManager";
|
||||||
import { clientId } from "@/constant/base";
|
import { clientId } from "@/constant/base";
|
||||||
import { NOTICE_EVENT_LOGIN_SUCCESS } from "@/constant/constant";
|
import { NOTICE_EVENT_LOGIN_SUCCESS } from "@/constant/constant";
|
||||||
import { getStorageSyncToken, setStorageSyncToken } from "../constant/token";
|
import { getStorageSyncToken, setStorageSyncToken } from "../constant/token";
|
||||||
@@ -22,8 +22,9 @@ export const onLogin = async (e) => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
await loginAuth(e).then(async () => {
|
await loginAuth(e).then(async () => {
|
||||||
|
console.log("loginAuth resolve success");
|
||||||
// 检查手机号是否绑定
|
// 检查手机号是否绑定
|
||||||
const checkRes = await checkPhone();
|
const checkRes = await checkUserPhone();
|
||||||
if (checkRes.data) {
|
if (checkRes.data) {
|
||||||
resolve();
|
resolve();
|
||||||
return;
|
return;
|
||||||
@@ -63,24 +64,10 @@ export const checkToken = () => {
|
|||||||
// 刷新token
|
// 刷新token
|
||||||
export const refreshToken = () => {
|
export const refreshToken = () => {
|
||||||
return new Promise(async (resolve) => {
|
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({
|
uni.login({
|
||||||
provider: "weixin", //使用微信登录
|
provider: "weixin", //使用微信登录
|
||||||
success: async ({ code }) => {
|
success: async ({ code }) => {
|
||||||
console.log("refreshToken", code);
|
console.log("进入 refreshToken success", code);
|
||||||
const params = {
|
const params = {
|
||||||
openIdCode: [code],
|
openIdCode: [code],
|
||||||
grant_type: "wechat",
|
grant_type: "wechat",
|
||||||
@@ -88,6 +75,7 @@ export const refreshToken = () => {
|
|||||||
clientId: clientId,
|
clientId: clientId,
|
||||||
};
|
};
|
||||||
console.log("获取到的微信授权params:", JSON.stringify(params));
|
console.log("获取到的微信授权params:", JSON.stringify(params));
|
||||||
|
|
||||||
const response = await wxLogin(params);
|
const response = await wxLogin(params);
|
||||||
|
|
||||||
if (response.access_token) {
|
if (response.access_token) {
|
||||||
|
|||||||
@@ -4,7 +4,6 @@ import {
|
|||||||
checkUserPhone,
|
checkUserPhone,
|
||||||
} from "../request/api/LoginApi";
|
} from "../request/api/LoginApi";
|
||||||
import { getWeChatAuthCode } from "./AuthManager";
|
import { getWeChatAuthCode } from "./AuthManager";
|
||||||
import { useAppStore } from "@/store";
|
|
||||||
import { clientId } from "@/constant/base";
|
import { clientId } from "@/constant/base";
|
||||||
import { NOTICE_EVENT_LOGIN_SUCCESS } from "@/constant/constant";
|
import { NOTICE_EVENT_LOGIN_SUCCESS } from "@/constant/constant";
|
||||||
import { removeStorageSyncToken, setStorageSyncToken } from "../constant/token";
|
import { removeStorageSyncToken, setStorageSyncToken } from "../constant/token";
|
||||||
@@ -26,6 +25,7 @@ const loginAuth = (e) => {
|
|||||||
console.log("获取到的微信授权response:", response);
|
console.log("获取到的微信授权response:", response);
|
||||||
|
|
||||||
if (response.access_token) {
|
if (response.access_token) {
|
||||||
|
console.log("进入条件");
|
||||||
setStorageSyncToken(response.access_token);
|
setStorageSyncToken(response.access_token);
|
||||||
// 登录成功后,触发登录成功事件
|
// 登录成功后,触发登录成功事件
|
||||||
uni.$emit(NOTICE_EVENT_LOGIN_SUCCESS);
|
uni.$emit(NOTICE_EVENT_LOGIN_SUCCESS);
|
||||||
@@ -45,9 +45,4 @@ const bindPhone = async (params) => {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
const checkPhone = async () => {
|
export { loginAuth, bindPhone };
|
||||||
const response = await checkUserPhone();
|
|
||||||
return response;
|
|
||||||
};
|
|
||||||
|
|
||||||
export { loginAuth, bindPhone, checkPhone };
|
|
||||||
|
|||||||
@@ -60,7 +60,7 @@
|
|||||||
朵花:wx23f86d809ae80259
|
朵花:wx23f86d809ae80259
|
||||||
*/
|
*/
|
||||||
"mp-weixin": {
|
"mp-weixin": {
|
||||||
"appid": "wx5e79df5996572539",
|
"appid": "wx23f86d809ae80259",
|
||||||
"setting": {
|
"setting": {
|
||||||
"urlCheck": false,
|
"urlCheck": false,
|
||||||
"minified": true
|
"minified": true
|
||||||
|
|||||||
@@ -2,79 +2,42 @@
|
|||||||
<view class="flex flex-col h-screen">
|
<view class="flex flex-col h-screen">
|
||||||
<!-- 顶部自定义导航栏 -->
|
<!-- 顶部自定义导航栏 -->
|
||||||
<view class="header" :style="{ paddingTop: statusBarHeight + 'px' }">
|
<view class="header" :style="{ paddingTop: statusBarHeight + 'px' }">
|
||||||
<ChatTopNavBar
|
<ChatTopNavBar ref="topNavBarRef" :mainPageDataModel="mainPageDataModel" />
|
||||||
ref="topNavBarRef"
|
|
||||||
:mainPageDataModel="mainPageDataModel"
|
|
||||||
/>
|
|
||||||
</view>
|
</view>
|
||||||
|
|
||||||
<!-- 消息列表(可滚动区域) -->
|
<!-- 消息列表(可滚动区域) -->
|
||||||
<scroll-view
|
<scroll-view class="main flex-full overflow-hidden scroll-y" scroll-y :scroll-top="scrollTop"
|
||||||
class="main flex-full overflow-hidden scroll-y"
|
:scroll-with-animation="true" @scroll="handleScroll" @scrolltolower="handleScrollToLower">
|
||||||
scroll-y
|
|
||||||
:scroll-top="scrollTop"
|
|
||||||
:scroll-with-animation="true"
|
|
||||||
@scroll="handleScroll"
|
|
||||||
@scrolltolower="handleScrollToLower"
|
|
||||||
>
|
|
||||||
<!-- welcome栏 -->
|
<!-- welcome栏 -->
|
||||||
<ChatTopWelcome ref="welcomeRef" :mainPageDataModel="mainPageDataModel" />
|
<ChatTopWelcome ref="welcomeRef" :mainPageDataModel="mainPageDataModel" />
|
||||||
|
|
||||||
<view
|
<view class="area-msg-list-content" v-for="item in chatMsgList" :key="item.msgId" :id="item.msgId">
|
||||||
class="area-msg-list-content"
|
|
||||||
v-for="item in chatMsgList"
|
|
||||||
:key="item.msgId"
|
|
||||||
:id="item.msgId"
|
|
||||||
>
|
|
||||||
<template v-if="item.msgType === MessageRole.AI">
|
<template v-if="item.msgType === MessageRole.AI">
|
||||||
<ChatCardAI
|
<ChatCardAI class="flex flex-justify-start" :key="`ai-${item.msgId}-${item.msg ? item.msg.length : 0}`"
|
||||||
class="flex flex-justify-start"
|
:text="item.msg || ''" :isLoading="item.isLoading">
|
||||||
:key="`ai-${item.msgId}-${item.msg ? item.msg.length : 0}`"
|
|
||||||
:text="item.msg || ''"
|
|
||||||
:isLoading="item.isLoading"
|
|
||||||
>
|
|
||||||
<template #content v-if="item.toolCall">
|
<template #content v-if="item.toolCall">
|
||||||
<QuickBookingComponent
|
<QuickBookingComponent v-if="item.toolCall.componentName === CompName.quickBookingCard" />
|
||||||
v-if="item.toolCall.componentName === CompName.quickBookingCard"
|
<DiscoveryCardComponent v-else-if="
|
||||||
/>
|
|
||||||
<DiscoveryCardComponent
|
|
||||||
v-else-if="
|
|
||||||
item.toolCall.componentName === CompName.discoveryCard
|
item.toolCall.componentName === CompName.discoveryCard
|
||||||
"
|
" />
|
||||||
/>
|
<CreateServiceOrder v-else-if="
|
||||||
<CreateServiceOrder
|
|
||||||
v-else-if="
|
|
||||||
item.toolCall.componentName === CompName.callServiceCard
|
item.toolCall.componentName === CompName.callServiceCard
|
||||||
"
|
" :toolCall="item.toolCall" />
|
||||||
:toolCall="item.toolCall"
|
<Feedback v-else-if="
|
||||||
/>
|
|
||||||
<Feedback
|
|
||||||
v-else-if="
|
|
||||||
item.toolCall.componentName === CompName.feedbackCard
|
item.toolCall.componentName === CompName.feedbackCard
|
||||||
"
|
" :toolCall="item.toolCall" />
|
||||||
:toolCall="item.toolCall"
|
<DetailCardCompontent v-else-if="
|
||||||
/>
|
|
||||||
<DetailCardCompontent
|
|
||||||
v-else-if="
|
|
||||||
item.toolCall.componentName ===
|
item.toolCall.componentName ===
|
||||||
CompName.pictureAndCommodityCard
|
CompName.pictureAndCommodityCard
|
||||||
"
|
" :toolCall="item.toolCall" />
|
||||||
:toolCall="item.toolCall"
|
<AddCarCrad v-else-if="
|
||||||
/>
|
|
||||||
<AddCarCrad
|
|
||||||
v-else-if="
|
|
||||||
item.toolCall.componentName === CompName.enterLicensePlateCard
|
item.toolCall.componentName === CompName.enterLicensePlateCard
|
||||||
"
|
" :toolCall="item.toolCall" />
|
||||||
:toolCall="item.toolCall"
|
|
||||||
/>
|
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<template #footer>
|
<template #footer>
|
||||||
<!-- 这个是底部 -->
|
<!-- 这个是底部 -->
|
||||||
<AttachListComponent
|
<AttachListComponent v-if="item.question" :question="item.question" />
|
||||||
v-if="item.question"
|
|
||||||
:question="item.question"
|
|
||||||
/>
|
|
||||||
</template>
|
</template>
|
||||||
</ChatCardAI>
|
</ChatCardAI>
|
||||||
</template>
|
</template>
|
||||||
@@ -85,21 +48,15 @@
|
|||||||
|
|
||||||
<template v-else>
|
<template v-else>
|
||||||
<ChatCardOther class="flex flex-justify-center" :text="item.msg">
|
<ChatCardOther class="flex flex-justify-center" :text="item.msg">
|
||||||
<ActivityListComponent
|
<ActivityListComponent v-if="
|
||||||
v-if="
|
|
||||||
mainPageDataModel.activityList &&
|
mainPageDataModel.activityList &&
|
||||||
mainPageDataModel.activityList.length > 0
|
mainPageDataModel.activityList.length > 0
|
||||||
"
|
" :activityList="mainPageDataModel.activityList" />
|
||||||
:activityList="mainPageDataModel.activityList"
|
|
||||||
/>
|
|
||||||
|
|
||||||
<RecommendPostsComponent
|
<RecommendPostsComponent v-if="
|
||||||
v-if="
|
|
||||||
mainPageDataModel.recommendTheme &&
|
mainPageDataModel.recommendTheme &&
|
||||||
mainPageDataModel.recommendTheme.length > 0
|
mainPageDataModel.recommendTheme.length > 0
|
||||||
"
|
" :recommendThemeList="mainPageDataModel.recommendTheme" />
|
||||||
:recommendThemeList="mainPageDataModel.recommendTheme"
|
|
||||||
/>
|
|
||||||
</ChatCardOther>
|
</ChatCardOther>
|
||||||
</template>
|
</template>
|
||||||
</view>
|
</view>
|
||||||
@@ -108,17 +65,9 @@
|
|||||||
<!-- 输入框区域 -->
|
<!-- 输入框区域 -->
|
||||||
<view class="pb-safe-area">
|
<view class="pb-safe-area">
|
||||||
<ChatQuickAccess />
|
<ChatQuickAccess />
|
||||||
<ChatInputArea
|
<ChatInputArea ref="inputAreaRef" v-model="inputMessage" :holdKeyboard="holdKeyboard"
|
||||||
ref="inputAreaRef"
|
:is-session-active="isSessionActive" :stop-request="stopRequest" @send="sendMessageAction"
|
||||||
v-model="inputMessage"
|
@noHideKeyboard="handleNoHideKeyboard" @keyboardShow="handleKeyboardShow" @keyboardHide="handleKeyboardHide" />
|
||||||
:holdKeyboard="holdKeyboard"
|
|
||||||
:is-session-active="isSessionActive"
|
|
||||||
:stop-request="stopRequest"
|
|
||||||
@send="sendMessageAction"
|
|
||||||
@noHideKeyboard="handleNoHideKeyboard"
|
|
||||||
@keyboardShow="handleKeyboardShow"
|
|
||||||
@keyboardHide="handleKeyboardHide"
|
|
||||||
/>
|
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
</template>
|
</template>
|
||||||
@@ -243,7 +192,7 @@ const handleScroll = ThrottleUtils.createThrottle(({ detail }) => {
|
|||||||
}, 50);
|
}, 50);
|
||||||
|
|
||||||
// 处理滚动到底部事件
|
// 处理滚动到底部事件
|
||||||
const handleScrollToLower = () => {};
|
const handleScrollToLower = () => { };
|
||||||
|
|
||||||
// 滚动到底部 - 优化版本,确保打字机效果始终可见
|
// 滚动到底部 - 优化版本,确保打字机效果始终可见
|
||||||
const scrollToBottom = () => {
|
const scrollToBottom = () => {
|
||||||
@@ -474,7 +423,7 @@ const initWebSocket = async () => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
// 处理WebSocket消息
|
// 处理WebSocket消息
|
||||||
const handleWebSocketMessage = (data) => {
|
const handleWebSocketMessage = (data) => {
|
||||||
const aiMsgIndex = chatMsgList.value.length - 1;
|
const aiMsgIndex = chatMsgList.value.length - 1;
|
||||||
if (!chatMsgList.value[aiMsgIndex] || aiMsgIndex < 0) {
|
if (!chatMsgList.value[aiMsgIndex] || aiMsgIndex < 0) {
|
||||||
console.error("处理WebSocket消息时找不到对应的AI消息项");
|
console.error("处理WebSocket消息时找不到对应的AI消息项");
|
||||||
@@ -520,7 +469,7 @@ const initWebSocket = async () => {
|
|||||||
// 重置会话状态
|
// 重置会话状态
|
||||||
isSessionActive.value = false;
|
isSessionActive.value = false;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
// 重置消息状态
|
// 重置消息状态
|
||||||
const resetMessageState = () => {
|
const resetMessageState = () => {
|
||||||
|
|||||||
@@ -17,17 +17,9 @@
|
|||||||
<view class="login-agreement flex flex-items-center">
|
<view class="login-agreement flex flex-items-center">
|
||||||
<CheckBox v-model="isAgree">
|
<CheckBox v-model="isAgree">
|
||||||
<text class="font-size-12 color-525866">我已阅读并同意</text>
|
<text class="font-size-12 color-525866">我已阅读并同意</text>
|
||||||
<text
|
<text class="font-size-12 color-2D91FF ml-4 mr-4" @click.stop="handleAgreeClick('service')">《服务协议》</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-525866">和</text>
|
||||||
<text
|
<text class="font-size-12 color-2D91FF ml-4 mr-4" @click.stop="handleAgreeClick('privacy')">《隐私协议》</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">,\n</text>
|
||||||
<text class="font-size-12 color-525866 ml-30">授权与账号关联操作</text>
|
<text class="font-size-12 color-525866 ml-30">授权与账号关联操作</text>
|
||||||
</CheckBox>
|
</CheckBox>
|
||||||
@@ -37,23 +29,13 @@
|
|||||||
<view class="login-btn-area">
|
<view class="login-btn-area">
|
||||||
<!-- 同意隐私协议并获取手机号按钮 -->
|
<!-- 同意隐私协议并获取手机号按钮 -->
|
||||||
|
|
||||||
<button
|
<button class="login-btn" type="primary" :open-type="needWxLogin ? 'getPhoneNumber' : ''"
|
||||||
class="login-btn"
|
@getphonenumber="getPhoneNumber" @click="handleAgreeAndGetPhone">
|
||||||
type="primary"
|
|
||||||
:open-type="needWxLogin ? 'getPhoneNumber' : ''"
|
|
||||||
@getphonenumber="getPhoneNumber"
|
|
||||||
@click="handleAgreeAndGetPhone"
|
|
||||||
>
|
|
||||||
手机号快捷登录
|
手机号快捷登录
|
||||||
</button>
|
</button>
|
||||||
</view>
|
</view>
|
||||||
|
|
||||||
<AgreePopup
|
<AgreePopup ref="agreePopup" :visible="visible" :agreement="computedAgreement" @close="visible = false" />
|
||||||
ref="agreePopup"
|
|
||||||
:visible="visible"
|
|
||||||
:agreement="computedAgreement"
|
|
||||||
@close="visible = false"
|
|
||||||
/>
|
|
||||||
</view>
|
</view>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
@@ -63,12 +45,14 @@ import { ref, computed } from "vue";
|
|||||||
import {
|
import {
|
||||||
getServiceAgreement,
|
getServiceAgreement,
|
||||||
getPrivacyAgreement,
|
getPrivacyAgreement,
|
||||||
|
checkUserPhone
|
||||||
} from "@/request/api/LoginApi";
|
} from "@/request/api/LoginApi";
|
||||||
import { onLogin, goBack, refreshToken } from "@/hooks/useGoLogin";
|
import { onLogin, goBack, refreshToken } from "@/hooks/useGoLogin";
|
||||||
import CheckBox from "@/components/CheckBox/index.vue";
|
import CheckBox from "@/components/CheckBox/index.vue";
|
||||||
import AgreePopup from "./components/AgreePopup/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 { getCurrentConfig } from "@/constant/base";
|
||||||
|
import { getStorageSyncToken } from "@/constant/token";
|
||||||
|
|
||||||
const needWxLogin = ref(false);
|
const needWxLogin = ref(false);
|
||||||
const isAgree = ref(false);
|
const isAgree = ref(false);
|
||||||
@@ -106,7 +90,7 @@ const getPhoneNumber = (e) => {
|
|||||||
});
|
});
|
||||||
goBack();
|
goBack();
|
||||||
})
|
})
|
||||||
.catch(() => {});
|
.catch(() => { });
|
||||||
};
|
};
|
||||||
|
|
||||||
// 处理同意协议点击事件
|
// 处理同意协议点击事件
|
||||||
@@ -142,14 +126,21 @@ getPrivacyAgreementData();
|
|||||||
|
|
||||||
// 页面显示时刷新token
|
// 页面显示时刷新token
|
||||||
onShow(async () => {
|
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>
|
</script>
|
||||||
|
|
||||||
<style lang="scss" scoped>
|
<style lang="scss" scoped>
|
||||||
@import "./styles/index.scss";
|
@import "./styles/index.scss";
|
||||||
|
|
||||||
@font-face {
|
@font-face {
|
||||||
font-family: znicons;
|
font-family: znicons;
|
||||||
src: url("@/static/fonts/znicons.ttf");
|
src: url("@/static/fonts/znicons.ttf");
|
||||||
|
|||||||
Reference in New Issue
Block a user