Compare commits
No commits in common. "4cdff7a594a803aa9c3a34c93679f03a39b82bd2" and "64db5ebaf33e773c6ddd4533fd7abe0305402a72" have entirely different histories.
4cdff7a594
...
64db5ebaf3
@ -5,7 +5,7 @@
|
||||
</view>
|
||||
<image
|
||||
class="code-img"
|
||||
src="https://one-feel-config-images-bucket.oss-cn-chengdu.aliyuncs.com/20250920102920_354_52.png"
|
||||
src="./images/qrcode.png"
|
||||
mode="widthFix"
|
||||
show-menu-by-longpress="true"
|
||||
/>
|
||||
|
||||
@ -3,6 +3,12 @@
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
|
||||
.description {
|
||||
font-size: 28rpx;
|
||||
color: #666;
|
||||
line-height: 1.5;
|
||||
}
|
||||
|
||||
.code-img {
|
||||
margin-top: 12px;
|
||||
width: 250px;
|
||||
@ -14,6 +20,6 @@
|
||||
padding: 12px;
|
||||
font-size: 36rpx;
|
||||
font-weight: 600;
|
||||
color: #666;
|
||||
color: #333;
|
||||
}
|
||||
}
|
||||
|
||||
18
components/Interceptor/index.vue
Normal file
18
components/Interceptor/index.vue
Normal file
@ -0,0 +1,18 @@
|
||||
<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>
|
||||
@ -1,11 +1,8 @@
|
||||
// 退出登录
|
||||
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'
|
||||
@ -1,6 +1,6 @@
|
||||
import { loginAuth, bindPhone } from "@/manager/LoginManager";
|
||||
import { clientId } from "@/constant/base";
|
||||
import { useAppStore } from "@/store";
|
||||
// 引入base.js中的clientId
|
||||
import { clientId } from "@/constant/base";
|
||||
|
||||
// 跳转登录
|
||||
export const goLogin = () => uni.navigateTo({ url: "/pages/login/index" });
|
||||
@ -26,13 +26,14 @@ export const onLogin = async (e) => {
|
||||
};
|
||||
|
||||
// 检测token
|
||||
export const checkToken = () => {
|
||||
export const checkToken = async () => {
|
||||
return new Promise((resolve) => {
|
||||
const appStore = useAppStore();
|
||||
console.log("appStore.hasToken: ", appStore.hasToken);
|
||||
if (!appStore.hasToken) {
|
||||
console.log("没有token,跳转到登录页");
|
||||
goLogin();
|
||||
const token = uni.getStorageSync("token");
|
||||
if (!token) {
|
||||
console.log("token不存在,重新登录");
|
||||
loginAuth().then(() => {
|
||||
resolve();
|
||||
});
|
||||
return;
|
||||
}
|
||||
resolve();
|
||||
|
||||
@ -1,30 +1,20 @@
|
||||
|
||||
export const MessageRole = {
|
||||
// 智能体消息
|
||||
AI: "AI",
|
||||
// 我发送的消息
|
||||
ME: "ME",
|
||||
// 其他消息
|
||||
OTHER: "OTHER",
|
||||
};
|
||||
OTHER: "OTHER"
|
||||
}
|
||||
|
||||
export const MessageType = {
|
||||
// 文本消息
|
||||
TEXT: "TEXT",
|
||||
// 图片消息
|
||||
IMAGE: "IMAGE",
|
||||
};
|
||||
TEXT: 'TEXT',
|
||||
IMAGE: 'IMAGE'
|
||||
}
|
||||
|
||||
|
||||
export const CompName = {
|
||||
// 快速预定卡片
|
||||
quickBookingCard: "quickBookingCard",
|
||||
// 服务工单卡片
|
||||
createWorkOrderCard: "createWorkOrderCard",
|
||||
// 意见反馈卡片
|
||||
feedbackCard: "feedbackCard",
|
||||
// 探索发现卡片
|
||||
discoveryCard: "discoveryCard",
|
||||
// 图片和商品卡片
|
||||
pictureAndCommodityCard: "pictureAndCommodityCard",
|
||||
// 输入车牌卡片
|
||||
enterLicensePlateCard: "enterLicensePlateCard",
|
||||
addLicensePlate: "addLicensePlate",
|
||||
};
|
||||
@ -31,6 +31,17 @@
|
||||
>
|
||||
</ChatTopWelcome>
|
||||
|
||||
<ChatCardAI class="message-item-ai">
|
||||
<template #content>
|
||||
<!-- 车牌添加卡片 -->
|
||||
<AddCarCrad
|
||||
:toolCall="{
|
||||
url: 'https://shop.gzcyb.vip/scanQrFixCode?fixCodeId=49892',
|
||||
}"
|
||||
/>
|
||||
</template>
|
||||
</ChatCardAI>
|
||||
|
||||
<view
|
||||
class="area-msg-list-content"
|
||||
v-for="item in chatMsgList"
|
||||
@ -67,16 +78,12 @@
|
||||
:toolCall="item.toolCall"
|
||||
/>
|
||||
<DetailCardCompontent
|
||||
v-else-if="
|
||||
item.toolCall.componentName ===
|
||||
CompName.pictureAndCommodityCard
|
||||
"
|
||||
v-else-if="item.toolCall.componentName === ''"
|
||||
:toolCall="item.toolCall"
|
||||
/>
|
||||
<AddCarCrad
|
||||
v-else-if="
|
||||
item.toolCall.componentName ===
|
||||
CompName.enterLicensePlateCard
|
||||
item.toolCall.componentName === CompName.addLicensePlate
|
||||
"
|
||||
:toolCall="item.toolCall"
|
||||
/>
|
||||
@ -151,7 +158,6 @@ import {
|
||||
SCROLL_TO_BOTTOM,
|
||||
RECOMMEND_POSTS_TITLE,
|
||||
SEND_COMMAND_TEXT,
|
||||
NOTICE_EVENT_LOGOUT,
|
||||
} from "@/constant/constant";
|
||||
import { WSS_URL } from "@/request/base/baseUrl";
|
||||
import { MessageRole, MessageType, CompName } from "../../model/ChatModel";
|
||||
@ -181,7 +187,7 @@ import {
|
||||
import WebSocketManager from "@/utils/WebSocketManager";
|
||||
import TypewriterManager from "@/utils/TypewriterManager";
|
||||
import { IdUtils } from "@/utils";
|
||||
import { goLogin, checkToken } from "@/hooks/useGoLogin";
|
||||
import { goLogin } from "@/hooks/useGoLogin";
|
||||
|
||||
import { useAppStore } from "@/store";
|
||||
const appStore = useAppStore();
|
||||
@ -190,7 +196,7 @@ const statusBarHeight = ref(20);
|
||||
/// 输入框组件引用
|
||||
const inputAreaRef = ref(null);
|
||||
|
||||
const holdKeyboardTimer = ref(null);
|
||||
const timer = ref(null);
|
||||
/// focus时,点击页面的时候不收起键盘
|
||||
const holdKeyboard = ref(false);
|
||||
/// 是否在键盘弹出,点击界面时关闭键盘
|
||||
@ -236,8 +242,8 @@ const openDrawer = () => emits("openDrawer");
|
||||
|
||||
/// =============事件函数↓================
|
||||
const handleTouchEnd = () => {
|
||||
clearTimeout(holdKeyboardTimer.value);
|
||||
holdKeyboardTimer.value = setTimeout(() => {
|
||||
clearTimeout(timer.value);
|
||||
timer.value = setTimeout(() => {
|
||||
// 键盘弹出时点击界面则关闭键盘
|
||||
if (holdKeyboardFlag.value && isKeyboardShow.value) {
|
||||
uni.hideKeyboard();
|
||||
@ -297,9 +303,12 @@ const handleReply = (text) => {
|
||||
};
|
||||
|
||||
// 是发送指令
|
||||
const handleReplyInstruct = async (item) => {
|
||||
await checkToken();
|
||||
|
||||
const handleReplyInstruct = (item) => {
|
||||
if (!appStore.hasToken) {
|
||||
console.log("没有token,跳转到登录页");
|
||||
goLogin();
|
||||
return;
|
||||
}
|
||||
if (item.type === "MyOrder") {
|
||||
// 订单
|
||||
uni.navigateTo({
|
||||
@ -336,13 +345,6 @@ const sendMessageAction = (inputText) => {
|
||||
|
||||
/// 添加通知
|
||||
const addNoticeListener = () => {
|
||||
uni.$on(NOTICE_EVENT_LOGOUT, () => {
|
||||
resetConfig();
|
||||
uni.showToast({
|
||||
title: "退出登录成功",
|
||||
});
|
||||
});
|
||||
|
||||
uni.$on(SCROLL_TO_BOTTOM, () => {
|
||||
setTimeout(() => {
|
||||
scrollToBottom();
|
||||
@ -629,10 +631,14 @@ const initData = () => {
|
||||
};
|
||||
|
||||
// 发送消息的参数拼接
|
||||
const sendMessage = async (message, isInstruct = false) => {
|
||||
const sendMessage = (message, isInstruct = false) => {
|
||||
console.log("发送的消息:", message);
|
||||
|
||||
await checkToken();
|
||||
if (!appStore.hasToken) {
|
||||
console.log("没有token,跳转到登录页");
|
||||
goLogin();
|
||||
return;
|
||||
}
|
||||
|
||||
if (!webSocketConnectStatus) {
|
||||
uni.showToast({
|
||||
@ -774,12 +780,7 @@ onUnmounted(() => {
|
||||
uni.$off(SCROLL_TO_BOTTOM);
|
||||
uni.$off(RECOMMEND_POSTS_TITLE);
|
||||
uni.$off(SEND_COMMAND_TEXT);
|
||||
uni.$off(NOTICE_EVENT_LOGOUT);
|
||||
|
||||
resetConfig();
|
||||
});
|
||||
|
||||
const resetConfig = () => {
|
||||
// 清理WebSocket连接
|
||||
if (webSocketManager) {
|
||||
webSocketManager.destroy();
|
||||
@ -796,11 +797,11 @@ const resetConfig = () => {
|
||||
resetMessageState();
|
||||
|
||||
// 清理定时器
|
||||
if (holdKeyboardTimer.value) {
|
||||
clearTimeout(holdKeyboardTimer.value);
|
||||
holdKeyboardTimer.value = null;
|
||||
if (timer.value) {
|
||||
clearTimeout(timer.value);
|
||||
timer.value = null;
|
||||
}
|
||||
};
|
||||
});
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
|
||||
@ -13,12 +13,18 @@
|
||||
<script setup>
|
||||
import { ref } from "vue";
|
||||
import DrawerHome from "@/pages/drawer/DrawerHome.vue";
|
||||
import { checkToken } from "@/hooks/useGoLogin";
|
||||
import { goLogin } from "@/hooks/useGoLogin";
|
||||
import { useAppStore } from "@/store";
|
||||
const appStore = useAppStore();
|
||||
const showLeft = ref(false);
|
||||
|
||||
// 打开窗口
|
||||
const showDrawer = async (e) => {
|
||||
await checkToken();
|
||||
const showDrawer = (e) => {
|
||||
if (!appStore.hasToken) {
|
||||
console.log("没有token,跳转到登录页");
|
||||
goLogin();
|
||||
return;
|
||||
}
|
||||
|
||||
showLeft.value.open();
|
||||
// 发送抽屉显示事件
|
||||
|
||||
@ -11,7 +11,7 @@
|
||||
<text class="title">我的</text>
|
||||
</view>
|
||||
|
||||
<MineSetting v-if="isDrawerVisible" @closeDrawer="closeDrawer" />
|
||||
<MineSetting v-if="isDrawerVisible" />
|
||||
</view>
|
||||
</template>
|
||||
|
||||
@ -23,7 +23,6 @@ const emits = defineEmits(["closeDrawer"]);
|
||||
const isDrawerVisible = ref(false);
|
||||
|
||||
const closeDrawer = () => {
|
||||
console.log("关闭抽屉");
|
||||
isDrawerVisible.value = false;
|
||||
emits("closeDrawer");
|
||||
};
|
||||
|
||||
@ -36,13 +36,8 @@
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import { ref, onMounted, defineEmits } from "vue";
|
||||
import { ref, onMounted } from "vue";
|
||||
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({
|
||||
@ -56,12 +51,12 @@ const menuList = ref([
|
||||
// { label: '修改手机号', type: 'navigate', url: '/pages/change-phone/change-phone' },
|
||||
{
|
||||
label: "账号注销",
|
||||
type: "action",
|
||||
url: "cancelAccount",
|
||||
type: "navigate",
|
||||
url: "/pages/cancel-account/cancel-account",
|
||||
},
|
||||
// { label: '营业资质&协议', type: 'navigate', url: '/pages/agreement/agreement' },
|
||||
// { label: "联系客服", type: "action", action: "contactService" },
|
||||
// { label: "订阅消息", type: "action", action: "subscribeMessage" },
|
||||
{ label: "联系客服", type: "action", action: "contactService" },
|
||||
{ label: "订阅消息", type: "action", action: "subscribeMessage" },
|
||||
]);
|
||||
|
||||
// 组件挂载时调用
|
||||
@ -84,8 +79,6 @@ const handleMenuClick = (item) => {
|
||||
} else if (item.type === "action") {
|
||||
if (item.action === "contactService") {
|
||||
uni.showToast({ title: "联系客服功能待实现", icon: "none" });
|
||||
} else if (item.action === "cancelAccount") {
|
||||
handleLogout();
|
||||
} else if (item.action === "subscribeMessage") {
|
||||
uni.requestSubscribeMessage({
|
||||
tmplIds: ["fMIt1q9GgM3Ep0DJSNgVPm4C3lCpQdz2TediETcv3iM"],
|
||||
@ -105,9 +98,7 @@ const handleLogout = () => {
|
||||
success: (res) => {
|
||||
if (res.confirm) {
|
||||
uni.clearStorageSync();
|
||||
appStore.setHasToken(false);
|
||||
emits("closeDrawer");
|
||||
uni.$emit(NOTICE_EVENT_LOGOUT);
|
||||
uni.reLaunch({ url: "/pages/login/index" });
|
||||
}
|
||||
},
|
||||
});
|
||||
|
||||
@ -32,7 +32,7 @@
|
||||
<view class="card-price-row">
|
||||
<text class="card-price-fu">¥</text>
|
||||
<text class="card-price">{{ item.commodityPrice }}</text>
|
||||
<text class="card-unit">/{{ item.stockUnitLabel }}</text>
|
||||
<text class="card-unit">/人</text>
|
||||
</view>
|
||||
|
||||
<text class="card-btn">下单</text>
|
||||
@ -47,7 +47,6 @@
|
||||
<script setup>
|
||||
import ModuleTitle from "@/components/ModuleTitle/index.vue";
|
||||
import { defineProps } from "vue";
|
||||
import { checkToken } from "@/hooks/useGoLogin";
|
||||
|
||||
const props = defineProps({
|
||||
commodityDTO: {
|
||||
@ -58,11 +57,9 @@ const props = defineProps({
|
||||
|
||||
/// 去下单
|
||||
const placeOrderHandle = (item) => {
|
||||
checkToken().then(() => {
|
||||
uni.navigateTo({
|
||||
url: `/pages/goods/index?commodityId=${item.commodityId}`,
|
||||
});
|
||||
});
|
||||
};
|
||||
</script>
|
||||
|
||||
|
||||
@ -35,7 +35,7 @@
|
||||
<view class="card-price-row">
|
||||
<text class="card-price-fu">¥</text>
|
||||
<text class="card-price">{{ item.specificationPrice }}</text>
|
||||
<text class="card-unit">/{{ item.stockUnitLabel }} </text>
|
||||
<text class="card-unit">/人</text>
|
||||
</view>
|
||||
<text class="card-btn">下单</text>
|
||||
</view>
|
||||
|
||||
@ -1,5 +1,6 @@
|
||||
import { goLogin } from "../../hooks/useGoLogin";
|
||||
import { BASE_URL } from "./baseUrl";
|
||||
import { loginAuth, checkPhone } from "@/manager/LoginManager";
|
||||
|
||||
const defaultConfig = {
|
||||
header: {
|
||||
@ -52,8 +53,14 @@ function request(url, args = {}, method = "POST", customConfig = {}) {
|
||||
resolve(res.data);
|
||||
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);
|
||||
|
||||
Loading…
Reference in New Issue
Block a user