diff --git a/hooks/useGoLogin.js b/hooks/useGoLogin.js
index 0ca9a36..09a3928 100644
--- a/hooks/useGoLogin.js
+++ b/hooks/useGoLogin.js
@@ -1,27 +1,25 @@
-import { loginAuth, checkPhone, bindPhone } from "@/manager/LoginManager";
+import { loginAuth, bindPhone } from "@/manager/LoginManager";
// 跳转登录
-export const goLogin = () => uni.reLaunch({ url: "/pages/login/index" });
+export const goLogin = () => uni.navigateTo({ url: "/pages/login/index" });
+
+// 登录成功后,返回上一页
+export const goBack = () => uni.navigateBack({ delta: 1 });
// 登录逻辑
-export const onLogin = (e) => {
- const token = uni.getStorageSync("token");
+export const onLogin = async (e) => {
+ return new Promise(async (resolve) => {
+ await loginAuth().then(async () => {
+ const { code } = e.detail;
+ console.info("onLogin code: ", code);
- if (token) return;
-
- const { code } = e.detail;
- console.info("onLogin code: ", code);
-
- loginAuth().then(async () => {
- // 检测是否绑定手机号
- const res = await checkPhone();
-
- if (res.data) return;
-
- const params = { wechatPhoneCode: code, clientId: "2" };
-
- // 绑定手机号
- bindPhone(params);
+ // 绑定手机号
+ const params = { wechatPhoneCode: code, clientId: "2" };
+ const res = await bindPhone(params);
+ if (res.data) {
+ resolve();
+ }
+ });
});
};
@@ -29,9 +27,13 @@ export const onLogin = (e) => {
export const checkToken = async () => {
return new Promise((resolve) => {
const token = uni.getStorageSync("token");
-
- if (!token) return;
-
- resolve(token);
+ if (!token) {
+ console.log("token不存在,重新登录");
+ loginAuth().then(() => {
+ resolve();
+ });
+ return;
+ }
+ resolve();
});
};
diff --git a/manager/LoginManager.js b/manager/LoginManager.js
index de18336..0750345 100644
--- a/manager/LoginManager.js
+++ b/manager/LoginManager.js
@@ -20,9 +20,7 @@ const loginAuth = () => {
if (response.access_token) {
uni.setStorageSync("token", response.access_token);
-
const appStore = useAppStore();
-
appStore.setHasToken(true);
resolve();
} else {
diff --git a/pages/chat/ChatInputArea.vue b/pages/chat/ChatInputArea.vue
index 8aa5539..e71e0cd 100644
--- a/pages/chat/ChatInputArea.vue
+++ b/pages/chat/ChatInputArea.vue
@@ -9,8 +9,6 @@
-
-
@@ -18,9 +16,6 @@
diff --git a/pages/chat/ChatQuickAccess.vue b/pages/chat/ChatQuickAccess.vue
index 6a3c71d..c0bd7ac 100644
--- a/pages/chat/ChatQuickAccess.vue
+++ b/pages/chat/ChatQuickAccess.vue
@@ -7,8 +7,6 @@
:key="index"
@click="sendReply(item)"
>
-
-
import { onMounted, ref } from "vue";
-import { checkToken } from "@/hooks/useGoLogin";
-import Interceptor from "@/components/Interceptor/index.vue";
-
const itemList = ref([]);
const emits = defineEmits(["replySent"]);
const sendReply = (item) => {
- checkToken().then(() => emits("replySent", item)); // 向父组件传递数据
+ emits("replySent", item); // 向父组件传递数据
};
onMounted(() => {
diff --git a/pages/chat/ChatTopNavBar.vue b/pages/chat/ChatTopNavBar.vue
index 0ff5c1f..a68bed0 100644
--- a/pages/chat/ChatTopNavBar.vue
+++ b/pages/chat/ChatTopNavBar.vue
@@ -11,18 +11,30 @@
diff --git a/pages/drawer/DrawerHome.vue b/pages/drawer/DrawerHome.vue
index 5f510a7..c2ffab8 100644
--- a/pages/drawer/DrawerHome.vue
+++ b/pages/drawer/DrawerHome.vue
@@ -11,18 +11,41 @@
我的
-
+
diff --git a/pages/login/styles/index.scss b/pages/login/styles/index.scss
index 22b89c0..50b6c6c 100644
--- a/pages/login/styles/index.scss
+++ b/pages/login/styles/index.scss
@@ -1,63 +1,75 @@
.login-wrapper {
+ display: flex;
+ flex-direction: column;
+ align-items: center;
+ box-sizing: border-box;
+ font-family: PingFang SC, PingFang SC;
+ height: 100vh;
+ padding-top: 168px;
+ position: relative;
+ background-position: 0 0;
+ background-size: 100% 100%;
+ background-repeat: no-repeat;
+
+ .back-btn {
+ position: absolute;
+ top: 44px;
+ left: 4px;
+ width: 44px;
+ height: 44px;
display: flex;
- flex-direction: column;
align-items: center;
- box-sizing: border-box;
- font-family: PingFang SC, PingFang SC;
- height: 100vh;
- padding-top: 168px;
- position: relative;
- background-position: 0 0;
- background-size: 100% 100%;
- background-repeat: no-repeat;
+ justify-content: center;
+ z-index: 10;
+ }
- .login-header {
- text-align: center;
- max-height: 223px;
+ .login-header {
+ text-align: center;
+ max-height: 223px;
- .login-avatar {
- width: 150px;
- display: block;
- }
-
- .login-title {
- width: 137px;
- height: 32px;
- margin: 6px auto;
- }
-
- .login-desc {
- font-size: 12px;
- color: #1e4c69;
- line-height: 24px;
- }
+ .login-avatar {
+ width: 150px;
+ display: block;
}
- .login-btn-area {
- margin-top: 46px;
- width: 297px;
-
- .login-btn {
- background: linear-gradient(246deg, #22a7ff 0%, #2567ff 100%);
- width: 100%;
- border-radius: 50px;
- }
+ .login-title {
+ width: 137px;
+ height: 32px;
+ margin: 6px auto;
}
- .login-agreement {
- margin-top: 20px;
- display: flex;
- align-items: center;
-
- .login-agreement-text {
- font-size: 14px;
- color: #666;
- }
-
- .login-agreement-link {
- font-size: 14px;
- color: #007aff;
- margin: 0 5px;
- }
+ .login-desc {
+ font-size: 12px;
+ color: #1e4c69;
+ line-height: 24px;
}
+ }
+
+ .login-btn-area {
+ margin-top: 46px;
+ width: 297px;
+
+ .login-btn {
+ background: linear-gradient(246deg, #22a7ff 0%, #2567ff 100%);
+ width: 100%;
+ border-radius: 50px;
+ }
+ }
+
+ .login-agreement {
+ margin-top: 20px;
+ display: flex;
+ align-items: center;
+
+ .login-agreement-text {
+ font-size: 14px;
+ color: #666;
+ }
+
+ .login-agreement-link {
+ font-size: 14px;
+ color: #007aff;
+ margin: 0 5px;
+ }
+ }
}
diff --git a/pages/module/detail/DetailCardGoodsContentList.vue b/pages/module/detail/DetailCardGoodsContentList.vue
index 29d92c1..4e150cf 100644
--- a/pages/module/detail/DetailCardGoodsContentList.vue
+++ b/pages/module/detail/DetailCardGoodsContentList.vue
@@ -7,7 +7,6 @@
:key="`${item.commodityId}-${index}`"
>
-
-
-
import { RECOMMEND_POSTS_TITLE } from "@/constant/constant";
import { defineProps } from "vue";
-import { checkToken } from "@/hooks/useGoLogin";
-import Interceptor from "@/components/Interceptor/index.vue";
import ModuleTitle from "@/components/ModuleTitle/index.vue";
const props = defineProps({
@@ -36,10 +32,8 @@ const props = defineProps({
});
const sendReply = (item) => {
- checkToken().then(() => {
- const topic = item.userInputContent || item.topic.replace(/^#/, "");
- uni.$emit(RECOMMEND_POSTS_TITLE, topic);
- });
+ const topic = item.userInputContent || item.topic.replace(/^#/, "");
+ uni.$emit(RECOMMEND_POSTS_TITLE, topic);
};
diff --git a/pages/module/recommend/RecommendPostsList.vue b/pages/module/recommend/RecommendPostsList.vue
index cfe7b8d..61d2da4 100644
--- a/pages/module/recommend/RecommendPostsList.vue
+++ b/pages/module/recommend/RecommendPostsList.vue
@@ -7,7 +7,6 @@
:key="index"
>
-
@@ -22,8 +21,6 @@
diff --git a/request/base/request.js b/request/base/request.js
index 7a73bce..fd2fd1c 100644
--- a/request/base/request.js
+++ b/request/base/request.js
@@ -1,5 +1,6 @@
+import { goLogin } from "../../hooks/useGoLogin";
import { BASE_URL } from "./baseUrl";
-import { goLogin } from "@/hooks/useGoLogin";
+import { loginAuth, checkPhone } from "@/manager/LoginManager";
const defaultConfig = {
header: {
@@ -50,10 +51,16 @@ function request(url, args = {}, method = "POST", customConfig = {}) {
success: (res) => {
console.log("请求响应:" + JSON.stringify(res));
resolve(res.data);
- // if (res.statusCode && res.statusCode === 424) {
- // uni.setStorageSync("token", "");
- // goLogin();
- // }
+ if (res.statusCode && res.statusCode === 424) {
+ console.log("424错误,重新登录");
+ loginAuth().then(async () => {
+ // 检测是否绑定手机号
+ const res = await checkPhone();
+ if (!res.data) {
+ goLogin();
+ }
+ });
+ }
},
fail: (err) => {
console.error("请求失败:", err);