feat: 调整优化登录的逻辑
This commit is contained in:
@@ -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) => {
|
export const onLogin = async (e) => {
|
||||||
const token = uni.getStorageSync("token");
|
return new Promise(async (resolve) => {
|
||||||
|
await loginAuth().then(async () => {
|
||||||
if (token) return;
|
|
||||||
|
|
||||||
const { code } = e.detail;
|
const { code } = e.detail;
|
||||||
console.info("onLogin code: ", code);
|
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 () => {
|
export const checkToken = async () => {
|
||||||
return new Promise((resolve) => {
|
return new Promise((resolve) => {
|
||||||
const token = uni.getStorageSync("token");
|
const token = uni.getStorageSync("token");
|
||||||
|
if (!token) {
|
||||||
if (!token) return;
|
console.log("token不存在,重新登录");
|
||||||
|
loginAuth().then(() => {
|
||||||
resolve(token);
|
resolve();
|
||||||
|
});
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
resolve();
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -20,9 +20,7 @@ const loginAuth = () => {
|
|||||||
|
|
||||||
if (response.access_token) {
|
if (response.access_token) {
|
||||||
uni.setStorageSync("token", response.access_token);
|
uni.setStorageSync("token", response.access_token);
|
||||||
|
|
||||||
const appStore = useAppStore();
|
const appStore = useAppStore();
|
||||||
|
|
||||||
appStore.setHasToken(true);
|
appStore.setHasToken(true);
|
||||||
resolve();
|
resolve();
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@@ -9,8 +9,6 @@
|
|||||||
|
|
||||||
<!-- 输入框/语音按钮容器 -->
|
<!-- 输入框/语音按钮容器 -->
|
||||||
<view class="input-button-container">
|
<view class="input-button-container">
|
||||||
<Interceptor />
|
|
||||||
|
|
||||||
<textarea
|
<textarea
|
||||||
ref="textareaRef"
|
ref="textareaRef"
|
||||||
v-if="!isVoiceMode"
|
v-if="!isVoiceMode"
|
||||||
@@ -63,9 +61,7 @@
|
|||||||
|
|
||||||
<script setup>
|
<script setup>
|
||||||
import { ref, watch, nextTick, onMounted, defineExpose } from "vue";
|
import { ref, watch, nextTick, onMounted, defineExpose } from "vue";
|
||||||
import { checkToken } from "@/hooks/useGoLogin";
|
|
||||||
import RecordingWaveBtn from "@/components/Speech/RecordingWaveBtn.vue";
|
import RecordingWaveBtn from "@/components/Speech/RecordingWaveBtn.vue";
|
||||||
import Interceptor from "@/components/Interceptor/index.vue";
|
|
||||||
|
|
||||||
const plugin = requirePlugin("WechatSI");
|
const plugin = requirePlugin("WechatSI");
|
||||||
const manager = plugin.getRecordRecognitionManager();
|
const manager = plugin.getRecordRecognitionManager();
|
||||||
@@ -117,7 +113,6 @@ const toggleVoiceMode = () => {
|
|||||||
|
|
||||||
// 处理语音按钮长按开始
|
// 处理语音按钮长按开始
|
||||||
const handleVoiceTouchStart = () => {
|
const handleVoiceTouchStart = () => {
|
||||||
checkToken().then(() => {
|
|
||||||
manager.start({ lang: "zh_CN" });
|
manager.start({ lang: "zh_CN" });
|
||||||
|
|
||||||
visibleWaveBtn.value = true;
|
visibleWaveBtn.value = true;
|
||||||
@@ -128,7 +123,6 @@ const handleVoiceTouchStart = () => {
|
|||||||
recordingWaveBtnRef.value.startAnimation();
|
recordingWaveBtnRef.value.startAnimation();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
});
|
|
||||||
};
|
};
|
||||||
|
|
||||||
// 处理语音按钮长按结束
|
// 处理语音按钮长按结束
|
||||||
|
|||||||
@@ -170,9 +170,9 @@ import {
|
|||||||
import WebSocketManager from "@/utils/WebSocketManager";
|
import WebSocketManager from "@/utils/WebSocketManager";
|
||||||
import TypewriterManager from "@/utils/TypewriterManager";
|
import TypewriterManager from "@/utils/TypewriterManager";
|
||||||
import { IdUtils } from "@/utils";
|
import { IdUtils } from "@/utils";
|
||||||
import { useAppStore } from "@/store";
|
import { goLogin } from "@/hooks/useGoLogin";
|
||||||
import { checkToken } from "@/hooks/useGoLogin";
|
|
||||||
|
|
||||||
|
import { useAppStore } from "@/store";
|
||||||
const appStore = useAppStore();
|
const appStore = useAppStore();
|
||||||
/// 导航栏相关
|
/// 导航栏相关
|
||||||
const statusBarHeight = ref(20);
|
const statusBarHeight = ref(20);
|
||||||
@@ -356,7 +356,7 @@ onLoad(() => {
|
|||||||
// token存在,初始化数据
|
// token存在,初始化数据
|
||||||
const initHandler = () => {
|
const initHandler = () => {
|
||||||
console.log("initHandler");
|
console.log("initHandler");
|
||||||
|
if (!appStore.hasToken) return;
|
||||||
loadRecentConversation();
|
loadRecentConversation();
|
||||||
///loadConversationMsgList();
|
///loadConversationMsgList();
|
||||||
initWebSocket();
|
initWebSocket();
|
||||||
@@ -368,6 +368,7 @@ watch(
|
|||||||
() => appStore.hasToken,
|
() => appStore.hasToken,
|
||||||
(newValue) => {
|
(newValue) => {
|
||||||
if (newValue) {
|
if (newValue) {
|
||||||
|
console.log("token存在,初始化数据");
|
||||||
initHandler();
|
initHandler();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -380,7 +381,7 @@ onMounted(() => {
|
|||||||
initTypewriterManager();
|
initTypewriterManager();
|
||||||
|
|
||||||
// 有token时,加载最近会话、最近消息、初始化socket
|
// 有token时,加载最近会话、最近消息、初始化socket
|
||||||
checkToken().then(() => initHandler());
|
initHandler();
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error("页面初始化错误:", error);
|
console.error("页面初始化错误:", error);
|
||||||
}
|
}
|
||||||
@@ -599,6 +600,13 @@ const initData = () => {
|
|||||||
|
|
||||||
// 发送消息的参数拼接
|
// 发送消息的参数拼接
|
||||||
const sendMessage = (message, isInstruct = false) => {
|
const sendMessage = (message, isInstruct = false) => {
|
||||||
|
console.log("发送的消息:", message);
|
||||||
|
if (!appStore.hasToken) {
|
||||||
|
console.log("没有token,跳转到登录页");
|
||||||
|
goLogin();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (isSessionActive.value) {
|
if (isSessionActive.value) {
|
||||||
uni.showToast({
|
uni.showToast({
|
||||||
title: "请等待当前回复完成",
|
title: "请等待当前回复完成",
|
||||||
|
|||||||
@@ -7,8 +7,6 @@
|
|||||||
:key="index"
|
:key="index"
|
||||||
>
|
>
|
||||||
<view class="more-tips-item-title" @click="sendReply(item)">
|
<view class="more-tips-item-title" @click="sendReply(item)">
|
||||||
<Interceptor />
|
|
||||||
|
|
||||||
{{ item }}
|
{{ item }}
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
@@ -18,9 +16,6 @@
|
|||||||
|
|
||||||
<script setup>
|
<script setup>
|
||||||
import { defineProps } from "vue";
|
import { defineProps } from "vue";
|
||||||
import { checkToken } from "@/hooks/useGoLogin";
|
|
||||||
import Interceptor from "@/components/Interceptor/index.vue";
|
|
||||||
|
|
||||||
const emits = defineEmits(["replySent"]);
|
const emits = defineEmits(["replySent"]);
|
||||||
|
|
||||||
defineProps({
|
defineProps({
|
||||||
@@ -39,8 +34,7 @@ defineProps({
|
|||||||
});
|
});
|
||||||
|
|
||||||
const sendReply = (text) => {
|
const sendReply = (text) => {
|
||||||
// 向父组件传递数据
|
emits("replySent", text);
|
||||||
checkToken().then(() => emits("replySent", text));
|
|
||||||
};
|
};
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
|||||||
@@ -7,8 +7,6 @@
|
|||||||
:key="index"
|
:key="index"
|
||||||
@click="sendReply(item)"
|
@click="sendReply(item)"
|
||||||
>
|
>
|
||||||
<Interceptor />
|
|
||||||
|
|
||||||
<image
|
<image
|
||||||
class="quick-access-item-bg"
|
class="quick-access-item-bg"
|
||||||
src="/static/quick/quick_icon_bg.png"
|
src="/static/quick/quick_icon_bg.png"
|
||||||
@@ -26,15 +24,12 @@
|
|||||||
|
|
||||||
<script setup>
|
<script setup>
|
||||||
import { onMounted, ref } from "vue";
|
import { onMounted, ref } from "vue";
|
||||||
import { checkToken } from "@/hooks/useGoLogin";
|
|
||||||
import Interceptor from "@/components/Interceptor/index.vue";
|
|
||||||
|
|
||||||
const itemList = ref([]);
|
const itemList = ref([]);
|
||||||
|
|
||||||
const emits = defineEmits(["replySent"]);
|
const emits = defineEmits(["replySent"]);
|
||||||
|
|
||||||
const sendReply = (item) => {
|
const sendReply = (item) => {
|
||||||
checkToken().then(() => emits("replySent", item)); // 向父组件传递数据
|
emits("replySent", item); // 向父组件传递数据
|
||||||
};
|
};
|
||||||
|
|
||||||
onMounted(() => {
|
onMounted(() => {
|
||||||
|
|||||||
@@ -11,18 +11,30 @@
|
|||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script setup>
|
<script setup>
|
||||||
import { defineEmits, ref } from "vue";
|
import { ref } from "vue";
|
||||||
import DrawerHome from "@/pages/drawer/DrawerHome.vue";
|
import DrawerHome from "@/pages/drawer/DrawerHome.vue";
|
||||||
|
import { goLogin } from "@/hooks/useGoLogin";
|
||||||
|
import { useAppStore } from "@/store";
|
||||||
|
const appStore = useAppStore();
|
||||||
const showLeft = ref(false);
|
const showLeft = ref(false);
|
||||||
|
|
||||||
// 打开窗口
|
// 打开窗口
|
||||||
const showDrawer = (e) => {
|
const showDrawer = (e) => {
|
||||||
|
if (!appStore.hasToken) {
|
||||||
|
console.log("没有token,跳转到登录页");
|
||||||
|
goLogin();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
showLeft.value.open();
|
showLeft.value.open();
|
||||||
|
// 发送抽屉显示事件
|
||||||
|
uni.$emit("drawerShow");
|
||||||
};
|
};
|
||||||
// 关闭窗口
|
// 关闭窗口
|
||||||
const closeDrawer = (e) => {
|
const closeDrawer = (e) => {
|
||||||
showLeft.value.close();
|
showLeft.value.close();
|
||||||
|
// 发送抽屉隐藏事件
|
||||||
|
uni.$emit("drawerHide");
|
||||||
};
|
};
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
|||||||
@@ -11,18 +11,41 @@
|
|||||||
<text class="title">我的</text>
|
<text class="title">我的</text>
|
||||||
</view>
|
</view>
|
||||||
|
|
||||||
<MineSetting />
|
<MineSetting v-if="isDrawerVisible" />
|
||||||
</view>
|
</view>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script setup>
|
<script setup>
|
||||||
import MineSetting from "./MineSetting.vue";
|
import MineSetting from "./MineSetting.vue";
|
||||||
import { defineEmits } from "vue";
|
import { defineEmits, ref, onMounted, onUnmounted } from "vue";
|
||||||
const emits = defineEmits(["closeDrawer"]);
|
const emits = defineEmits(["closeDrawer"]);
|
||||||
|
|
||||||
|
const isDrawerVisible = ref(false);
|
||||||
|
|
||||||
const closeDrawer = () => {
|
const closeDrawer = () => {
|
||||||
|
isDrawerVisible.value = false;
|
||||||
emits("closeDrawer");
|
emits("closeDrawer");
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// 监听抽屉显示事件
|
||||||
|
const handleDrawerShow = () => {
|
||||||
|
isDrawerVisible.value = true;
|
||||||
|
};
|
||||||
|
|
||||||
|
// 监听抽屉隐藏事件
|
||||||
|
const handleDrawerHide = () => {
|
||||||
|
isDrawerVisible.value = false;
|
||||||
|
};
|
||||||
|
|
||||||
|
onMounted(() => {
|
||||||
|
uni.$on("drawerShow", handleDrawerShow);
|
||||||
|
uni.$on("drawerHide", handleDrawerHide);
|
||||||
|
});
|
||||||
|
|
||||||
|
onUnmounted(() => {
|
||||||
|
uni.$off("drawerShow", handleDrawerShow);
|
||||||
|
uni.$off("drawerHide", handleDrawerHide);
|
||||||
|
});
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style lang="scss" scoped>
|
<style lang="scss" scoped>
|
||||||
|
|||||||
@@ -36,9 +36,9 @@
|
|||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script setup>
|
<script setup>
|
||||||
import { ref, onMounted } from "vue";
|
import { ref } from "vue";
|
||||||
|
import { onShow } from "@dcloudio/uni-app";
|
||||||
import { getLoginUserPhone } from "@/request/api/LoginApi";
|
import { getLoginUserPhone } from "@/request/api/LoginApi";
|
||||||
import { checkToken } from "@/hooks/useGoLogin";
|
|
||||||
|
|
||||||
// 假数据
|
// 假数据
|
||||||
const userInfo = ref({
|
const userInfo = ref({
|
||||||
@@ -60,12 +60,10 @@ const menuList = ref([
|
|||||||
{ label: "订阅消息", type: "action", action: "subscribeMessage" },
|
{ label: "订阅消息", type: "action", action: "subscribeMessage" },
|
||||||
]);
|
]);
|
||||||
|
|
||||||
// 生命周期钩子
|
// 页面生命周期钩子 - 页面显示时调用
|
||||||
onMounted(() => {
|
onShow(() => {
|
||||||
checkToken().then(() => {
|
|
||||||
getLoginUserPhoneInfo();
|
getLoginUserPhoneInfo();
|
||||||
});
|
});
|
||||||
});
|
|
||||||
|
|
||||||
const getLoginUserPhoneInfo = async () => {
|
const getLoginUserPhoneInfo = async () => {
|
||||||
const res = await getLoginUserPhone();
|
const res = await getLoginUserPhone();
|
||||||
|
|||||||
@@ -1,5 +1,12 @@
|
|||||||
<template>
|
<template>
|
||||||
<view class="login-wrapper" :style="{ backgroundImage: `url(${loginBg})` }">
|
<view class="login-wrapper" :style="{ backgroundImage: `url(${loginBg})` }">
|
||||||
|
<!-- 返回按钮 -->
|
||||||
|
<view class="back-btn" @click="goBack">
|
||||||
|
<uni-icons fontFamily="znicons" size="24" color="#333">{{
|
||||||
|
zniconsMap["zn-nav-arrow-left"]
|
||||||
|
}}</uni-icons>
|
||||||
|
</view>
|
||||||
|
|
||||||
<!-- 头部内容 -->
|
<!-- 头部内容 -->
|
||||||
<view class="login-header">
|
<view class="login-header">
|
||||||
<!-- 卡通形象 -->
|
<!-- 卡通形象 -->
|
||||||
@@ -31,7 +38,7 @@
|
|||||||
class="login-btn"
|
class="login-btn"
|
||||||
open-type="getPhoneNumber"
|
open-type="getPhoneNumber"
|
||||||
type="primary"
|
type="primary"
|
||||||
@getphonenumber="onLogin"
|
@getphonenumber="getPhoneNumber"
|
||||||
>
|
>
|
||||||
微信一键登录
|
微信一键登录
|
||||||
</button>
|
</button>
|
||||||
@@ -66,15 +73,15 @@
|
|||||||
|
|
||||||
<script setup>
|
<script setup>
|
||||||
import { ref, computed } from "vue";
|
import { ref, computed } from "vue";
|
||||||
import { loginAuth, bindPhone, checkPhone } from "@/manager/LoginManager";
|
|
||||||
import {
|
import {
|
||||||
getServiceAgreement,
|
getServiceAgreement,
|
||||||
getPrivacyAgreement,
|
getPrivacyAgreement,
|
||||||
} from "@/request/api/LoginApi";
|
} from "@/request/api/LoginApi";
|
||||||
import { goHome } from "@/hooks/useGoHome";
|
import { onLogin, goBack } from "@/hooks/useGoLogin";
|
||||||
import loginBg from "./images/bg.png";
|
import loginBg from "./images/bg.png";
|
||||||
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";
|
||||||
|
|
||||||
const isAgree = ref(false);
|
const isAgree = ref(false);
|
||||||
const visible = ref(false);
|
const visible = ref(false);
|
||||||
@@ -94,30 +101,20 @@ const handleAgreeAndGetPhone = () => {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
const onLogin = (e) => {
|
const getPhoneNumber = (e) => {
|
||||||
const { code } = e.detail;
|
onLogin(e)
|
||||||
console.info("onLogin code: ", code);
|
.then(() => {
|
||||||
|
uni.showToast({
|
||||||
loginAuth()
|
title: "登录成功",
|
||||||
.then(async () => {
|
icon: "success",
|
||||||
// 检测是否绑定手机号,已绑定则直接跳转首页,未绑定则获取手机号并绑定
|
|
||||||
const res = await checkPhone();
|
|
||||||
|
|
||||||
if (res.data) {
|
|
||||||
return goHome();
|
|
||||||
}
|
|
||||||
|
|
||||||
const { data } = await bindPhone({
|
|
||||||
wechatPhoneCode: code,
|
|
||||||
clientId: "2",
|
|
||||||
});
|
});
|
||||||
|
goBack();
|
||||||
if (data) {
|
|
||||||
goHome();
|
|
||||||
}
|
|
||||||
})
|
})
|
||||||
.catch((err) => {
|
.catch(() => {
|
||||||
console.error("登录失败", err);
|
uni.showToast({
|
||||||
|
title: "登录失败",
|
||||||
|
icon: "none",
|
||||||
|
});
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -155,4 +152,8 @@ getPrivacyAgreementData();
|
|||||||
|
|
||||||
<style lang="scss" scoped>
|
<style lang="scss" scoped>
|
||||||
@import "./styles/index.scss";
|
@import "./styles/index.scss";
|
||||||
|
@font-face {
|
||||||
|
font-family: znicons;
|
||||||
|
src: url("@/static/fonts/znicons.ttf");
|
||||||
|
}
|
||||||
</style>
|
</style>
|
||||||
|
|||||||
@@ -11,6 +11,18 @@
|
|||||||
background-size: 100% 100%;
|
background-size: 100% 100%;
|
||||||
background-repeat: no-repeat;
|
background-repeat: no-repeat;
|
||||||
|
|
||||||
|
.back-btn {
|
||||||
|
position: absolute;
|
||||||
|
top: 44px;
|
||||||
|
left: 4px;
|
||||||
|
width: 44px;
|
||||||
|
height: 44px;
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: center;
|
||||||
|
z-index: 10;
|
||||||
|
}
|
||||||
|
|
||||||
.login-header {
|
.login-header {
|
||||||
text-align: center;
|
text-align: center;
|
||||||
max-height: 223px;
|
max-height: 223px;
|
||||||
|
|||||||
@@ -7,7 +7,6 @@
|
|||||||
:key="`${item.commodityId}-${index}`"
|
:key="`${item.commodityId}-${index}`"
|
||||||
>
|
>
|
||||||
<view class="mk-card-item" @click="placeOrderHandle(item)">
|
<view class="mk-card-item" @click="placeOrderHandle(item)">
|
||||||
<Interceptor />
|
|
||||||
<image
|
<image
|
||||||
class="card-img"
|
class="card-img"
|
||||||
:src="item.commodityPhoto"
|
:src="item.commodityPhoto"
|
||||||
@@ -51,7 +50,6 @@
|
|||||||
import { defineProps } from "vue";
|
import { defineProps } from "vue";
|
||||||
import { checkToken } from "@/hooks/useGoLogin";
|
import { checkToken } from "@/hooks/useGoLogin";
|
||||||
import ModuleTitle from "@/components/ModuleTitle/index.vue";
|
import ModuleTitle from "@/components/ModuleTitle/index.vue";
|
||||||
import Interceptor from "@/components/Interceptor/index.vue";
|
|
||||||
|
|
||||||
const props = defineProps({
|
const props = defineProps({
|
||||||
commodityList: {
|
commodityList: {
|
||||||
|
|||||||
@@ -7,8 +7,6 @@
|
|||||||
:key="index"
|
:key="index"
|
||||||
>
|
>
|
||||||
<view class="mk-card-item" @click="sendReply(item)">
|
<view class="mk-card-item" @click="sendReply(item)">
|
||||||
<Interceptor />
|
|
||||||
|
|
||||||
<image
|
<image
|
||||||
class="card-img"
|
class="card-img"
|
||||||
:src="item.coverPhoto"
|
:src="item.coverPhoto"
|
||||||
@@ -24,8 +22,6 @@
|
|||||||
<script setup>
|
<script setup>
|
||||||
import { RECOMMEND_POSTS_TITLE } from "@/constant/constant";
|
import { RECOMMEND_POSTS_TITLE } from "@/constant/constant";
|
||||||
import { defineProps } from "vue";
|
import { defineProps } from "vue";
|
||||||
import { checkToken } from "@/hooks/useGoLogin";
|
|
||||||
import Interceptor from "@/components/Interceptor/index.vue";
|
|
||||||
import ModuleTitle from "@/components/ModuleTitle/index.vue";
|
import ModuleTitle from "@/components/ModuleTitle/index.vue";
|
||||||
|
|
||||||
const props = defineProps({
|
const props = defineProps({
|
||||||
@@ -36,10 +32,8 @@ const props = defineProps({
|
|||||||
});
|
});
|
||||||
|
|
||||||
const sendReply = (item) => {
|
const sendReply = (item) => {
|
||||||
checkToken().then(() => {
|
|
||||||
const topic = item.userInputContent || item.topic.replace(/^#/, "");
|
const topic = item.userInputContent || item.topic.replace(/^#/, "");
|
||||||
uni.$emit(RECOMMEND_POSTS_TITLE, topic);
|
uni.$emit(RECOMMEND_POSTS_TITLE, topic);
|
||||||
});
|
|
||||||
};
|
};
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
|||||||
@@ -7,7 +7,6 @@
|
|||||||
:key="index"
|
:key="index"
|
||||||
>
|
>
|
||||||
<view class="mk-card-item" @click="sendReply(item)">
|
<view class="mk-card-item" @click="sendReply(item)">
|
||||||
<Interceptor />
|
|
||||||
<image class="card-img" :src="item.coverPhoto" mode="aspectFill" />
|
<image class="card-img" :src="item.coverPhoto" mode="aspectFill" />
|
||||||
|
|
||||||
<view class="overlay-gradient">
|
<view class="overlay-gradient">
|
||||||
@@ -22,8 +21,6 @@
|
|||||||
<script setup>
|
<script setup>
|
||||||
import { defineProps } from "vue";
|
import { defineProps } from "vue";
|
||||||
import { RECOMMEND_POSTS_TITLE } from "@/constant/constant";
|
import { RECOMMEND_POSTS_TITLE } from "@/constant/constant";
|
||||||
import { checkToken } from "@/hooks/useGoLogin";
|
|
||||||
import Interceptor from "@/components/Interceptor/index.vue";
|
|
||||||
import ModuleTitle from "@/components/ModuleTitle/index.vue";
|
import ModuleTitle from "@/components/ModuleTitle/index.vue";
|
||||||
|
|
||||||
const props = defineProps({
|
const props = defineProps({
|
||||||
@@ -34,10 +31,8 @@ const props = defineProps({
|
|||||||
});
|
});
|
||||||
|
|
||||||
const sendReply = (item) => {
|
const sendReply = (item) => {
|
||||||
checkToken().then(() => {
|
|
||||||
const topic = item.userInputContent || item.topic.replace(/^#/, "");
|
const topic = item.userInputContent || item.topic.replace(/^#/, "");
|
||||||
uni.$emit(RECOMMEND_POSTS_TITLE, topic);
|
uni.$emit(RECOMMEND_POSTS_TITLE, topic);
|
||||||
});
|
|
||||||
};
|
};
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
|
import { goLogin } from "../../hooks/useGoLogin";
|
||||||
import { BASE_URL } from "./baseUrl";
|
import { BASE_URL } from "./baseUrl";
|
||||||
import { goLogin } from "@/hooks/useGoLogin";
|
import { loginAuth, checkPhone } from "@/manager/LoginManager";
|
||||||
|
|
||||||
const defaultConfig = {
|
const defaultConfig = {
|
||||||
header: {
|
header: {
|
||||||
@@ -50,10 +51,16 @@ function request(url, args = {}, method = "POST", customConfig = {}) {
|
|||||||
success: (res) => {
|
success: (res) => {
|
||||||
console.log("请求响应:" + JSON.stringify(res));
|
console.log("请求响应:" + JSON.stringify(res));
|
||||||
resolve(res.data);
|
resolve(res.data);
|
||||||
// if (res.statusCode && res.statusCode === 424) {
|
if (res.statusCode && res.statusCode === 424) {
|
||||||
// uni.setStorageSync("token", "");
|
console.log("424错误,重新登录");
|
||||||
// goLogin();
|
loginAuth().then(async () => {
|
||||||
// }
|
// 检测是否绑定手机号
|
||||||
|
const res = await checkPhone();
|
||||||
|
if (!res.data) {
|
||||||
|
goLogin();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
},
|
},
|
||||||
fail: (err) => {
|
fail: (err) => {
|
||||||
console.error("请求失败:", err);
|
console.error("请求失败:", err);
|
||||||
|
|||||||
Reference in New Issue
Block a user