Compare commits

...

3 Commits

Author SHA1 Message Date
4cdff7a594 feat: 登录逻辑的调整 2025-09-20 16:13:07 +08:00
67474d73a4 feat: 退出登录 2025-09-20 15:24:40 +08:00
dc8b939ff3 feat: 车牌卡片 图片商品组件名称 单位 2025-09-20 14:07:26 +08:00
13 changed files with 99 additions and 112 deletions

View File

@ -5,7 +5,7 @@
</view> </view>
<image <image
class="code-img" class="code-img"
src="./images/qrcode.png" src="https://one-feel-config-images-bucket.oss-cn-chengdu.aliyuncs.com/20250920102920_354_52.png"
mode="widthFix" mode="widthFix"
show-menu-by-longpress="true" show-menu-by-longpress="true"
/> />

View File

@ -3,12 +3,6 @@
flex-direction: column; flex-direction: column;
align-items: center; align-items: center;
.description {
font-size: 28rpx;
color: #666;
line-height: 1.5;
}
.code-img { .code-img {
margin-top: 12px; margin-top: 12px;
width: 250px; width: 250px;
@ -20,6 +14,6 @@
padding: 12px; padding: 12px;
font-size: 36rpx; font-size: 36rpx;
font-weight: 600; font-weight: 600;
color: #333; color: #666;
} }
} }

View File

@ -1,18 +0,0 @@
<template>
<button
v-if="!hasToken"
class="reset-btn"
open-type="getPhoneNumber"
@getphonenumber="onLogin"
/>
</template>
<script setup>
import { computed, defineEmits } from "vue";
import { useAppStore } from "@/store";
import { onLogin } from "@/hooks/useGoLogin";
const emits = defineEmits(["click"]);
const hasToken = computed(() => useAppStore().hasToken);
</script>

View File

@ -1,8 +1,11 @@
// 退出登录
export const NOTICE_EVENT_LOGOUT = "NOTICE_EVENT_LOGOUT";
// 滚动到底部 // 滚动到底部
export const SCROLL_TO_BOTTOM = 'SCROLL_TO_BOTTOM' export const SCROLL_TO_BOTTOM = "SCROLL_TO_BOTTOM";
// 推荐帖子 // 推荐帖子
export const RECOMMEND_POSTS_TITLE = 'RECOMMEND_POSTS_TITLE' export const RECOMMEND_POSTS_TITLE = "RECOMMEND_POSTS_TITLE";
// 发送命令 // 发送命令
export const SEND_COMMAND_TEXT = 'SEND_COMMAND_TEXT' export const SEND_COMMAND_TEXT = "SEND_COMMAND_TEXT";

View File

@ -1,6 +1,6 @@
import { loginAuth, bindPhone } from "@/manager/LoginManager"; import { loginAuth, bindPhone } from "@/manager/LoginManager";
// 引入base.js中的clientId import { clientId } from "@/constant/base";
import { clientId } from "@/constant/base"; import { useAppStore } from "@/store";
// 跳转登录 // 跳转登录
export const goLogin = () => uni.navigateTo({ url: "/pages/login/index" }); export const goLogin = () => uni.navigateTo({ url: "/pages/login/index" });
@ -26,14 +26,13 @@ export const onLogin = async (e) => {
}; };
// 检测token // 检测token
export const checkToken = async () => { export const checkToken = () => {
return new Promise((resolve) => { return new Promise((resolve) => {
const token = uni.getStorageSync("token"); const appStore = useAppStore();
if (!token) { console.log("appStore.hasToken: ", appStore.hasToken);
console.log("token不存在重新登录"); if (!appStore.hasToken) {
loginAuth().then(() => { console.log("没有token跳转到登录页");
resolve(); goLogin();
});
return; return;
} }
resolve(); resolve();

View File

@ -1,20 +1,30 @@
export const MessageRole = { export const MessageRole = {
AI: "AI", // 智能体消息
ME: "ME", AI: "AI",
OTHER: "OTHER" // 我发送的消息
} ME: "ME",
// 其他消息
OTHER: "OTHER",
};
export const MessageType = { export const MessageType = {
TEXT: 'TEXT', // 文本消息
IMAGE: 'IMAGE' TEXT: "TEXT",
} // 图片消息
IMAGE: "IMAGE",
};
export const CompName = { export const CompName = {
// 快速预定卡片
quickBookingCard: "quickBookingCard", quickBookingCard: "quickBookingCard",
// 服务工单卡片
createWorkOrderCard: "createWorkOrderCard", createWorkOrderCard: "createWorkOrderCard",
// 意见反馈卡片
feedbackCard: "feedbackCard", feedbackCard: "feedbackCard",
// 探索发现卡片
discoveryCard: "discoveryCard", discoveryCard: "discoveryCard",
addLicensePlate: "addLicensePlate", // 图片和商品卡片
pictureAndCommodityCard: "pictureAndCommodityCard",
// 输入车牌卡片
enterLicensePlateCard: "enterLicensePlateCard",
}; };

View File

@ -31,17 +31,6 @@
> >
</ChatTopWelcome> </ChatTopWelcome>
<ChatCardAI class="message-item-ai">
<template #content>
<!-- 车牌添加卡片 -->
<AddCarCrad
:toolCall="{
url: 'https://shop.gzcyb.vip/scanQrFixCode?fixCodeId=49892',
}"
/>
</template>
</ChatCardAI>
<view <view
class="area-msg-list-content" class="area-msg-list-content"
v-for="item in chatMsgList" v-for="item in chatMsgList"
@ -78,12 +67,16 @@
:toolCall="item.toolCall" :toolCall="item.toolCall"
/> />
<DetailCardCompontent <DetailCardCompontent
v-else-if="item.toolCall.componentName === ''" v-else-if="
item.toolCall.componentName ===
CompName.pictureAndCommodityCard
"
:toolCall="item.toolCall" :toolCall="item.toolCall"
/> />
<AddCarCrad <AddCarCrad
v-else-if=" v-else-if="
item.toolCall.componentName === CompName.addLicensePlate item.toolCall.componentName ===
CompName.enterLicensePlateCard
" "
:toolCall="item.toolCall" :toolCall="item.toolCall"
/> />
@ -158,6 +151,7 @@ import {
SCROLL_TO_BOTTOM, SCROLL_TO_BOTTOM,
RECOMMEND_POSTS_TITLE, RECOMMEND_POSTS_TITLE,
SEND_COMMAND_TEXT, SEND_COMMAND_TEXT,
NOTICE_EVENT_LOGOUT,
} from "@/constant/constant"; } from "@/constant/constant";
import { WSS_URL } from "@/request/base/baseUrl"; import { WSS_URL } from "@/request/base/baseUrl";
import { MessageRole, MessageType, CompName } from "../../model/ChatModel"; import { MessageRole, MessageType, CompName } from "../../model/ChatModel";
@ -187,7 +181,7 @@ 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 { goLogin } from "@/hooks/useGoLogin"; import { goLogin, checkToken } from "@/hooks/useGoLogin";
import { useAppStore } from "@/store"; import { useAppStore } from "@/store";
const appStore = useAppStore(); const appStore = useAppStore();
@ -196,7 +190,7 @@ const statusBarHeight = ref(20);
/// ///
const inputAreaRef = ref(null); const inputAreaRef = ref(null);
const timer = ref(null); const holdKeyboardTimer = ref(null);
/// focus /// focus
const holdKeyboard = ref(false); const holdKeyboard = ref(false);
/// ///
@ -242,8 +236,8 @@ const openDrawer = () => emits("openDrawer");
/// ============================= /// =============================
const handleTouchEnd = () => { const handleTouchEnd = () => {
clearTimeout(timer.value); clearTimeout(holdKeyboardTimer.value);
timer.value = setTimeout(() => { holdKeyboardTimer.value = setTimeout(() => {
// //
if (holdKeyboardFlag.value && isKeyboardShow.value) { if (holdKeyboardFlag.value && isKeyboardShow.value) {
uni.hideKeyboard(); uni.hideKeyboard();
@ -303,12 +297,9 @@ const handleReply = (text) => {
}; };
// //
const handleReplyInstruct = (item) => { const handleReplyInstruct = async (item) => {
if (!appStore.hasToken) { await checkToken();
console.log("没有token跳转到登录页");
goLogin();
return;
}
if (item.type === "MyOrder") { if (item.type === "MyOrder") {
// //
uni.navigateTo({ uni.navigateTo({
@ -345,6 +336,13 @@ const sendMessageAction = (inputText) => {
/// ///
const addNoticeListener = () => { const addNoticeListener = () => {
uni.$on(NOTICE_EVENT_LOGOUT, () => {
resetConfig();
uni.showToast({
title: "退出登录成功",
});
});
uni.$on(SCROLL_TO_BOTTOM, () => { uni.$on(SCROLL_TO_BOTTOM, () => {
setTimeout(() => { setTimeout(() => {
scrollToBottom(); scrollToBottom();
@ -631,14 +629,10 @@ const initData = () => {
}; };
// //
const sendMessage = (message, isInstruct = false) => { const sendMessage = async (message, isInstruct = false) => {
console.log("发送的消息:", message); console.log("发送的消息:", message);
if (!appStore.hasToken) { await checkToken();
console.log("没有token跳转到登录页");
goLogin();
return;
}
if (!webSocketConnectStatus) { if (!webSocketConnectStatus) {
uni.showToast({ uni.showToast({
@ -780,7 +774,12 @@ onUnmounted(() => {
uni.$off(SCROLL_TO_BOTTOM); uni.$off(SCROLL_TO_BOTTOM);
uni.$off(RECOMMEND_POSTS_TITLE); uni.$off(RECOMMEND_POSTS_TITLE);
uni.$off(SEND_COMMAND_TEXT); uni.$off(SEND_COMMAND_TEXT);
uni.$off(NOTICE_EVENT_LOGOUT);
resetConfig();
});
const resetConfig = () => {
// WebSocket // WebSocket
if (webSocketManager) { if (webSocketManager) {
webSocketManager.destroy(); webSocketManager.destroy();
@ -797,11 +796,11 @@ onUnmounted(() => {
resetMessageState(); resetMessageState();
// //
if (timer.value) { if (holdKeyboardTimer.value) {
clearTimeout(timer.value); clearTimeout(holdKeyboardTimer.value);
timer.value = null; holdKeyboardTimer.value = null;
} }
}); };
</script> </script>
<style lang="scss" scoped> <style lang="scss" scoped>

View File

@ -13,18 +13,12 @@
<script setup> <script setup>
import { 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 { checkToken } from "@/hooks/useGoLogin";
import { useAppStore } from "@/store";
const appStore = useAppStore();
const showLeft = ref(false); const showLeft = ref(false);
// //
const showDrawer = (e) => { const showDrawer = async (e) => {
if (!appStore.hasToken) { await checkToken();
console.log("没有token跳转到登录页");
goLogin();
return;
}
showLeft.value.open(); showLeft.value.open();
// //

View File

@ -11,7 +11,7 @@
<text class="title">我的</text> <text class="title">我的</text>
</view> </view>
<MineSetting v-if="isDrawerVisible" /> <MineSetting v-if="isDrawerVisible" @closeDrawer="closeDrawer" />
</view> </view>
</template> </template>
@ -23,6 +23,7 @@ const emits = defineEmits(["closeDrawer"]);
const isDrawerVisible = ref(false); const isDrawerVisible = ref(false);
const closeDrawer = () => { const closeDrawer = () => {
console.log("关闭抽屉");
isDrawerVisible.value = false; isDrawerVisible.value = false;
emits("closeDrawer"); emits("closeDrawer");
}; };

View File

@ -36,8 +36,13 @@
</template> </template>
<script setup> <script setup>
import { ref, onMounted } from "vue"; import { ref, onMounted, defineEmits } from "vue";
import { getLoginUserPhone } from "@/request/api/LoginApi"; import { getLoginUserPhone } from "@/request/api/LoginApi";
import { NOTICE_EVENT_LOGOUT } from "@/constant/constant";
import { useAppStore } from "@/store";
const appStore = useAppStore();
const emits = defineEmits(["closeDrawer"]);
// //
const userInfo = ref({ const userInfo = ref({
@ -51,12 +56,12 @@ const menuList = ref([
// { label: '', type: 'navigate', url: '/pages/change-phone/change-phone' }, // { label: '', type: 'navigate', url: '/pages/change-phone/change-phone' },
{ {
label: "账号注销", label: "账号注销",
type: "navigate", type: "action",
url: "/pages/cancel-account/cancel-account", url: "cancelAccount",
}, },
// { label: '&', type: 'navigate', url: '/pages/agreement/agreement' }, // { label: '&', type: 'navigate', url: '/pages/agreement/agreement' },
{ label: "联系客服", type: "action", action: "contactService" }, // { label: "", type: "action", action: "contactService" },
{ label: "订阅消息", type: "action", action: "subscribeMessage" }, // { label: "", type: "action", action: "subscribeMessage" },
]); ]);
// //
@ -79,6 +84,8 @@ const handleMenuClick = (item) => {
} else if (item.type === "action") { } else if (item.type === "action") {
if (item.action === "contactService") { if (item.action === "contactService") {
uni.showToast({ title: "联系客服功能待实现", icon: "none" }); uni.showToast({ title: "联系客服功能待实现", icon: "none" });
} else if (item.action === "cancelAccount") {
handleLogout();
} else if (item.action === "subscribeMessage") { } else if (item.action === "subscribeMessage") {
uni.requestSubscribeMessage({ uni.requestSubscribeMessage({
tmplIds: ["fMIt1q9GgM3Ep0DJSNgVPm4C3lCpQdz2TediETcv3iM"], tmplIds: ["fMIt1q9GgM3Ep0DJSNgVPm4C3lCpQdz2TediETcv3iM"],
@ -98,7 +105,9 @@ const handleLogout = () => {
success: (res) => { success: (res) => {
if (res.confirm) { if (res.confirm) {
uni.clearStorageSync(); uni.clearStorageSync();
uni.reLaunch({ url: "/pages/login/index" }); appStore.setHasToken(false);
emits("closeDrawer");
uni.$emit(NOTICE_EVENT_LOGOUT);
} }
}, },
}); });

View File

@ -32,7 +32,7 @@
<view class="card-price-row"> <view class="card-price-row">
<text class="card-price-fu"></text> <text class="card-price-fu"></text>
<text class="card-price">{{ item.commodityPrice }}</text> <text class="card-price">{{ item.commodityPrice }}</text>
<text class="card-unit">/</text> <text class="card-unit">/{{ item.stockUnitLabel }}</text>
</view> </view>
<text class="card-btn">下单</text> <text class="card-btn">下单</text>
@ -47,6 +47,7 @@
<script setup> <script setup>
import ModuleTitle from "@/components/ModuleTitle/index.vue"; import ModuleTitle from "@/components/ModuleTitle/index.vue";
import { defineProps } from "vue"; import { defineProps } from "vue";
import { checkToken } from "@/hooks/useGoLogin";
const props = defineProps({ const props = defineProps({
commodityDTO: { commodityDTO: {
@ -57,8 +58,10 @@ const props = defineProps({
/// ///
const placeOrderHandle = (item) => { const placeOrderHandle = (item) => {
uni.navigateTo({ checkToken().then(() => {
url: `/pages/goods/index?commodityId=${item.commodityId}`, uni.navigateTo({
url: `/pages/goods/index?commodityId=${item.commodityId}`,
});
}); });
}; };
</script> </script>

View File

@ -35,7 +35,7 @@
<view class="card-price-row"> <view class="card-price-row">
<text class="card-price-fu"></text> <text class="card-price-fu"></text>
<text class="card-price">{{ item.specificationPrice }}</text> <text class="card-price">{{ item.specificationPrice }}</text>
<text class="card-unit">/</text> <text class="card-unit">/{{ item.stockUnitLabel }} </text>
</view> </view>
<text class="card-btn">下单</text> <text class="card-btn">下单</text>
</view> </view>

View File

@ -1,6 +1,5 @@
import { goLogin } from "../../hooks/useGoLogin"; import { goLogin } from "../../hooks/useGoLogin";
import { BASE_URL } from "./baseUrl"; import { BASE_URL } from "./baseUrl";
import { loginAuth, checkPhone } from "@/manager/LoginManager";
const defaultConfig = { const defaultConfig = {
header: { header: {
@ -53,13 +52,7 @@ function request(url, args = {}, method = "POST", customConfig = {}) {
resolve(res.data); resolve(res.data);
if (res.statusCode && res.statusCode === 424) { if (res.statusCode && res.statusCode === 424) {
console.log("424错误重新登录"); console.log("424错误重新登录");
loginAuth().then(async () => { goLogin();
// 检测是否绑定手机号
const res = await checkPhone();
if (!res.data) {
goLogin();
}
});
} }
}, },
fail: (err) => { fail: (err) => {