Compare commits

..

No commits in common. "f585c83554fa94442272bc8cd0ab480d807687c4" and "843d8d3138a3bec2ce9684dc728f7f089377cd32" have entirely different histories.

40 changed files with 286 additions and 721 deletions

View File

@ -3,5 +3,11 @@ NODE_ENV = development
# 测试 # 测试
VITE_BASE_URL = https://onefeel.brother7.cn/ingress VITE_BASE_URL = https://onefeel.brother7.cn/ingress
# 生产
# VITE_BASE_URL = https://biz.nianxx.cn
# 测试 # 测试
VITE_WSS_URL = wss://onefeel.brother7.cn/ingress/agent/ws/chat VITE_WSS_URL = wss://onefeel.brother7.cn/ingress/agent/ws/chat
# 生产
# VITE_WSS_URL = wss://biz.nianxx.cn/agent/ws/chat

View File

@ -1,7 +1,13 @@
NODE_ENV = production NODE_ENV = production
# 生产 # 测试
VITE_BASE_URL = https://biz.nianxx.cn VITE_BASE_URL = https://onefeel.brother7.cn/ingress
# 生产 # 生产
VITE_WSS_URL = wss://biz.nianxx.cn/agent/ws/chat # VITE_BASE_URL = https://biz.nianxx.cn
# 测试
VITE_WSS_URL = wss://onefeel.brother7.cn/ingress/agent/ws/chat
# 生产
# VITE_WSS_URL = wss://biz.nianxx.cn/agent/ws/chat

View File

@ -1,7 +1,13 @@
NODE_ENV = staging NODE_ENV = staging
# 生产 # 测试
VITE_BASE_URL = https://biz.nianxx.cn VITE_BASE_URL = https://onefeel.brother7.cn/ingress
# 生产 # 生产
VITE_WSS_URL = wss://biz.nianxx.cn/agent/ws/chat # VITE_BASE_URL = https://biz.nianxx.cn
# 测试
VITE_WSS_URL = wss://onefeel.brother7.cn/ingress/agent/ws/chat
# 生产
# VITE_WSS_URL = wss://biz.nianxx.cn/agent/ws/chat

Binary file not shown.

Before

Width:  |  Height:  |  Size: 48 KiB

View File

@ -1,43 +0,0 @@
<template>
<view class="add-car-card" @click="handleConfirm">
<view class="header-image">
<image
class="header-img"
src="./images/add_car_crad.png"
mode="aspectFill"
/>
</view>
<view class="content">
<view class="title">请输入车牌号</view>
<view class="description">
请绑定真实有效的车牌号否则将无法正常使用车牌付费等功能
</view>
</view>
<view class="confirm-btn">
<text class="confirm-text">进入绑定</text>
</view>
</view>
</template>
<script setup>
import { defineProps } from "vue";
import { navigateTo } from "@/router/index";
const props = defineProps({
toolCall: {
type: Object,
default: {},
},
});
//
const handleConfirm = () => {
navigateTo(props.toolCall.url);
};
</script>
<style lang="scss" scoped>
@import "./styles/index.scss";
</style>

View File

@ -1,51 +0,0 @@
.add-car-card {
display: flex;
flex-direction: column;
.header-image {
display: flex;
justify-content: center;
align-items: center;
margin: -24rpx -24rpx 0 -24rpx;
.header-img {
width: 100%;
height: 150px;
}
}
.content {
display: flex;
align-items: start;
flex-direction: column;
padding: 24rpx 0;
}
.title {
font-size: 36rpx;
font-weight: 600;
color: #333;
}
.description {
font-size: 28rpx;
color: #666;
line-height: 1.5;
}
.confirm-btn {
height: 88rpx;
background: linear-gradient(135deg, #1898ff 0%, #77e5f9 100%);
border-radius: 44rpx;
margin-bottom: 24rpx;
display: flex;
align-items: center;
justify-content: center;
.confirm-text {
font-size: 28rpx;
font-weight: 500;
color: #fff;
}
}
}

View File

@ -93,7 +93,9 @@ const props = defineProps({
// //
priceData: { priceData: {
type: Array, type: Array,
default: () => [{ date: "", price: "-", stock: "0" }], default: () => [
{date: '', price: '-', stock: '0'}
],
}, },
// //
@ -208,7 +210,7 @@ const getPriceForDate = (dateStr) => {
return null; return null;
} }
const priceItem = props.priceData.find((item) => item.date === dateStr); const priceItem = props.priceData.find(item => item.date === dateStr);
return priceItem ? priceItem.price : null; return priceItem ? priceItem.price : null;
}; };
@ -385,58 +387,22 @@ const handleRangeSelection = (dateInfo) => {
return; return;
} }
//
const dateRange = generateDateRange(rangeStart.value, rangeEnd.value);
emit("range-select", { emit("range-select", {
startDate: rangeStart.value, startDate: rangeStart.value,
endDate: rangeEnd.value, endDate: rangeEnd.value,
startPrice: getPriceForDate(rangeStart.value), startPrice: getPriceForDate(rangeStart.value),
endPrice: getPriceForDate(rangeEnd.value), endPrice: getPriceForDate(rangeEnd.value),
totalDays: daysBetween, totalDays: daysBetween,
dateRange: dateRange, //
}); });
} }
}; };
//
const generateDateRange = (startDate, endDate) => {
const dateRange = [];
const start = new Date(startDate);
const end = new Date(endDate);
//
if (startDate === endDate) {
return [
{
date: startDate,
price: getPriceForDate(startDate),
},
];
}
//
const current = new Date(start);
while (current <= end) {
const dateStr = current.toISOString().split("T")[0];
dateRange.push({
date: dateStr,
price: getPriceForDate(dateStr),
});
current.setDate(current.getDate() + 1);
}
return dateRange;
};
// //
const calculateDaysBetween = (startDate, endDate) => { const calculateDaysBetween = (startDate, endDate) => {
const start = new Date(startDate); const start = new Date(startDate);
const end = new Date(endDate); const end = new Date(endDate);
const diffTime = Math.abs(end - start); const diffTime = Math.abs(end - start);
const days = Math.ceil(diffTime / (1000 * 60 * 60 * 24)); return Math.ceil(diffTime / (1000 * 60 * 60 * 24));
// 10
return days === 0 ? 1 : days;
}; };
// visibleuni-popup // visibleuni-popup

View File

@ -1,7 +1,7 @@
// 颜色系统 // 颜色系统
$primary-color: #1890ff; $primary-color: #1890ff;
$primary-light: #e6f7ff; $primary-light: #e6f7ff;
$primary-dark: #1890ff; $primary-dark: #0050b3;
// 中性色 // 中性色
$text-primary: #262626; $text-primary: #262626;

View File

@ -1,28 +1,8 @@
// 小程序特有相关: 同时更改manifest.json和 project.config.json文件中的appid const isProd = true;
// 所有用户端的配置
export const CLIENT_CONFIGS = {
// 智念用户端
zhinian: {
clientId: '2',
appId: 'wx5e79df5996572539'
},
// 朵花用户端
duohua: {
clientId: '2',
appId: 'wx23f86d809ae80259'
},
// 天沐用户端
tianmu: {
clientId: '4',
appId: 'wx0be424e1d22065a9'
}
};
// 获取当前用户端配置 console.log(import.meta.env);
const getCurrentConfig = () => {
return CLIENT_CONFIGS.zhinian;
};
export const clientId = getCurrentConfig().clientId; export const BASE_URL = import.meta.env.VITE_BASE_URL;
export const appId = getCurrentConfig().appId;
// socket地址
export const WSS_URL = import.meta.env.VITE_WSS_URL;

View File

@ -1,27 +1,27 @@
import { loginAuth, bindPhone } from "@/manager/LoginManager"; import { loginAuth, checkPhone, bindPhone } from "@/manager/LoginManager";
// 引入base.js中的clientId
import { clientId } from "@/constant/base";
// 跳转登录 // 跳转登录
export const goLogin = () => uni.navigateTo({ url: "/pages/login/index" }); export const goLogin = () => uni.reLaunch({ url: "/pages/login/index" });
// 登录成功后,返回上一页
export const goBack = () => uni.navigateBack({ delta: 1 });
// 登录逻辑 // 登录逻辑
export const onLogin = async (e) => { export const onLogin = (e) => {
return new Promise(async (resolve) => { const token = uni.getStorageSync("token");
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" };
// 绑定手机号 // 绑定手机号
const params = { wechatPhoneCode: code, clientId: clientId }; bindPhone(params);
const res = await bindPhone(params);
if (res.data) {
resolve();
}
});
}); });
}; };
@ -29,13 +29,9 @@ export const onLogin = async (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) {
console.log("token不存在重新登录"); if (!token) return;
loginAuth().then(() => {
resolve(); resolve(token);
});
return;
}
resolve();
}); });
}; };

View File

@ -5,7 +5,6 @@ import {
} from "../request/api/LoginApi"; } from "../request/api/LoginApi";
import { getWeChatAuthCode } from "./AuthManager"; import { getWeChatAuthCode } from "./AuthManager";
import { useAppStore } from "@/store"; import { useAppStore } from "@/store";
import { clientId } from "@/constant/base";
const loginAuth = () => { const loginAuth = () => {
return new Promise(async (resolve, reject) => { return new Promise(async (resolve, reject) => {
@ -15,13 +14,15 @@ const loginAuth = () => {
openIdCode: [openIdCode], openIdCode: [openIdCode],
grant_type: "wechat", grant_type: "wechat",
scope: "server", scope: "server",
clientId: clientId, clientId: "2",
}); });
console.log("获取到的微信授权response:", response); console.log("获取到的微信授权response:", response);
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 {

View File

@ -55,10 +55,7 @@
}, },
/* */ /* */
"quickapp": {}, "quickapp": {},
/* project.config.json /* wx23f86d809ae80259 wx5e79df5996572539 */
wx5e79df5996572539
wx23f86d809ae80259
*/
"mp-weixin": { "mp-weixin": {
"appid": "wx5e79df5996572539", "appid": "wx5e79df5996572539",
"setting": { "setting": {

View File

@ -16,5 +16,4 @@ export const CompName = {
createWorkOrderCard: "createWorkOrderCard", createWorkOrderCard: "createWorkOrderCard",
feedbackCard: "feedbackCard", feedbackCard: "feedbackCard",
discoveryCard: "discoveryCard", discoveryCard: "discoveryCard",
addLicensePlate: "addLicensePlate",
}; };

View File

@ -1,5 +1,6 @@
{ {
"pages": [ "pages": [
//pageshttps://uniapp.dcloud.io/collocation/pages
{ {
"path": "pages/index/index", "path": "pages/index/index",
"style": { "style": {
@ -46,21 +47,13 @@
"style": { "style": {
"navigationStyle": "custom" "navigationStyle": "custom"
} }
},
{
"path": "pages/webview/index",
"style": {
"navigationStyle": "custom",
"navigationBarBackgroundColor": "#F8F8F8",
"navigationBarTitleColor": "#000000"
}
} }
], ],
"globalStyle": { "globalStyle": {
"navigationBarTextstyle": "black", // "navigationBarTextStyle": "black",
"navigationBarTitleText": "", // // "navigationBarTitleText": "小沐",
"navigationBarBackgroundcolor": "#F8F8F8", // "navigationBarBackgroundColor": "#F8F8F8",
"backgroundColor": "#F8F8F8" // "backgroundColor": "#F8F8F8"
}, },
"uniIdRouter": {} "uniIdRouter": {}
} }

View File

@ -84,9 +84,6 @@ watch(
border-radius: 4px 20px 20px 20px; border-radius: 4px 20px 20px 20px;
border: 1px solid; border: 1px solid;
border-color: #ffffff; border-color: #ffffff;
overflow: hidden; //
word-wrap: break-word; //
word-break: break-all; //
} }
} }

View File

@ -9,6 +9,8 @@
<!-- 输入框/语音按钮容器 --> <!-- 输入框/语音按钮容器 -->
<view class="input-button-container"> <view class="input-button-container">
<Interceptor />
<textarea <textarea
ref="textareaRef" ref="textareaRef"
v-if="!isVoiceMode" v-if="!isVoiceMode"
@ -61,7 +63,9 @@
<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();
@ -113,6 +117,7 @@ const toggleVoiceMode = () => {
// //
const handleVoiceTouchStart = () => { const handleVoiceTouchStart = () => {
checkToken().then(() => {
manager.start({ lang: "zh_CN" }); manager.start({ lang: "zh_CN" });
visibleWaveBtn.value = true; visibleWaveBtn.value = true;
@ -123,6 +128,7 @@ const handleVoiceTouchStart = () => {
recordingWaveBtnRef.value.startAnimation(); recordingWaveBtnRef.value.startAnimation();
} }
}); });
});
}; };
// //

View File

@ -42,6 +42,7 @@
class="message-item-ai" class="message-item-ai"
:key="`ai-${item.msgId}-${item.msg ? item.msg.length : 0}`" :key="`ai-${item.msgId}-${item.msg ? item.msg.length : 0}`"
:text="item.msg || ''" :text="item.msg || ''"
,
:isLoading="item.isLoading" :isLoading="item.isLoading"
> >
<template #content v-if="item.toolCall"> <template #content v-if="item.toolCall">
@ -70,12 +71,6 @@
v-else-if="item.toolCall.componentName === ''" v-else-if="item.toolCall.componentName === ''"
:toolCall="item.toolCall" :toolCall="item.toolCall"
/> />
<AddCarCrad
v-else-if="
item.toolCall.componentName === CompName.addLicensePlate
"
:toolCall="item.toolCall"
/>
</template> </template>
<template #footer> <template #footer>
@ -148,7 +143,7 @@ import {
RECOMMEND_POSTS_TITLE, RECOMMEND_POSTS_TITLE,
SEND_COMMAND_TEXT, SEND_COMMAND_TEXT,
} from "@/constant/constant"; } from "@/constant/constant";
import { WSS_URL } from "@/request/base/baseUrl"; import { WSS_URL } from "@/constant/base";
import { MessageRole, MessageType, CompName } from "../../model/ChatModel"; import { MessageRole, MessageType, CompName } from "../../model/ChatModel";
import ChatTopWelcome from "./ChatTopWelcome.vue"; import ChatTopWelcome from "./ChatTopWelcome.vue";
import ChatTopBgImg from "./ChatTopBgImg.vue"; import ChatTopBgImg from "./ChatTopBgImg.vue";
@ -167,7 +162,6 @@ import AttachListComponent from "../module/attach/AttachListComponent.vue";
import CreateServiceOrder from "@/components/CreateServiceOrder/index.vue"; import CreateServiceOrder from "@/components/CreateServiceOrder/index.vue";
import Feedback from "@/components/Feedback/index.vue"; import Feedback from "@/components/Feedback/index.vue";
import DetailCardCompontent from "../module/detail/DetailCardCompontent.vue"; import DetailCardCompontent from "../module/detail/DetailCardCompontent.vue";
import AddCarCrad from "@/components/AddCarCrad/index.vue";
import { mainPageData } from "@/request/api/MainPageDataApi"; import { mainPageData } from "@/request/api/MainPageDataApi";
import { import {
conversationMsgList, conversationMsgList,
@ -176,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 { goLogin } from "@/hooks/useGoLogin";
import { useAppStore } from "@/store"; import { useAppStore } from "@/store";
import { checkToken } from "@/hooks/useGoLogin";
const appStore = useAppStore(); const appStore = useAppStore();
/// ///
const statusBarHeight = ref(20); const statusBarHeight = ref(20);
@ -218,8 +212,6 @@ let commonType = "";
// WebSocket // WebSocket
let webSocketManager = null; let webSocketManager = null;
/// WebSocket
let webSocketConnectStatus = false;
// //
let typewriterManager = null; let typewriterManager = null;
// IDmessageId // IDmessageId
@ -293,11 +285,6 @@ const handleReply = (text) => {
// //
const handleReplyInstruct = (item) => { const handleReplyInstruct = (item) => {
if (!appStore.hasToken) {
console.log("没有token跳转到登录页");
goLogin();
return;
}
if (item.type === "MyOrder") { if (item.type === "MyOrder") {
// //
uni.navigateTo({ uni.navigateTo({
@ -369,9 +356,9 @@ onLoad(() => {
// token // token
const initHandler = () => { const initHandler = () => {
console.log("initHandler"); console.log("initHandler");
if (!appStore.hasToken) return;
loadRecentConversation(); loadRecentConversation();
///loadConversationMsgList(); loadConversationMsgList();
initWebSocket(); initWebSocket();
}; };
@ -381,7 +368,6 @@ watch(
() => appStore.hasToken, () => appStore.hasToken,
(newValue) => { (newValue) => {
if (newValue) { if (newValue) {
console.log("token存在初始化数据");
initHandler(); initHandler();
} }
} }
@ -394,7 +380,7 @@ onMounted(() => {
initTypewriterManager(); initTypewriterManager();
// tokensocket // tokensocket
initHandler(); checkToken().then(() => initHandler());
} catch (error) { } catch (error) {
console.error("页面初始化错误:", error); console.error("页面初始化错误:", error);
} }
@ -455,14 +441,12 @@ const initWebSocket = () => {
// //
onOpen: (event) => { onOpen: (event) => {
// //
webSocketConnectStatus = true;
isSessionActive.value = true; isSessionActive.value = true;
}, },
// //
onClose: (event) => { onClose: (event) => {
console.error("WebSocket连接断开:", event); console.error("WebSocket连接断开:", event);
webSocketConnectStatus = false;
// //
isSessionActive.value = false; isSessionActive.value = false;
// //
@ -473,7 +457,6 @@ const initWebSocket = () => {
// //
onError: (error) => { onError: (error) => {
webSocketConnectStatus = false;
isSessionActive.value = false; isSessionActive.value = false;
console.error("WebSocket错误:", error); console.error("WebSocket错误:", error);
}, },
@ -491,12 +474,7 @@ const initWebSocket = () => {
}); });
// //
webSocketManager webSocketManager.connect().catch((error) => {
.connect()
.then(() => {
webSocketConnectStatus = true;
})
.catch((error) => {
console.error("WebSocket连接失败:", error); console.error("WebSocket连接失败:", error);
}); });
}; };
@ -621,22 +599,6 @@ const initData = () => {
// //
const sendMessage = (message, isInstruct = false) => { const sendMessage = (message, isInstruct = false) => {
console.log("发送的消息:", message);
if (!appStore.hasToken) {
console.log("没有token跳转到登录页");
goLogin();
return;
}
if (!webSocketConnectStatus) {
uni.showToast({
title: "当前网络异常,请稍后重试",
icon: "none",
});
return;
}
if (isSessionActive.value) { if (isSessionActive.value) {
uni.showToast({ uni.showToast({
title: "请等待当前回复完成", title: "请等待当前回复完成",

View File

@ -7,6 +7,8 @@
: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>
@ -16,6 +18,9 @@
<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({
@ -34,7 +39,8 @@ defineProps({
}); });
const sendReply = (text) => { const sendReply = (text) => {
emits("replySent", text); //
checkToken().then(() => emits("replySent", text));
}; };
</script> </script>

View File

@ -7,6 +7,8 @@
: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"
@ -24,12 +26,15 @@
<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) => {
emits("replySent", item); // checkToken().then(() => emits("replySent", item)); //
}; };
onMounted(() => { onMounted(() => {

View File

@ -11,30 +11,18 @@
</template> </template>
<script setup> <script setup>
import { ref } from "vue"; import { defineEmits, 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>

View File

@ -11,41 +11,18 @@
<text class="title">我的</text> <text class="title">我的</text>
</view> </view>
<MineSetting v-if="isDrawerVisible" /> <MineSetting />
</view> </view>
</template> </template>
<script setup> <script setup>
import MineSetting from "./MineSetting.vue"; import MineSetting from "./MineSetting.vue";
import { defineEmits, ref, onMounted, onUnmounted } from "vue"; import { defineEmits } 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>

View File

@ -38,6 +38,7 @@
<script setup> <script setup>
import { ref, onMounted } from "vue"; import { ref, onMounted } from "vue";
import { getLoginUserPhone } from "@/request/api/LoginApi"; import { getLoginUserPhone } from "@/request/api/LoginApi";
import { checkToken } from "@/hooks/useGoLogin";
// //
const userInfo = ref({ const userInfo = ref({
@ -59,10 +60,12 @@ const menuList = ref([
{ label: "订阅消息", type: "action", action: "subscribeMessage" }, { label: "订阅消息", type: "action", action: "subscribeMessage" },
]); ]);
// //
onMounted(() => { onMounted(() => {
checkToken().then(() => {
getLoginUserPhoneInfo(); getLoginUserPhoneInfo();
}); });
});
const getLoginUserPhoneInfo = async () => { const getLoginUserPhoneInfo = async () => {
const res = await getLoginUserPhone(); const res = await getLoginUserPhone();

View File

@ -39,18 +39,8 @@
}}</view> }}</view>
<view class="goods-price"> <view class="goods-price">
<text class="currency">¥</text> <text class="currency">¥</text>
<template v-if="goodsData.commodityTypeCode === '0'">
<text class="price"> <text class="price">
{{ goodsData.calculatedTotalPrice || 0 }} {{ goodsData.specificationPrice || 399 }}
</text>
<text class="price-desc">
({{ goodsData.startDate }}{{ goodsData.endDate }}) {{
goodsData.totalDays
}}
</text>
</template>
<text v-else class="price">
{{ goodsData.specificationPrice || 0 }}
</text> </text>
</view> </view>
<view <view
@ -105,11 +95,7 @@
<!-- 总价区域 --> <!-- 总价区域 -->
<SumCard <SumCard
:referencePrice=" :referencePrice="goodsData.specificationPrice"
goodsData.commodityTypeCode === '0'
? goodsData.calculatedTotalPrice
: goodsData.specificationPrice
"
:discount="totalPrice" :discount="totalPrice"
/> />
</view> </view>
@ -194,10 +180,7 @@ const isDeleting = ref(false); // 标志位防止删除时watch冲突
// //
const totalPrice = computed(() => { const totalPrice = computed(() => {
const price = const price = props.goodsData?.specificationPrice || DEFAULT_PRICE;
props.goodsData?.commodityTypeCode === "0"
? props.goodsData?.calculatedTotalPrice
: props.goodsData?.specificationPrice || 0;
return (price * quantity.value).toFixed(0); return (price * quantity.value).toFixed(0);
}); });

View File

@ -92,13 +92,6 @@
font-weight: 600; font-weight: 600;
margin-left: 2px; margin-left: 2px;
} }
.price-desc {
font-size: 14px;
color: #999;
font-weight: 400;
margin-left: 12px;
}
} }
.goods-service-list { .goods-service-list {

View File

@ -38,7 +38,7 @@
<view class="footer"> <view class="footer">
<view class="left"> <view class="left">
<text class="label">价格</text> <text class="label">价格</text>
<text class="price">{{ calculatedTotalPrice }}</text> <text class="price">{{ goodsData.specificationPrice || 399 }}</text>
</view> </view>
<view class="buy-button" @click="showConfirmPopup">立即抢购</view> <view class="buy-button" @click="showConfirmPopup">立即抢购</view>
</view> </view>
@ -103,34 +103,20 @@ const selectedDate = ref({
}); });
const priceData = ref([]); const priceData = ref([]);
//
const calculatedTotalPrice = ref(0);
// //
const goodsInfo = async (params) => { const goodsInfo = async (params) => {
const res = await goodsDetail(params); const res = await goodsDetail(params);
goodsData.value = res.data; goodsData.value = res.data;
//
calculatedTotalPrice.value = goodsData.value.specificationPrice || 0;
// //
if (goodsData.value.commodityTypeCode === "0") { if (goodsData.value.commodityTypeCode === "0") {
configGoodsData();
getGoodsDailyPrice({ getGoodsDailyPrice({
commodityId: goodsData.value.commodityId, commodityId: goodsData.value.commodityId,
}); });
} }
}; };
const configGoodsData = () => {
goodsData.value.startDate = selectedDate.value.startDate;
goodsData.value.endDate = selectedDate.value.endDate;
goodsData.value.totalDays = selectedDate.value.totalDays;
goodsData.value.calculatedTotalPrice = calculatedTotalPrice.value;
};
// //
const getGoodsDailyPrice = async (params) => { const getGoodsDailyPrice = async (params) => {
const res = await commodityDailyPriceList(params); const res = await commodityDailyPriceList(params);
@ -286,63 +272,6 @@ const handleDateSelect = (data) => {
totalDays: data.totalDays, totalDays: data.totalDays,
}; };
//
if (goodsData.value.commodityTypeCode === "0") {
// dateRange
if (data.dateRange && Array.isArray(data.dateRange)) {
// 退
const defaultPrice = Number(goodsData.value.specificationPrice) || 0;
//
const isValidPrice = (price) => {
return (
price !== null &&
price !== undefined &&
price !== "" &&
price !== "-" &&
!isNaN(Number(price)) &&
Number(price) > 0
);
};
// 1使
if (data.dateRange.length === 1) {
const dayPrice = data.dateRange[0].price;
calculatedTotalPrice.value = isValidPrice(dayPrice)
? Number(dayPrice)
: defaultPrice;
console.log(
"同一天选择,价格:",
calculatedTotalPrice.value,
"(原价格:",
dayPrice,
")"
);
} else {
//
const dateRangeExcludingLast = data.dateRange.slice(0, -1);
calculatedTotalPrice.value = dateRangeExcludingLast.reduce(
(total, dateItem) => {
const dayPrice = dateItem.price;
const priceToAdd = isValidPrice(dayPrice)
? Number(dayPrice)
: defaultPrice;
return total + priceToAdd;
},
0
);
console.log(
"酒店类型计算总价格(排除最后一天):",
calculatedTotalPrice.value
);
}
configGoodsData();
}
} else {
// dateRange使
calculatedTotalPrice.value = goodsData.value.specificationPrice || 0;
}
// //
calendarVisible.value = false; calendarVisible.value = false;
}; };

View File

@ -18,7 +18,7 @@ import { ref, onMounted, onUnmounted } from "vue";
import ChatMainList from "../chat/ChatMainList.vue"; import ChatMainList from "../chat/ChatMainList.vue";
import Calender from "@/components/Calender/index.vue"; import Calender from "@/components/Calender/index.vue";
import { onLoad } from "@dcloudio/uni-app"; import { onLoad } from "@dcloudio/uni-app";
import { getUrlParams } from "@/utils/UrlParams"; import { GetWxMiniProgramUrlParam } from "@/utils/UrlParams";
import { useAppStore } from "@/store"; import { useAppStore } from "@/store";
@ -48,7 +48,7 @@ const getWeixinMiniProgramParams = (e) => {
console.log("Params:", e); console.log("Params:", e);
if (e.q && e.q != "undefined") { if (e.q && e.q != "undefined") {
const qrUrl = decodeURIComponent(e.q); // const qrUrl = decodeURIComponent(e.q); //
const params = getUrlParams(qrUrl); const params = GetWxMiniProgramUrlParam(qrUrl);
appStore.setSceneId(params.sceneId); appStore.setSceneId(params.sceneId);
} }
}; };

View File

@ -1,12 +1,5 @@
<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">
<!-- 卡通形象 --> <!-- 卡通形象 -->
@ -38,7 +31,7 @@
class="login-btn" class="login-btn"
open-type="getPhoneNumber" open-type="getPhoneNumber"
type="primary" type="primary"
@getphonenumber="getPhoneNumber" @getphonenumber="onLogin"
> >
微信一键登录 微信一键登录
</button> </button>
@ -73,15 +66,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 { onLogin, goBack } from "@/hooks/useGoLogin"; import { goHome } from "@/hooks/useGoHome";
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);
@ -101,20 +94,30 @@ const handleAgreeAndGetPhone = () => {
} }
}; };
const getPhoneNumber = (e) => { const onLogin = (e) => {
onLogin(e) const { code } = e.detail;
.then(() => { console.info("onLogin code: ", code);
uni.showToast({
title: "登录成功", loginAuth()
icon: "success", .then(async () => {
//
const res = await checkPhone();
if (res.data) {
return goHome();
}
const { data } = await bindPhone({
wechatPhoneCode: code,
clientId: "2",
}); });
goBack();
if (data) {
goHome();
}
}) })
.catch(() => { .catch((err) => {
uni.showToast({ console.error("登录失败", err);
title: "登录失败",
icon: "none",
});
}); });
}; };
@ -152,8 +155,4 @@ 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>

View File

@ -11,18 +11,6 @@
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;

View File

@ -6,7 +6,7 @@
v-for="(item, index) in commodityDTO.commodityList" v-for="(item, index) in commodityDTO.commodityList"
:key="`${item.commodityId}-${index}`" :key="`${item.commodityId}-${index}`"
> >
<view class="mk-card-item" @click="placeOrderHandle(item)"> <Interceptor class="mk-card-item" @click="placeOrderHandle(item)">
<!-- <view class="card-badge">超值推荐</view> --> <!-- <view class="card-badge">超值推荐</view> -->
<image class="card-img" :src="item.commodityIcon" mode="aspectFill" /> <image class="card-img" :src="item.commodityIcon" mode="aspectFill" />
<view class="card-content"> <view class="card-content">
@ -38,7 +38,7 @@
<text class="card-btn">下单</text> <text class="card-btn">下单</text>
</view> </view>
</view> </view>
</view> </Interceptor>
</view> </view>
</view> </view>
</view> </view>
@ -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 Interceptor from "@/components/Interceptor/index.vue";
const props = defineProps({ const props = defineProps({
commodityDTO: { commodityDTO: {

View File

@ -7,6 +7,7 @@
: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"
@ -50,6 +51,7 @@
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: {

View File

@ -7,6 +7,8 @@
: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"
@ -22,6 +24,8 @@
<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({
@ -32,8 +36,10 @@ 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>

View File

@ -7,6 +7,7 @@
: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">
@ -21,6 +22,8 @@
<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({
@ -31,8 +34,10 @@ 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>

View File

@ -7,11 +7,7 @@
<view class="order-title"> <view class="order-title">
{{ orderData.workOrderTypeName || orderData.commodityName }} {{ orderData.workOrderTypeName || orderData.commodityName }}
</view> </view>
<image <image class="arrow-icon" src="./images/arrow.png"></image>
v-if="props.orderData.orderType !== undefined"
class="arrow-icon"
src="./images/arrow.png"
></image>
</view> </view>
<view <view
v-if="orderData.status !== 'pending'" v-if="orderData.status !== 'pending'"
@ -111,7 +107,6 @@ const getStatusText = (status) => {
// //
const handleCardClick = () => { const handleCardClick = () => {
if (props.orderData.orderType === undefined) return;
emit("click", props.orderData); emit("click", props.orderData);
}; };
</script> </script>

View File

@ -1,56 +0,0 @@
<template>
<view class="webview">
<!-- 使用 NavBar 组件 -->
<TopNavBar title="网页浏览" @back="goBack" />
<!-- WebView 内容区域 -->
<view class="webview-content">
<web-view :src="webviewUrl"></web-view>
</view>
</view>
</template>
<script setup>
import { ref, onMounted } from "vue";
import TopNavBar from "@/components/TopNavBar/index.vue";
const webviewUrl = ref("");
//
const goBack = () => {
uni.navigateBack();
};
onMounted(() => {
//
const pages = getCurrentPages();
const currentPage = pages[pages.length - 1];
const options = currentPage.options;
// url
if (options.url) {
// URL
webviewUrl.value = decodeURIComponent(options.url);
}
});
</script>
<style lang="scss" scoped>
.webview {
width: 100%;
height: 100vh;
display: flex;
flex-direction: column;
background-color: #fff;
}
.webview-content {
flex: 1;
margin-top: calc(44px + var(--status-bar-height));
}
.webview-content {
width: 100%;
height: 100%;
}
</style>

View File

@ -1,8 +1,8 @@
import { BASE_URL } from "@/request/base/baseUrl"; import { BASE_URL } from "../../constant/base";
import { goLogin } from "@/hooks/useGoLogin"; import { goLogin } from "@/hooks/useGoLogin";
/// 请求流式数据的API /// 请求流式数据的API
const API = "/agent/assistant/chat"; const API = '/agent/assistant/chat';
/** /**
* 获取AI聊天流式信息仅微信小程序支持 * 获取AI聊天流式信息仅微信小程序支持
@ -31,7 +31,7 @@ const stopAbortTask = () => {
activeRequestId = null; activeRequestId = null;
if (currentPromiseReject) { if (currentPromiseReject) {
currentPromiseReject(new Error("请求已被用户终止")); currentPromiseReject(new Error('请求已被用户终止'));
currentPromiseReject = null; currentPromiseReject = null;
} }
@ -40,15 +40,15 @@ const stopAbortTask = () => {
const cleanupListeners = () => { const cleanupListeners = () => {
try { try {
if(requestTask.offChunkReceived) { if(requestTask.offChunkReceived) {
console.log("======>offChunkReceived"); console.log("======>offChunkReceived")
requestTask.offChunkReceived(); requestTask.offChunkReceived();
} }
if(requestTask.offHeadersReceived) { if(requestTask.offHeadersReceived) {
console.log("======>offHeadersReceived"); console.log("======>offHeadersReceived")
requestTask.offHeadersReceived(); requestTask.offHeadersReceived();
} }
} catch (e) { } catch (e) {
console.error("清理事件监听器失败:", e); console.error('清理事件监听器失败:', e);
} }
}; };
@ -57,22 +57,22 @@ const stopAbortTask = () => {
// 终止请求 // 终止请求
try { try {
if (requestTask.abort) { if (requestTask.abort) {
console.log("======>abort"); console.log("======>abort")
requestTask.abort(); requestTask.abort();
} }
} catch (e) { } catch (e) {
console.log("🛑 终止网络请求失败:", e); console.log('🛑 终止网络请求失败:', e);
} }
requestTask = null; requestTask = null;
} }
console.log("🛑 请求强制终止完成"); console.log('🛑 请求强制终止完成');
}; }
const agentChatStream = (params, onChunk) => { const agentChatStream = (params, onChunk) => {
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
const token = uni.getStorageSync("token"); const token = uni.getStorageSync('token');
const requestId = Date.now().toString(); // 生成唯一请求ID const requestId = Date.now().toString(); // 生成唯一请求ID
// 重置状态 // 重置状态
@ -87,23 +87,21 @@ const agentChatStream = (params, onChunk) => {
// 检查数据块是否来自已终止的请求 // 检查数据块是否来自已终止的请求
const isStaleData = (dataRequestId) => { const isStaleData = (dataRequestId) => {
return ( return dataRequestId === lastRequestId || dataRequestId !== activeRequestId;
dataRequestId === lastRequestId || dataRequestId !== activeRequestId
);
}; };
// #ifdef MP-WEIXIN // #ifdef MP-WEIXIN
requestTask = uni.request({ requestTask = uni.request({
url: BASE_URL + API, // 替换为你的接口地址 url: BASE_URL + API, // 替换为你的接口地址
method: "POST", method: 'POST',
data: params, data: params,
enableChunked: true, enableChunked: true,
header: { header: {
Accept: "text/event-stream", Accept: 'text/event-stream',
"Content-Type": "application/json", 'Content-Type': 'application/json',
Authorization: `Bearer ${token}`, // 如需token可加 Authorization: `Bearer ${token}`, // 如需token可加
}, },
responseType: "arraybuffer", responseType: 'arraybuffer',
success(res) { success(res) {
if (!isAborted && !isStaleData(requestId)) { if (!isAborted && !isStaleData(requestId)) {
console.log(`✅ 请求 [${requestId}] 成功`); console.log(`✅ 请求 [${requestId}] 成功`);
@ -124,39 +122,30 @@ const agentChatStream = (params, onChunk) => {
// 使用 requestId 来验证请求有效性 // 使用 requestId 来验证请求有效性
if (!isAborted && activeRequestId === requestId) { if (!isAborted && activeRequestId === requestId) {
if (res.statusCode !== 200) { if (res.statusCode !== 200) {
console.log( console.log(`❌ 请求 [${requestId}] 完成但状态错误,状态:`, res.statusCode);
`❌ 请求 [${requestId}] 完成但状态错误,状态:`,
res.statusCode
);
if(res.statusCode === 424) { if(res.statusCode === 424) {
uni.setStorageSync("token", ""); uni.setStorageSync('token', '');
goLogin(); goLogin();
} }
if (onChunk) { if (onChunk) {
onChunk({ onChunk({
error: true, error: true,
message: "服务器错误", message: '服务器错误',
detail: res, detail: res
}); });
} }
reject(res); reject(res);
} }
} else { } else {
console.log( console.log(`❌ 请求 [${requestId}] ${isAborted ? '已终止' : '已过期'}忽略complete回调`);
`❌ 请求 [${requestId}] ${ }
isAborted ? "已终止" : "已过期"
}忽略complete回调`
);
} }
},
}); });
requestTask.onHeadersReceived((res) => { requestTask.onHeadersReceived(res => {
// 使用 requestId 验证请求有效性 // 使用 requestId 验证请求有效性
if (isAborted || activeRequestId !== requestId) { if (isAborted || activeRequestId !== requestId) {
console.log( console.log(`🚫 Headers [${requestId}] ${isAborted ? '已终止' : '已过期'},忽略`);
`🚫 Headers [${requestId}] ${isAborted ? "已终止" : "已过期"},忽略`
);
return; return;
} }
@ -169,7 +158,7 @@ const agentChatStream = (params, onChunk) => {
onChunk({ onChunk({
error: true, error: true,
message: `服务器错误(${status})`, message: `服务器错误(${status})`,
detail: res, detail: res
}); });
} }
// 终止异常请求 // 终止异常请求
@ -179,7 +168,7 @@ const agentChatStream = (params, onChunk) => {
} }
}); });
requestTask.onChunkReceived((res) => { requestTask.onChunkReceived(res => {
// 立即验证请求有效性 // 立即验证请求有效性
if (isAborted || isStaleData(requestId)) { if (isAborted || isStaleData(requestId)) {
console.log(`🚫 数据块 [${requestId}] 已终止或过期,忽略`); console.log(`🚫 数据块 [${requestId}] 已终止或过期,忽略`);
@ -187,15 +176,15 @@ const agentChatStream = (params, onChunk) => {
} }
const base64 = uni.arrayBufferToBase64(res.data); const base64 = uni.arrayBufferToBase64(res.data);
let data = ""; let data = '';
try { try {
data = decodeURIComponent(escape(weAtob(base64))); data = decodeURIComponent(escape(weAtob(base64)));
} catch (e) { } catch (e) {
console.error("Base64解码失败:", e); console.error('Base64解码失败:', e);
return; return;
} }
console.log("📦 onChunkReceivedres:", data); console.log("📦 onChunkReceivedres:", data)
// 再次验证请求有效性 // 再次验证请求有效性
if (isAborted || activeRequestId !== requestId) { if (isAborted || activeRequestId !== requestId) {
@ -204,7 +193,7 @@ const agentChatStream = (params, onChunk) => {
} }
const messages = parseSSEChunk(data); const messages = parseSSEChunk(data);
messages.forEach((msg) => { messages.forEach(msg => {
if (!isAborted && !isStaleData(requestId) && onChunk) { if (!isAborted && !isStaleData(requestId) && onChunk) {
onChunk(msg); onChunk(msg);
} }
@ -212,16 +201,14 @@ const agentChatStream = (params, onChunk) => {
}); });
// #endif // #endif
}); });
}; }
// window.atob兼容性处理 // window.atob兼容性处理
const weAtob = (string) => { const weAtob = (string) => {
const b64re = const b64re = /^(?:[A-Za-z\d+/]{4})*?(?:[A-Za-z\d+/]{2}(?:==)?|[A-Za-z\d+/]{3}=?)?$/;
/^(?:[A-Za-z\d+/]{4})*?(?:[A-Za-z\d+/]{2}(?:==)?|[A-Za-z\d+/]{3}=?)?$/; const b64 = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=';
const b64 =
"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";
// 去除空白字符 // 去除空白字符
string = String(string).replace(/[\t\n\f\r ]+/g, ""); string = String(string).replace(/[\t\n\f\r ]+/g, '');
// 验证 Base64 编码 // 验证 Base64 编码
if (!b64re.test(string)) { if (!b64re.test(string)) {
throw new TypeError( throw new TypeError(
@ -231,10 +218,10 @@ const weAtob = (string) => {
} }
// 填充字符 // 填充字符
string += "==".slice(2 - (string.length & 3)); string += '=='.slice(2 - (string.length & 3));
let bitmap, let bitmap,
result = "", result = '',
r1, r1,
r2, r2,
i = 0; i = 0;
@ -249,7 +236,10 @@ const weAtob = (string) => {
if (r1 === 64) { if (r1 === 64) {
result += String.fromCharCode((bitmap >> 16) & 255); result += String.fromCharCode((bitmap >> 16) & 255);
} else if (r2 === 64) { } else if (r2 === 64) {
result += String.fromCharCode((bitmap >> 16) & 255, (bitmap >> 8) & 255); result += String.fromCharCode(
(bitmap >> 16) & 255,
(bitmap >> 8) & 255
);
} else { } else {
result += String.fromCharCode( result += String.fromCharCode(
(bitmap >> 16) & 255, (bitmap >> 16) & 255,
@ -261,6 +251,7 @@ const weAtob = (string) => {
return result; return result;
}; };
// 解析SSE分段数据 // 解析SSE分段数据
const parseSSEChunk = (raw) => { const parseSSEChunk = (raw) => {
const results = []; const results = [];
@ -273,7 +264,7 @@ const parseSSEChunk = (raw) => {
let dataLines = []; let dataLines = [];
for (const line of lines) { for (const line of lines) {
if (line.startsWith("data:")) { if (line.startsWith('data:')) {
// 提取data:后面的内容并去除首尾空格 // 提取data:后面的内容并去除首尾空格
dataLines.push(line.slice(5).trim()); dataLines.push(line.slice(5).trim());
} }
@ -281,18 +272,18 @@ const parseSSEChunk = (raw) => {
if (dataLines.length > 0) { if (dataLines.length > 0) {
// 拼接多行数据 // 拼接多行数据
const fullData = dataLines.join("\n"); const fullData = dataLines.join('\n');
try { try {
const obj = JSON.parse(fullData); const obj = JSON.parse(fullData);
results.push(obj); results.push(obj);
} catch (e) { } catch (e) {
console.warn("⚠️ SSE数据解析失败:", e, "原始数据:", fullData); console.warn('⚠️ SSE数据解析失败:', e, '原始数据:', fullData);
// 解析失败忽略 // 解析失败忽略
} }
} }
} }
return results; return results;
}; }
export { agentChatStream, stopAbortTask }; export { agentChatStream, stopAbortTask }

View File

@ -1,19 +0,0 @@
const isProd = false;
// 测试
const VITE_BASE_URL_TEST = "https://onefeel.brother7.cn/ingress";
const VITE_WSS_URL_TEST = "wss://onefeel.brother7.cn/ingress/agent/ws/chat";
// 生产
const VITE_BASE_URL_PRO = "https://biz.nianxx.cn";
const VITE_WSS_URL_PRO = "wss://biz.nianxx.cn/agent/ws/chat";
// 环境配置
export const BASE_URL = isProd ? VITE_BASE_URL_PRO : VITE_BASE_URL_TEST;
export const WSS_URL = isProd ? VITE_WSS_URL_PRO : VITE_WSS_URL_TEST;
// =====================================
// 环境配置文件使用方法
// console.log("当前环境:", import.meta.env);
// export const BASE_URL = import.meta.env.VITE_BASE_URL;
// export const WSS_URL = import.meta.env.VITE_WSS_URL;

View File

@ -1,6 +1,5 @@
import { goLogin } from "../../hooks/useGoLogin"; import { BASE_URL } from "../../constant/base";
import { BASE_URL } from "./baseUrl"; import { goLogin } from "@/hooks/useGoLogin";
import { loginAuth, checkPhone } from "@/manager/LoginManager";
const defaultConfig = { const defaultConfig = {
header: { header: {
@ -51,16 +50,10 @@ 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) {
console.log("424错误重新登录"); // uni.setStorageSync("token", "");
loginAuth().then(async () => { // goLogin();
// 检测是否绑定手机号 // }
const res = await checkPhone();
if (!res.data) {
goLogin();
}
});
}
}, },
fail: (err) => { fail: (err) => {
console.error("请求失败:", err); console.error("请求失败:", err);

View File

@ -1,20 +0,0 @@
import { objectToUrlParams } from "../utils/UrlParams.js";
export function navigateTo(url, args) {
let targetUrl = url;
if (args && typeof args === "object") {
// 如果有额外参数拼接到URL后面
const paramString = objectToUrlParams(args);
if (paramString) {
if (targetUrl.contains("?")) {
targetUrl += "&";
} else {
targetUrl += "?";
}
targetUrl += paramString;
}
}
uni.navigateTo({
url: "/pages/webview/index?url=" + encodeURIComponent(targetUrl),
});
}

View File

@ -1,4 +1,4 @@
export function getUrlParams(url) { export function GetWxMiniProgramUrlParam(url) {
let theRequest = {}; let theRequest = {};
if(url.indexOf("#") != -1){ if(url.indexOf("#") != -1){
const str=url.split("#")[1]; const str=url.split("#")[1];
@ -15,23 +15,3 @@ export function getUrlParams(url) {
} }
return theRequest; return theRequest;
} }
/**
* 将对象参数转换为URL查询字符串格式
* @param {Object} args - 参数对象
* @returns {String} 返回key=value&格式的查询字符串
*/
export function objectToUrlParams(args) {
if (!args || typeof args !== 'object') {
return '';
}
const params = [];
for (const key in args) {
if (args.hasOwnProperty(key) && args[key] !== undefined && args[key] !== null) {
params.push(`${key}=${args[key]}`);
}
}
return params.length > 0 ? params.join('&') : '';
}

View File

@ -13,12 +13,7 @@ export class IdUtils {
* @returns {string} 消息ID * @returns {string} 消息ID
*/ */
static generateMessageId() { static generateMessageId() {
const timestamp = new Date().getTime(); return "mid" + new Date().getTime();
const chars = "abcdefghijklmnopqrstuvwxyz";
const randomStr = Array.from({ length: 4 }, () =>
chars.charAt(Math.floor(Math.random() * chars.length))
).join("");
return "mid"+ randomStr + timestamp;
} }
} }