Compare commits
13 Commits
843d8d3138
...
f585c83554
| Author | SHA1 | Date | |
|---|---|---|---|
| f585c83554 | |||
| fd5902ca05 | |||
| 8af82e54ef | |||
| cead891e69 | |||
| 69fe1b80c8 | |||
| 6443b67d15 | |||
|
|
8d0c93206b | ||
|
|
191d2394c5 | ||
|
|
5849411e89 | ||
|
|
3e34f68406 | ||
| fc63bbc994 | |||
| 66c256cefd | |||
| 1038dd3180 |
@ -3,11 +3,5 @@ NODE_ENV = development
|
||||
# 测试
|
||||
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://biz.nianxx.cn/agent/ws/chat
|
||||
|
||||
@ -1,13 +1,7 @@
|
||||
NODE_ENV = production
|
||||
|
||||
# 测试
|
||||
VITE_BASE_URL = https://onefeel.brother7.cn/ingress
|
||||
# 生产
|
||||
VITE_BASE_URL = https://biz.nianxx.cn
|
||||
|
||||
# 生产
|
||||
# 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
|
||||
VITE_WSS_URL = wss://biz.nianxx.cn/agent/ws/chat
|
||||
12
.env.staging
12
.env.staging
@ -1,13 +1,7 @@
|
||||
NODE_ENV = staging
|
||||
|
||||
# 测试
|
||||
VITE_BASE_URL = https://onefeel.brother7.cn/ingress
|
||||
# 生产
|
||||
VITE_BASE_URL = https://biz.nianxx.cn
|
||||
|
||||
# 生产
|
||||
# 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
|
||||
VITE_WSS_URL = wss://biz.nianxx.cn/agent/ws/chat
|
||||
BIN
components/AddCarCrad/images/add_car_crad.png
Normal file
BIN
components/AddCarCrad/images/add_car_crad.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 48 KiB |
43
components/AddCarCrad/index.vue
Normal file
43
components/AddCarCrad/index.vue
Normal file
@ -0,0 +1,43 @@
|
||||
<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>
|
||||
51
components/AddCarCrad/styles/index.scss
Normal file
51
components/AddCarCrad/styles/index.scss
Normal file
@ -0,0 +1,51 @@
|
||||
.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;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -93,9 +93,7 @@ const props = defineProps({
|
||||
// 价格数据数组
|
||||
priceData: {
|
||||
type: Array,
|
||||
default: () => [
|
||||
{date: '', price: '-', stock: '0'}
|
||||
],
|
||||
default: () => [{ date: "", price: "-", stock: "0" }],
|
||||
},
|
||||
|
||||
// 默认选中日期
|
||||
@ -209,8 +207,8 @@ const getPriceForDate = (dateStr) => {
|
||||
if (!props.priceData || !Array.isArray(props.priceData)) {
|
||||
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;
|
||||
};
|
||||
|
||||
@ -387,22 +385,58 @@ const handleRangeSelection = (dateInfo) => {
|
||||
return;
|
||||
}
|
||||
|
||||
// 生成范围内所有日期的数组
|
||||
const dateRange = generateDateRange(rangeStart.value, rangeEnd.value);
|
||||
|
||||
emit("range-select", {
|
||||
startDate: rangeStart.value,
|
||||
endDate: rangeEnd.value,
|
||||
startPrice: getPriceForDate(rangeStart.value),
|
||||
endPrice: getPriceForDate(rangeEnd.value),
|
||||
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 start = new Date(startDate);
|
||||
const end = new Date(endDate);
|
||||
const diffTime = Math.abs(end - start);
|
||||
return Math.ceil(diffTime / (1000 * 60 * 60 * 24));
|
||||
const days = Math.ceil(diffTime / (1000 * 60 * 60 * 24));
|
||||
// 如果是同一天,返回1天而不是0天
|
||||
return days === 0 ? 1 : days;
|
||||
};
|
||||
|
||||
// 监听visible属性变化,控制uni-popup显示
|
||||
@ -441,4 +475,4 @@ onBeforeUnmount(() => {
|
||||
<style lang="scss" scoped>
|
||||
// 引入样式文件
|
||||
@import "./styles/index.scss";
|
||||
</style>
|
||||
</style>
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
// 颜色系统
|
||||
$primary-color: #1890ff;
|
||||
$primary-light: #e6f7ff;
|
||||
$primary-dark: #0050b3;
|
||||
$primary-dark: #1890ff;
|
||||
|
||||
// 中性色
|
||||
$text-primary: #262626;
|
||||
|
||||
@ -1,8 +1,28 @@
|
||||
const isProd = true;
|
||||
// 小程序特有相关: 同时更改manifest.json和 project.config.json文件中的appid;
|
||||
// 所有用户端的配置
|
||||
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 BASE_URL = import.meta.env.VITE_BASE_URL;
|
||||
export const clientId = getCurrentConfig().clientId;
|
||||
export const appId = getCurrentConfig().appId;
|
||||
|
||||
// socket地址
|
||||
export const WSS_URL = import.meta.env.VITE_WSS_URL;
|
||||
|
||||
@ -1,27 +1,27 @@
|
||||
import { loginAuth, checkPhone, bindPhone } from "@/manager/LoginManager";
|
||||
|
||||
import { loginAuth, bindPhone } from "@/manager/LoginManager";
|
||||
// 引入base.js中的clientId
|
||||
import { clientId } from "@/constant/base";
|
||||
|
||||
// 跳转登录
|
||||
export const goLogin = () => uni.reLaunch({ url: "/pages/login/index" });
|
||||
export const goLogin = () => uni.navigateTo({ url: "/pages/login/index" });
|
||||
|
||||
// 登录成功后,返回上一页
|
||||
export const goBack = () => uni.navigateBack({ delta: 1 });
|
||||
|
||||
// 登录逻辑
|
||||
export const onLogin = (e) => {
|
||||
const token = uni.getStorageSync("token");
|
||||
|
||||
if (token) return;
|
||||
|
||||
const { code } = e.detail;
|
||||
console.info("onLogin code: ", code);
|
||||
|
||||
loginAuth().then(async () => {
|
||||
// 检测是否绑定手机号
|
||||
const res = await checkPhone();
|
||||
|
||||
if (res.data) return;
|
||||
|
||||
const params = { wechatPhoneCode: code, clientId: "2" };
|
||||
|
||||
// 绑定手机号
|
||||
bindPhone(params);
|
||||
export const onLogin = async (e) => {
|
||||
return new Promise(async (resolve) => {
|
||||
await loginAuth().then(async () => {
|
||||
const { code } = e.detail;
|
||||
console.info("onLogin code: ", code);
|
||||
|
||||
// 绑定手机号
|
||||
const params = { wechatPhoneCode: code, clientId: clientId };
|
||||
const res = await bindPhone(params);
|
||||
if (res.data) {
|
||||
resolve();
|
||||
}
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
@ -29,9 +29,13 @@ export const onLogin = (e) => {
|
||||
export const checkToken = async () => {
|
||||
return new Promise((resolve) => {
|
||||
const token = uni.getStorageSync("token");
|
||||
|
||||
if (!token) return;
|
||||
|
||||
resolve(token);
|
||||
if (!token) {
|
||||
console.log("token不存在,重新登录");
|
||||
loginAuth().then(() => {
|
||||
resolve();
|
||||
});
|
||||
return;
|
||||
}
|
||||
resolve();
|
||||
});
|
||||
};
|
||||
|
||||
@ -5,6 +5,7 @@ import {
|
||||
} from "../request/api/LoginApi";
|
||||
import { getWeChatAuthCode } from "./AuthManager";
|
||||
import { useAppStore } from "@/store";
|
||||
import { clientId } from "@/constant/base";
|
||||
|
||||
const loginAuth = () => {
|
||||
return new Promise(async (resolve, reject) => {
|
||||
@ -14,15 +15,13 @@ const loginAuth = () => {
|
||||
openIdCode: [openIdCode],
|
||||
grant_type: "wechat",
|
||||
scope: "server",
|
||||
clientId: "2",
|
||||
clientId: clientId,
|
||||
});
|
||||
console.log("获取到的微信授权response:", response);
|
||||
|
||||
if (response.access_token) {
|
||||
uni.setStorageSync("token", response.access_token);
|
||||
|
||||
const appStore = useAppStore();
|
||||
|
||||
appStore.setHasToken(true);
|
||||
resolve();
|
||||
} else {
|
||||
|
||||
@ -55,7 +55,10 @@
|
||||
},
|
||||
/* 快应用特有相关 */
|
||||
"quickapp": {},
|
||||
/* 小程序特有相关 朵花用:wx23f86d809ae80259 测试用:wx5e79df5996572539 */
|
||||
/* 小程序特有相关 同时更改 project.config.json文件
|
||||
智念:wx5e79df5996572539
|
||||
朵花:wx23f86d809ae80259
|
||||
*/
|
||||
"mp-weixin": {
|
||||
"appid": "wx5e79df5996572539",
|
||||
"setting": {
|
||||
|
||||
@ -16,4 +16,5 @@ export const CompName = {
|
||||
createWorkOrderCard: "createWorkOrderCard",
|
||||
feedbackCard: "feedbackCard",
|
||||
discoveryCard: "discoveryCard",
|
||||
addLicensePlate: "addLicensePlate",
|
||||
};
|
||||
17
pages.json
17
pages.json
@ -1,6 +1,5 @@
|
||||
{
|
||||
"pages": [
|
||||
//pages数组中第一项表示应用启动页,参考:https://uniapp.dcloud.io/collocation/pages
|
||||
{
|
||||
"path": "pages/index/index",
|
||||
"style": {
|
||||
@ -47,13 +46,21 @@
|
||||
"style": {
|
||||
"navigationStyle": "custom"
|
||||
}
|
||||
},
|
||||
{
|
||||
"path": "pages/webview/index",
|
||||
"style": {
|
||||
"navigationStyle": "custom",
|
||||
"navigationBarBackgroundColor": "#F8F8F8",
|
||||
"navigationBarTitleColor": "#000000"
|
||||
}
|
||||
}
|
||||
],
|
||||
"globalStyle": {
|
||||
// "navigationBarTextStyle": "black",
|
||||
// // "navigationBarTitleText": "小沐",
|
||||
// "navigationBarBackgroundColor": "#F8F8F8",
|
||||
// "backgroundColor": "#F8F8F8"
|
||||
"navigationBarTextstyle": "black",
|
||||
"navigationBarTitleText": "",
|
||||
"navigationBarBackgroundcolor": "#F8F8F8",
|
||||
"backgroundColor": "#F8F8F8"
|
||||
},
|
||||
"uniIdRouter": {}
|
||||
}
|
||||
|
||||
@ -84,6 +84,9 @@ watch(
|
||||
border-radius: 4px 20px 20px 20px;
|
||||
border: 1px solid;
|
||||
border-color: #ffffff;
|
||||
overflow: hidden; // ✅ 超出内容被切掉
|
||||
word-wrap: break-word; // ✅ 长单词自动换行
|
||||
word-break: break-all; // ✅ 强制换行
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -9,8 +9,6 @@
|
||||
|
||||
<!-- 输入框/语音按钮容器 -->
|
||||
<view class="input-button-container">
|
||||
<Interceptor />
|
||||
|
||||
<textarea
|
||||
ref="textareaRef"
|
||||
v-if="!isVoiceMode"
|
||||
@ -63,9 +61,7 @@
|
||||
|
||||
<script setup>
|
||||
import { ref, watch, nextTick, onMounted, defineExpose } from "vue";
|
||||
import { checkToken } from "@/hooks/useGoLogin";
|
||||
import RecordingWaveBtn from "@/components/Speech/RecordingWaveBtn.vue";
|
||||
import Interceptor from "@/components/Interceptor/index.vue";
|
||||
|
||||
const plugin = requirePlugin("WechatSI");
|
||||
const manager = plugin.getRecordRecognitionManager();
|
||||
@ -117,8 +113,7 @@ const toggleVoiceMode = () => {
|
||||
|
||||
// 处理语音按钮长按开始
|
||||
const handleVoiceTouchStart = () => {
|
||||
checkToken().then(() => {
|
||||
manager.start({ lang: "zh_CN" });
|
||||
manager.start({ lang: "zh_CN" });
|
||||
|
||||
visibleWaveBtn.value = true;
|
||||
|
||||
@ -128,7 +123,6 @@ const handleVoiceTouchStart = () => {
|
||||
recordingWaveBtnRef.value.startAnimation();
|
||||
}
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
// 处理语音按钮长按结束
|
||||
|
||||
@ -42,7 +42,6 @@
|
||||
class="message-item-ai"
|
||||
:key="`ai-${item.msgId}-${item.msg ? item.msg.length : 0}`"
|
||||
:text="item.msg || ''"
|
||||
,
|
||||
:isLoading="item.isLoading"
|
||||
>
|
||||
<template #content v-if="item.toolCall">
|
||||
@ -71,6 +70,12 @@
|
||||
v-else-if="item.toolCall.componentName === ''"
|
||||
:toolCall="item.toolCall"
|
||||
/>
|
||||
<AddCarCrad
|
||||
v-else-if="
|
||||
item.toolCall.componentName === CompName.addLicensePlate
|
||||
"
|
||||
:toolCall="item.toolCall"
|
||||
/>
|
||||
</template>
|
||||
|
||||
<template #footer>
|
||||
@ -143,7 +148,7 @@ import {
|
||||
RECOMMEND_POSTS_TITLE,
|
||||
SEND_COMMAND_TEXT,
|
||||
} from "@/constant/constant";
|
||||
import { WSS_URL } from "@/constant/base";
|
||||
import { WSS_URL } from "@/request/base/baseUrl";
|
||||
import { MessageRole, MessageType, CompName } from "../../model/ChatModel";
|
||||
import ChatTopWelcome from "./ChatTopWelcome.vue";
|
||||
import ChatTopBgImg from "./ChatTopBgImg.vue";
|
||||
@ -162,6 +167,7 @@ import AttachListComponent from "../module/attach/AttachListComponent.vue";
|
||||
import CreateServiceOrder from "@/components/CreateServiceOrder/index.vue";
|
||||
import Feedback from "@/components/Feedback/index.vue";
|
||||
import DetailCardCompontent from "../module/detail/DetailCardCompontent.vue";
|
||||
import AddCarCrad from "@/components/AddCarCrad/index.vue";
|
||||
import { mainPageData } from "@/request/api/MainPageDataApi";
|
||||
import {
|
||||
conversationMsgList,
|
||||
@ -170,9 +176,9 @@ import {
|
||||
import WebSocketManager from "@/utils/WebSocketManager";
|
||||
import TypewriterManager from "@/utils/TypewriterManager";
|
||||
import { IdUtils } from "@/utils";
|
||||
import { useAppStore } from "@/store";
|
||||
import { checkToken } from "@/hooks/useGoLogin";
|
||||
import { goLogin } from "@/hooks/useGoLogin";
|
||||
|
||||
import { useAppStore } from "@/store";
|
||||
const appStore = useAppStore();
|
||||
/// 导航栏相关
|
||||
const statusBarHeight = ref(20);
|
||||
@ -212,6 +218,8 @@ let commonType = "";
|
||||
|
||||
// WebSocket 相关
|
||||
let webSocketManager = null;
|
||||
/// WebSocket 连接状态
|
||||
let webSocketConnectStatus = false;
|
||||
// 打字机管理器
|
||||
let typewriterManager = null;
|
||||
// 当前会话的消息ID,用于保持发送和终止的messageId一致
|
||||
@ -285,6 +293,11 @@ const handleReply = (text) => {
|
||||
|
||||
// 是发送指令
|
||||
const handleReplyInstruct = (item) => {
|
||||
if (!appStore.hasToken) {
|
||||
console.log("没有token,跳转到登录页");
|
||||
goLogin();
|
||||
return;
|
||||
}
|
||||
if (item.type === "MyOrder") {
|
||||
// 订单
|
||||
uni.navigateTo({
|
||||
@ -356,9 +369,9 @@ onLoad(() => {
|
||||
// token存在,初始化数据
|
||||
const initHandler = () => {
|
||||
console.log("initHandler");
|
||||
|
||||
if (!appStore.hasToken) return;
|
||||
loadRecentConversation();
|
||||
loadConversationMsgList();
|
||||
///loadConversationMsgList();
|
||||
initWebSocket();
|
||||
};
|
||||
|
||||
@ -368,6 +381,7 @@ watch(
|
||||
() => appStore.hasToken,
|
||||
(newValue) => {
|
||||
if (newValue) {
|
||||
console.log("token存在,初始化数据");
|
||||
initHandler();
|
||||
}
|
||||
}
|
||||
@ -380,7 +394,7 @@ onMounted(() => {
|
||||
initTypewriterManager();
|
||||
|
||||
// 有token时,加载最近会话、最近消息、初始化socket
|
||||
checkToken().then(() => initHandler());
|
||||
initHandler();
|
||||
} catch (error) {
|
||||
console.error("页面初始化错误:", error);
|
||||
}
|
||||
@ -441,12 +455,14 @@ const initWebSocket = () => {
|
||||
// 连接成功回调
|
||||
onOpen: (event) => {
|
||||
// 重置会话状态
|
||||
webSocketConnectStatus = true;
|
||||
isSessionActive.value = true;
|
||||
},
|
||||
|
||||
// 连接断开回调
|
||||
onClose: (event) => {
|
||||
console.error("WebSocket连接断开:", event);
|
||||
webSocketConnectStatus = false;
|
||||
// 停止当前会话
|
||||
isSessionActive.value = false;
|
||||
// 停止打字机效果
|
||||
@ -457,6 +473,7 @@ const initWebSocket = () => {
|
||||
|
||||
// 错误回调
|
||||
onError: (error) => {
|
||||
webSocketConnectStatus = false;
|
||||
isSessionActive.value = false;
|
||||
console.error("WebSocket错误:", error);
|
||||
},
|
||||
@ -474,9 +491,14 @@ const initWebSocket = () => {
|
||||
});
|
||||
|
||||
// 初始化连接
|
||||
webSocketManager.connect().catch((error) => {
|
||||
console.error("WebSocket连接失败:", error);
|
||||
});
|
||||
webSocketManager
|
||||
.connect()
|
||||
.then(() => {
|
||||
webSocketConnectStatus = true;
|
||||
})
|
||||
.catch((error) => {
|
||||
console.error("WebSocket连接失败:", error);
|
||||
});
|
||||
};
|
||||
|
||||
// 处理WebSocket消息
|
||||
@ -599,6 +621,22 @@ const initData = () => {
|
||||
|
||||
// 发送消息的参数拼接
|
||||
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) {
|
||||
uni.showToast({
|
||||
title: "请等待当前回复完成",
|
||||
|
||||
@ -7,8 +7,6 @@
|
||||
:key="index"
|
||||
>
|
||||
<view class="more-tips-item-title" @click="sendReply(item)">
|
||||
<Interceptor />
|
||||
|
||||
{{ item }}
|
||||
</view>
|
||||
</view>
|
||||
@ -18,9 +16,6 @@
|
||||
|
||||
<script setup>
|
||||
import { defineProps } from "vue";
|
||||
import { checkToken } from "@/hooks/useGoLogin";
|
||||
import Interceptor from "@/components/Interceptor/index.vue";
|
||||
|
||||
const emits = defineEmits(["replySent"]);
|
||||
|
||||
defineProps({
|
||||
@ -39,8 +34,7 @@ defineProps({
|
||||
});
|
||||
|
||||
const sendReply = (text) => {
|
||||
// 向父组件传递数据
|
||||
checkToken().then(() => emits("replySent", text));
|
||||
emits("replySent", text);
|
||||
};
|
||||
</script>
|
||||
|
||||
|
||||
@ -7,8 +7,6 @@
|
||||
:key="index"
|
||||
@click="sendReply(item)"
|
||||
>
|
||||
<Interceptor />
|
||||
|
||||
<image
|
||||
class="quick-access-item-bg"
|
||||
src="/static/quick/quick_icon_bg.png"
|
||||
@ -26,15 +24,12 @@
|
||||
|
||||
<script setup>
|
||||
import { onMounted, ref } from "vue";
|
||||
import { checkToken } from "@/hooks/useGoLogin";
|
||||
import Interceptor from "@/components/Interceptor/index.vue";
|
||||
|
||||
const itemList = ref([]);
|
||||
|
||||
const emits = defineEmits(["replySent"]);
|
||||
|
||||
const sendReply = (item) => {
|
||||
checkToken().then(() => emits("replySent", item)); // 向父组件传递数据
|
||||
emits("replySent", item); // 向父组件传递数据
|
||||
};
|
||||
|
||||
onMounted(() => {
|
||||
|
||||
@ -11,18 +11,30 @@
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import { defineEmits, ref } from "vue";
|
||||
import { ref } from "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 showDrawer = (e) => {
|
||||
if (!appStore.hasToken) {
|
||||
console.log("没有token,跳转到登录页");
|
||||
goLogin();
|
||||
return;
|
||||
}
|
||||
|
||||
showLeft.value.open();
|
||||
// 发送抽屉显示事件
|
||||
uni.$emit("drawerShow");
|
||||
};
|
||||
// 关闭窗口
|
||||
const closeDrawer = (e) => {
|
||||
showLeft.value.close();
|
||||
// 发送抽屉隐藏事件
|
||||
uni.$emit("drawerHide");
|
||||
};
|
||||
</script>
|
||||
|
||||
|
||||
@ -11,18 +11,41 @@
|
||||
<text class="title">我的</text>
|
||||
</view>
|
||||
|
||||
<MineSetting />
|
||||
<MineSetting v-if="isDrawerVisible" />
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import MineSetting from "./MineSetting.vue";
|
||||
import { defineEmits } from "vue";
|
||||
import { defineEmits, ref, onMounted, onUnmounted } from "vue";
|
||||
const emits = defineEmits(["closeDrawer"]);
|
||||
|
||||
const isDrawerVisible = ref(false);
|
||||
|
||||
const closeDrawer = () => {
|
||||
isDrawerVisible.value = false;
|
||||
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>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
|
||||
@ -38,7 +38,6 @@
|
||||
<script setup>
|
||||
import { ref, onMounted } from "vue";
|
||||
import { getLoginUserPhone } from "@/request/api/LoginApi";
|
||||
import { checkToken } from "@/hooks/useGoLogin";
|
||||
|
||||
// 假数据
|
||||
const userInfo = ref({
|
||||
@ -60,11 +59,9 @@ const menuList = ref([
|
||||
{ label: "订阅消息", type: "action", action: "subscribeMessage" },
|
||||
]);
|
||||
|
||||
// 生命周期钩子
|
||||
// 组件挂载时调用
|
||||
onMounted(() => {
|
||||
checkToken().then(() => {
|
||||
getLoginUserPhoneInfo();
|
||||
});
|
||||
getLoginUserPhoneInfo();
|
||||
});
|
||||
|
||||
const getLoginUserPhoneInfo = async () => {
|
||||
|
||||
@ -39,8 +39,18 @@
|
||||
}}</view>
|
||||
<view class="goods-price">
|
||||
<text class="currency">¥</text>
|
||||
<text class="price">
|
||||
{{ goodsData.specificationPrice || 399 }}
|
||||
<template v-if="goodsData.commodityTypeCode === '0'">
|
||||
<text class="price">
|
||||
{{ goodsData.calculatedTotalPrice || 0 }}
|
||||
</text>
|
||||
<text class="price-desc">
|
||||
({{ goodsData.startDate }}至{{ goodsData.endDate }}) 共{{
|
||||
goodsData.totalDays
|
||||
}}晚
|
||||
</text>
|
||||
</template>
|
||||
<text v-else class="price">
|
||||
{{ goodsData.specificationPrice || 0 }}
|
||||
</text>
|
||||
</view>
|
||||
<view
|
||||
@ -95,7 +105,11 @@
|
||||
|
||||
<!-- 总价区域 -->
|
||||
<SumCard
|
||||
:referencePrice="goodsData.specificationPrice"
|
||||
:referencePrice="
|
||||
goodsData.commodityTypeCode === '0'
|
||||
? goodsData.calculatedTotalPrice
|
||||
: goodsData.specificationPrice
|
||||
"
|
||||
:discount="totalPrice"
|
||||
/>
|
||||
</view>
|
||||
@ -180,7 +194,10 @@ const isDeleting = ref(false); // 标志位,防止删除时watch冲突
|
||||
|
||||
// 计算属性
|
||||
const totalPrice = computed(() => {
|
||||
const price = props.goodsData?.specificationPrice || DEFAULT_PRICE;
|
||||
const price =
|
||||
props.goodsData?.commodityTypeCode === "0"
|
||||
? props.goodsData?.calculatedTotalPrice
|
||||
: props.goodsData?.specificationPrice || 0;
|
||||
return (price * quantity.value).toFixed(0);
|
||||
});
|
||||
|
||||
|
||||
@ -92,6 +92,13 @@
|
||||
font-weight: 600;
|
||||
margin-left: 2px;
|
||||
}
|
||||
|
||||
.price-desc {
|
||||
font-size: 14px;
|
||||
color: #999;
|
||||
font-weight: 400;
|
||||
margin-left: 12px;
|
||||
}
|
||||
}
|
||||
|
||||
.goods-service-list {
|
||||
|
||||
@ -38,7 +38,7 @@
|
||||
<view class="footer">
|
||||
<view class="left">
|
||||
<text class="label">价格:</text>
|
||||
<text class="price">{{ goodsData.specificationPrice || 399 }}</text>
|
||||
<text class="price">{{ calculatedTotalPrice }}</text>
|
||||
</view>
|
||||
<view class="buy-button" @click="showConfirmPopup">立即抢购</view>
|
||||
</view>
|
||||
@ -103,20 +103,34 @@ const selectedDate = ref({
|
||||
});
|
||||
const priceData = ref([]);
|
||||
|
||||
// 计算的总价格
|
||||
const calculatedTotalPrice = ref(0);
|
||||
|
||||
// 获取商品详情数据
|
||||
const goodsInfo = async (params) => {
|
||||
const res = await goodsDetail(params);
|
||||
|
||||
goodsData.value = res.data;
|
||||
|
||||
// 初始化计算价格
|
||||
calculatedTotalPrice.value = goodsData.value.specificationPrice || 0;
|
||||
|
||||
// 判断是酒店类型订单再获取获取商品日价格及库存
|
||||
if (goodsData.value.commodityTypeCode === "0") {
|
||||
configGoodsData();
|
||||
getGoodsDailyPrice({
|
||||
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 res = await commodityDailyPriceList(params);
|
||||
@ -272,6 +286,63 @@ const handleDateSelect = (data) => {
|
||||
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;
|
||||
};
|
||||
|
||||
@ -18,7 +18,7 @@ import { ref, onMounted, onUnmounted } from "vue";
|
||||
import ChatMainList from "../chat/ChatMainList.vue";
|
||||
import Calender from "@/components/Calender/index.vue";
|
||||
import { onLoad } from "@dcloudio/uni-app";
|
||||
import { GetWxMiniProgramUrlParam } from "@/utils/UrlParams";
|
||||
import { getUrlParams } from "@/utils/UrlParams";
|
||||
|
||||
import { useAppStore } from "@/store";
|
||||
|
||||
@ -48,7 +48,7 @@ const getWeixinMiniProgramParams = (e) => {
|
||||
console.log("Params:", e);
|
||||
if (e.q && e.q != "undefined") {
|
||||
const qrUrl = decodeURIComponent(e.q); // 获取到二维码原始链接内容
|
||||
const params = GetWxMiniProgramUrlParam(qrUrl);
|
||||
const params = getUrlParams(qrUrl);
|
||||
appStore.setSceneId(params.sceneId);
|
||||
}
|
||||
};
|
||||
|
||||
@ -1,5 +1,12 @@
|
||||
<template>
|
||||
<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">
|
||||
<!-- 卡通形象 -->
|
||||
@ -31,7 +38,7 @@
|
||||
class="login-btn"
|
||||
open-type="getPhoneNumber"
|
||||
type="primary"
|
||||
@getphonenumber="onLogin"
|
||||
@getphonenumber="getPhoneNumber"
|
||||
>
|
||||
微信一键登录
|
||||
</button>
|
||||
@ -66,15 +73,15 @@
|
||||
|
||||
<script setup>
|
||||
import { ref, computed } from "vue";
|
||||
import { loginAuth, bindPhone, checkPhone } from "@/manager/LoginManager";
|
||||
import {
|
||||
getServiceAgreement,
|
||||
getPrivacyAgreement,
|
||||
} from "@/request/api/LoginApi";
|
||||
import { goHome } from "@/hooks/useGoHome";
|
||||
import { onLogin, goBack } from "@/hooks/useGoLogin";
|
||||
import loginBg from "./images/bg.png";
|
||||
import CheckBox from "@/components/CheckBox/index.vue";
|
||||
import AgreePopup from "./components/AgreePopup/index.vue";
|
||||
import { zniconsMap } from "@/static/fonts/znicons.js";
|
||||
|
||||
const isAgree = ref(false);
|
||||
const visible = ref(false);
|
||||
@ -94,30 +101,20 @@ const handleAgreeAndGetPhone = () => {
|
||||
}
|
||||
};
|
||||
|
||||
const onLogin = (e) => {
|
||||
const { code } = e.detail;
|
||||
console.info("onLogin code: ", code);
|
||||
|
||||
loginAuth()
|
||||
.then(async () => {
|
||||
// 检测是否绑定手机号,已绑定则直接跳转首页,未绑定则获取手机号并绑定
|
||||
const res = await checkPhone();
|
||||
|
||||
if (res.data) {
|
||||
return goHome();
|
||||
}
|
||||
|
||||
const { data } = await bindPhone({
|
||||
wechatPhoneCode: code,
|
||||
clientId: "2",
|
||||
const getPhoneNumber = (e) => {
|
||||
onLogin(e)
|
||||
.then(() => {
|
||||
uni.showToast({
|
||||
title: "登录成功",
|
||||
icon: "success",
|
||||
});
|
||||
|
||||
if (data) {
|
||||
goHome();
|
||||
}
|
||||
goBack();
|
||||
})
|
||||
.catch((err) => {
|
||||
console.error("登录失败", err);
|
||||
.catch(() => {
|
||||
uni.showToast({
|
||||
title: "登录失败",
|
||||
icon: "none",
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
@ -155,4 +152,8 @@ getPrivacyAgreementData();
|
||||
|
||||
<style lang="scss" scoped>
|
||||
@import "./styles/index.scss";
|
||||
@font-face {
|
||||
font-family: znicons;
|
||||
src: url("@/static/fonts/znicons.ttf");
|
||||
}
|
||||
</style>
|
||||
|
||||
@ -1,63 +1,75 @@
|
||||
.login-wrapper {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
box-sizing: border-box;
|
||||
font-family: PingFang SC, PingFang SC;
|
||||
height: 100vh;
|
||||
padding-top: 168px;
|
||||
position: relative;
|
||||
background-position: 0 0;
|
||||
background-size: 100% 100%;
|
||||
background-repeat: no-repeat;
|
||||
|
||||
.back-btn {
|
||||
position: absolute;
|
||||
top: 44px;
|
||||
left: 4px;
|
||||
width: 44px;
|
||||
height: 44px;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
box-sizing: border-box;
|
||||
font-family: PingFang SC, PingFang SC;
|
||||
height: 100vh;
|
||||
padding-top: 168px;
|
||||
position: relative;
|
||||
background-position: 0 0;
|
||||
background-size: 100% 100%;
|
||||
background-repeat: no-repeat;
|
||||
justify-content: center;
|
||||
z-index: 10;
|
||||
}
|
||||
|
||||
.login-header {
|
||||
text-align: center;
|
||||
max-height: 223px;
|
||||
.login-header {
|
||||
text-align: center;
|
||||
max-height: 223px;
|
||||
|
||||
.login-avatar {
|
||||
width: 150px;
|
||||
display: block;
|
||||
}
|
||||
|
||||
.login-title {
|
||||
width: 137px;
|
||||
height: 32px;
|
||||
margin: 6px auto;
|
||||
}
|
||||
|
||||
.login-desc {
|
||||
font-size: 12px;
|
||||
color: #1e4c69;
|
||||
line-height: 24px;
|
||||
}
|
||||
.login-avatar {
|
||||
width: 150px;
|
||||
display: block;
|
||||
}
|
||||
|
||||
.login-btn-area {
|
||||
margin-top: 46px;
|
||||
width: 297px;
|
||||
|
||||
.login-btn {
|
||||
background: linear-gradient(246deg, #22a7ff 0%, #2567ff 100%);
|
||||
width: 100%;
|
||||
border-radius: 50px;
|
||||
}
|
||||
.login-title {
|
||||
width: 137px;
|
||||
height: 32px;
|
||||
margin: 6px auto;
|
||||
}
|
||||
|
||||
.login-agreement {
|
||||
margin-top: 20px;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
|
||||
.login-agreement-text {
|
||||
font-size: 14px;
|
||||
color: #666;
|
||||
}
|
||||
|
||||
.login-agreement-link {
|
||||
font-size: 14px;
|
||||
color: #007aff;
|
||||
margin: 0 5px;
|
||||
}
|
||||
.login-desc {
|
||||
font-size: 12px;
|
||||
color: #1e4c69;
|
||||
line-height: 24px;
|
||||
}
|
||||
}
|
||||
|
||||
.login-btn-area {
|
||||
margin-top: 46px;
|
||||
width: 297px;
|
||||
|
||||
.login-btn {
|
||||
background: linear-gradient(246deg, #22a7ff 0%, #2567ff 100%);
|
||||
width: 100%;
|
||||
border-radius: 50px;
|
||||
}
|
||||
}
|
||||
|
||||
.login-agreement {
|
||||
margin-top: 20px;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
|
||||
.login-agreement-text {
|
||||
font-size: 14px;
|
||||
color: #666;
|
||||
}
|
||||
|
||||
.login-agreement-link {
|
||||
font-size: 14px;
|
||||
color: #007aff;
|
||||
margin: 0 5px;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -6,7 +6,7 @@
|
||||
v-for="(item, index) in commodityDTO.commodityList"
|
||||
:key="`${item.commodityId}-${index}`"
|
||||
>
|
||||
<Interceptor class="mk-card-item" @click="placeOrderHandle(item)">
|
||||
<view class="mk-card-item" @click="placeOrderHandle(item)">
|
||||
<!-- <view class="card-badge">超值推荐</view> -->
|
||||
<image class="card-img" :src="item.commodityIcon" mode="aspectFill" />
|
||||
<view class="card-content">
|
||||
@ -38,7 +38,7 @@
|
||||
<text class="card-btn">下单</text>
|
||||
</view>
|
||||
</view>
|
||||
</Interceptor>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
@ -47,7 +47,6 @@
|
||||
<script setup>
|
||||
import ModuleTitle from "@/components/ModuleTitle/index.vue";
|
||||
import { defineProps } from "vue";
|
||||
import Interceptor from "@/components/Interceptor/index.vue";
|
||||
|
||||
const props = defineProps({
|
||||
commodityDTO: {
|
||||
|
||||
@ -7,7 +7,6 @@
|
||||
:key="`${item.commodityId}-${index}`"
|
||||
>
|
||||
<view class="mk-card-item" @click="placeOrderHandle(item)">
|
||||
<Interceptor />
|
||||
<image
|
||||
class="card-img"
|
||||
:src="item.commodityPhoto"
|
||||
@ -51,7 +50,6 @@
|
||||
import { defineProps } from "vue";
|
||||
import { checkToken } from "@/hooks/useGoLogin";
|
||||
import ModuleTitle from "@/components/ModuleTitle/index.vue";
|
||||
import Interceptor from "@/components/Interceptor/index.vue";
|
||||
|
||||
const props = defineProps({
|
||||
commodityList: {
|
||||
|
||||
@ -7,8 +7,6 @@
|
||||
:key="index"
|
||||
>
|
||||
<view class="mk-card-item" @click="sendReply(item)">
|
||||
<Interceptor />
|
||||
|
||||
<image
|
||||
class="card-img"
|
||||
:src="item.coverPhoto"
|
||||
@ -24,8 +22,6 @@
|
||||
<script setup>
|
||||
import { RECOMMEND_POSTS_TITLE } from "@/constant/constant";
|
||||
import { defineProps } from "vue";
|
||||
import { checkToken } from "@/hooks/useGoLogin";
|
||||
import Interceptor from "@/components/Interceptor/index.vue";
|
||||
import ModuleTitle from "@/components/ModuleTitle/index.vue";
|
||||
|
||||
const props = defineProps({
|
||||
@ -36,10 +32,8 @@ const props = defineProps({
|
||||
});
|
||||
|
||||
const sendReply = (item) => {
|
||||
checkToken().then(() => {
|
||||
const topic = item.userInputContent || item.topic.replace(/^#/, "");
|
||||
uni.$emit(RECOMMEND_POSTS_TITLE, topic);
|
||||
});
|
||||
const topic = item.userInputContent || item.topic.replace(/^#/, "");
|
||||
uni.$emit(RECOMMEND_POSTS_TITLE, topic);
|
||||
};
|
||||
</script>
|
||||
|
||||
|
||||
@ -7,7 +7,6 @@
|
||||
:key="index"
|
||||
>
|
||||
<view class="mk-card-item" @click="sendReply(item)">
|
||||
<Interceptor />
|
||||
<image class="card-img" :src="item.coverPhoto" mode="aspectFill" />
|
||||
|
||||
<view class="overlay-gradient">
|
||||
@ -22,8 +21,6 @@
|
||||
<script setup>
|
||||
import { defineProps } from "vue";
|
||||
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";
|
||||
|
||||
const props = defineProps({
|
||||
@ -34,10 +31,8 @@ const props = defineProps({
|
||||
});
|
||||
|
||||
const sendReply = (item) => {
|
||||
checkToken().then(() => {
|
||||
const topic = item.userInputContent || item.topic.replace(/^#/, "");
|
||||
uni.$emit(RECOMMEND_POSTS_TITLE, topic);
|
||||
});
|
||||
const topic = item.userInputContent || item.topic.replace(/^#/, "");
|
||||
uni.$emit(RECOMMEND_POSTS_TITLE, topic);
|
||||
};
|
||||
</script>
|
||||
|
||||
|
||||
@ -7,7 +7,11 @@
|
||||
<view class="order-title">
|
||||
{{ orderData.workOrderTypeName || orderData.commodityName }}
|
||||
</view>
|
||||
<image class="arrow-icon" src="./images/arrow.png"></image>
|
||||
<image
|
||||
v-if="props.orderData.orderType !== undefined"
|
||||
class="arrow-icon"
|
||||
src="./images/arrow.png"
|
||||
></image>
|
||||
</view>
|
||||
<view
|
||||
v-if="orderData.status !== 'pending'"
|
||||
@ -107,6 +111,7 @@ const getStatusText = (status) => {
|
||||
|
||||
// 处理卡片点击
|
||||
const handleCardClick = () => {
|
||||
if (props.orderData.orderType === undefined) return;
|
||||
emit("click", props.orderData);
|
||||
};
|
||||
</script>
|
||||
|
||||
56
pages/webview/index.vue
Normal file
56
pages/webview/index.vue
Normal file
@ -0,0 +1,56 @@
|
||||
<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>
|
||||
@ -1,8 +1,8 @@
|
||||
import { BASE_URL } from "../../constant/base";
|
||||
import { BASE_URL } from "@/request/base/baseUrl";
|
||||
import { goLogin } from "@/hooks/useGoLogin";
|
||||
|
||||
/// 请求流式数据的API
|
||||
const API = '/agent/assistant/chat';
|
||||
const API = "/agent/assistant/chat";
|
||||
|
||||
/**
|
||||
* 获取AI聊天流式信息(仅微信小程序支持)
|
||||
@ -15,8 +15,8 @@ const API = '/agent/assistant/chat';
|
||||
let requestTask = null;
|
||||
let isAborted = false;
|
||||
let currentPromiseReject = null;
|
||||
let lastRequestId = null; // 记录上一次请求ID
|
||||
let activeRequestId = null; // 记录当前活动请求ID
|
||||
let lastRequestId = null; // 记录上一次请求ID
|
||||
let activeRequestId = null; // 记录当前活动请求ID
|
||||
|
||||
/**
|
||||
* 终止的请求
|
||||
@ -24,14 +24,14 @@ let activeRequestId = null; // 记录当前活动请求ID
|
||||
const stopAbortTask = () => {
|
||||
console.log("🛑 开始强制终止请求... ");
|
||||
isAborted = true;
|
||||
|
||||
|
||||
// 将当前活动请求ID保存为上一次请求ID
|
||||
lastRequestId = activeRequestId;
|
||||
// 清除当前活动请求ID
|
||||
activeRequestId = null;
|
||||
|
||||
if (currentPromiseReject) {
|
||||
currentPromiseReject(new Error('请求已被用户终止'));
|
||||
currentPromiseReject(new Error("请求已被用户终止"));
|
||||
currentPromiseReject = null;
|
||||
}
|
||||
|
||||
@ -39,16 +39,16 @@ const stopAbortTask = () => {
|
||||
// 先移除监听器,再终止请求
|
||||
const cleanupListeners = () => {
|
||||
try {
|
||||
if(requestTask.offChunkReceived) {
|
||||
console.log("======>offChunkReceived")
|
||||
if (requestTask.offChunkReceived) {
|
||||
console.log("======>offChunkReceived");
|
||||
requestTask.offChunkReceived();
|
||||
}
|
||||
if(requestTask.offHeadersReceived) {
|
||||
console.log("======>offHeadersReceived")
|
||||
if (requestTask.offHeadersReceived) {
|
||||
console.log("======>offHeadersReceived");
|
||||
requestTask.offHeadersReceived();
|
||||
}
|
||||
} catch (e) {
|
||||
console.error('清理事件监听器失败:', e);
|
||||
console.error("清理事件监听器失败:", e);
|
||||
}
|
||||
};
|
||||
|
||||
@ -57,51 +57,53 @@ const stopAbortTask = () => {
|
||||
// 终止请求
|
||||
try {
|
||||
if (requestTask.abort) {
|
||||
console.log("======>abort")
|
||||
console.log("======>abort");
|
||||
requestTask.abort();
|
||||
}
|
||||
} catch (e) {
|
||||
console.log('🛑 终止网络请求失败:', e);
|
||||
console.log("🛑 终止网络请求失败:", e);
|
||||
}
|
||||
|
||||
requestTask = null;
|
||||
}
|
||||
|
||||
console.log('🛑 请求强制终止完成');
|
||||
}
|
||||
console.log("🛑 请求强制终止完成");
|
||||
};
|
||||
|
||||
const agentChatStream = (params, onChunk) => {
|
||||
return new Promise((resolve, reject) => {
|
||||
const token = uni.getStorageSync('token');
|
||||
const token = uni.getStorageSync("token");
|
||||
const requestId = Date.now().toString(); // 生成唯一请求ID
|
||||
|
||||
|
||||
// 重置状态
|
||||
isAborted = false;
|
||||
currentPromiseReject = reject;
|
||||
|
||||
|
||||
// 更新请求ID追踪
|
||||
lastRequestId = activeRequestId; // 保存上一次请求ID
|
||||
activeRequestId = requestId; // 设置新的活动请求ID
|
||||
lastRequestId = activeRequestId; // 保存上一次请求ID
|
||||
activeRequestId = requestId; // 设置新的活动请求ID
|
||||
|
||||
console.log(`🚀 发送请求 [${requestId}], 上一次请求ID [${lastRequestId}]`);
|
||||
|
||||
// 检查数据块是否来自已终止的请求
|
||||
const isStaleData = (dataRequestId) => {
|
||||
return dataRequestId === lastRequestId || dataRequestId !== activeRequestId;
|
||||
return (
|
||||
dataRequestId === lastRequestId || dataRequestId !== activeRequestId
|
||||
);
|
||||
};
|
||||
|
||||
// #ifdef MP-WEIXIN
|
||||
requestTask = uni.request({
|
||||
url: BASE_URL + API, // 替换为你的接口地址
|
||||
method: 'POST',
|
||||
method: "POST",
|
||||
data: params,
|
||||
enableChunked: true,
|
||||
header: {
|
||||
Accept: 'text/event-stream',
|
||||
'Content-Type': 'application/json',
|
||||
Accept: "text/event-stream",
|
||||
"Content-Type": "application/json",
|
||||
Authorization: `Bearer ${token}`, // 如需token可加
|
||||
},
|
||||
responseType: 'arraybuffer',
|
||||
responseType: "arraybuffer",
|
||||
success(res) {
|
||||
if (!isAborted && !isStaleData(requestId)) {
|
||||
console.log(`✅ 请求 [${requestId}] 成功`);
|
||||
@ -122,43 +124,52 @@ const agentChatStream = (params, onChunk) => {
|
||||
// 使用 requestId 来验证请求有效性
|
||||
if (!isAborted && activeRequestId === requestId) {
|
||||
if (res.statusCode !== 200) {
|
||||
console.log(`❌ 请求 [${requestId}] 完成但状态错误,状态:`, res.statusCode);
|
||||
if(res.statusCode === 424) {
|
||||
uni.setStorageSync('token', '');
|
||||
console.log(
|
||||
`❌ 请求 [${requestId}] 完成但状态错误,状态:`,
|
||||
res.statusCode
|
||||
);
|
||||
if (res.statusCode === 424) {
|
||||
uni.setStorageSync("token", "");
|
||||
goLogin();
|
||||
}
|
||||
if (onChunk) {
|
||||
onChunk({
|
||||
error: true,
|
||||
message: '服务器错误',
|
||||
detail: res
|
||||
onChunk({
|
||||
error: true,
|
||||
message: "服务器错误",
|
||||
detail: res,
|
||||
});
|
||||
}
|
||||
reject(res);
|
||||
}
|
||||
} else {
|
||||
console.log(`❌ 请求 [${requestId}] ${isAborted ? '已终止' : '已过期'},忽略complete回调`);
|
||||
console.log(
|
||||
`❌ 请求 [${requestId}] ${
|
||||
isAborted ? "已终止" : "已过期"
|
||||
},忽略complete回调`
|
||||
);
|
||||
}
|
||||
}
|
||||
},
|
||||
});
|
||||
|
||||
requestTask.onHeadersReceived(res => {
|
||||
requestTask.onHeadersReceived((res) => {
|
||||
// 使用 requestId 验证请求有效性
|
||||
if (isAborted || activeRequestId !== requestId) {
|
||||
console.log(`🚫 Headers [${requestId}] ${isAborted ? '已终止' : '已过期'},忽略`);
|
||||
console.log(
|
||||
`🚫 Headers [${requestId}] ${isAborted ? "已终止" : "已过期"},忽略`
|
||||
);
|
||||
return;
|
||||
}
|
||||
|
||||
console.log(`📡 请求 [${requestId}] Headers接收:`, res);
|
||||
const status = res.statusCode || (res.header && res.header.statusCode);
|
||||
|
||||
|
||||
if (status && status !== 200) {
|
||||
console.log(`❌ 请求 [${requestId}] 服务器返回错误状态:`, status);
|
||||
if (onChunk && !isAborted && activeRequestId === requestId) {
|
||||
onChunk({
|
||||
error: true,
|
||||
message: `服务器错误(${status})`,
|
||||
detail: res
|
||||
onChunk({
|
||||
error: true,
|
||||
message: `服务器错误(${status})`,
|
||||
detail: res,
|
||||
});
|
||||
}
|
||||
// 终止异常请求
|
||||
@ -168,7 +179,7 @@ const agentChatStream = (params, onChunk) => {
|
||||
}
|
||||
});
|
||||
|
||||
requestTask.onChunkReceived(res => {
|
||||
requestTask.onChunkReceived((res) => {
|
||||
// 立即验证请求有效性
|
||||
if (isAborted || isStaleData(requestId)) {
|
||||
console.log(`🚫 数据块 [${requestId}] 已终止或过期,忽略`);
|
||||
@ -176,15 +187,15 @@ const agentChatStream = (params, onChunk) => {
|
||||
}
|
||||
|
||||
const base64 = uni.arrayBufferToBase64(res.data);
|
||||
let data = '';
|
||||
let data = "";
|
||||
try {
|
||||
data = decodeURIComponent(escape(weAtob(base64)));
|
||||
} catch (e) {
|
||||
console.error('Base64解码失败:', e);
|
||||
console.error("Base64解码失败:", e);
|
||||
return;
|
||||
}
|
||||
|
||||
console.log("📦 onChunkReceived,res:", data)
|
||||
console.log("📦 onChunkReceived,res:", data);
|
||||
|
||||
// 再次验证请求有效性
|
||||
if (isAborted || activeRequestId !== requestId) {
|
||||
@ -193,7 +204,7 @@ const agentChatStream = (params, onChunk) => {
|
||||
}
|
||||
|
||||
const messages = parseSSEChunk(data);
|
||||
messages.forEach(msg => {
|
||||
messages.forEach((msg) => {
|
||||
if (!isAborted && !isStaleData(requestId) && onChunk) {
|
||||
onChunk(msg);
|
||||
}
|
||||
@ -201,14 +212,16 @@ const agentChatStream = (params, onChunk) => {
|
||||
});
|
||||
// #endif
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
// window.atob兼容性处理
|
||||
const weAtob = (string) => {
|
||||
const b64re = /^(?:[A-Za-z\d+/]{4})*?(?:[A-Za-z\d+/]{2}(?:==)?|[A-Za-z\d+/]{3}=?)?$/;
|
||||
const b64 = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=';
|
||||
const b64re =
|
||||
/^(?:[A-Za-z\d+/]{4})*?(?:[A-Za-z\d+/]{2}(?:==)?|[A-Za-z\d+/]{3}=?)?$/;
|
||||
const b64 =
|
||||
"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";
|
||||
// 去除空白字符
|
||||
string = String(string).replace(/[\t\n\f\r ]+/g, '');
|
||||
string = String(string).replace(/[\t\n\f\r ]+/g, "");
|
||||
// 验证 Base64 编码
|
||||
if (!b64re.test(string)) {
|
||||
throw new TypeError(
|
||||
@ -218,15 +231,15 @@ const weAtob = (string) => {
|
||||
}
|
||||
|
||||
// 填充字符
|
||||
string += '=='.slice(2 - (string.length & 3));
|
||||
string += "==".slice(2 - (string.length & 3));
|
||||
|
||||
let bitmap,
|
||||
result = '',
|
||||
result = "",
|
||||
r1,
|
||||
r2,
|
||||
i = 0;
|
||||
|
||||
for (; i < string.length;) {
|
||||
for (; i < string.length; ) {
|
||||
bitmap =
|
||||
(b64.indexOf(string.charAt(i++)) << 18) |
|
||||
(b64.indexOf(string.charAt(i++)) << 12) |
|
||||
@ -236,10 +249,7 @@ const weAtob = (string) => {
|
||||
if (r1 === 64) {
|
||||
result += String.fromCharCode((bitmap >> 16) & 255);
|
||||
} else if (r2 === 64) {
|
||||
result += String.fromCharCode(
|
||||
(bitmap >> 16) & 255,
|
||||
(bitmap >> 8) & 255
|
||||
);
|
||||
result += String.fromCharCode((bitmap >> 16) & 255, (bitmap >> 8) & 255);
|
||||
} else {
|
||||
result += String.fromCharCode(
|
||||
(bitmap >> 16) & 255,
|
||||
@ -251,7 +261,6 @@ const weAtob = (string) => {
|
||||
return result;
|
||||
};
|
||||
|
||||
|
||||
// 解析SSE分段数据
|
||||
const parseSSEChunk = (raw) => {
|
||||
const results = [];
|
||||
@ -264,7 +273,7 @@ const parseSSEChunk = (raw) => {
|
||||
let dataLines = [];
|
||||
|
||||
for (const line of lines) {
|
||||
if (line.startsWith('data:')) {
|
||||
if (line.startsWith("data:")) {
|
||||
// 提取data:后面的内容并去除首尾空格
|
||||
dataLines.push(line.slice(5).trim());
|
||||
}
|
||||
@ -272,18 +281,18 @@ const parseSSEChunk = (raw) => {
|
||||
|
||||
if (dataLines.length > 0) {
|
||||
// 拼接多行数据
|
||||
const fullData = dataLines.join('\n');
|
||||
const fullData = dataLines.join("\n");
|
||||
try {
|
||||
const obj = JSON.parse(fullData);
|
||||
results.push(obj);
|
||||
} catch (e) {
|
||||
console.warn('⚠️ SSE数据解析失败:', e, '原始数据:', fullData);
|
||||
console.warn("⚠️ SSE数据解析失败:", e, "原始数据:", fullData);
|
||||
// 解析失败忽略
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return results;
|
||||
}
|
||||
};
|
||||
|
||||
export { agentChatStream, stopAbortTask }
|
||||
export { agentChatStream, stopAbortTask };
|
||||
|
||||
19
request/base/baseUrl.js
Normal file
19
request/base/baseUrl.js
Normal file
@ -0,0 +1,19 @@
|
||||
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;
|
||||
@ -1,5 +1,6 @@
|
||||
import { BASE_URL } from "../../constant/base";
|
||||
import { goLogin } from "@/hooks/useGoLogin";
|
||||
import { goLogin } from "../../hooks/useGoLogin";
|
||||
import { BASE_URL } from "./baseUrl";
|
||||
import { loginAuth, checkPhone } from "@/manager/LoginManager";
|
||||
|
||||
const defaultConfig = {
|
||||
header: {
|
||||
@ -50,10 +51,16 @@ function request(url, args = {}, method = "POST", customConfig = {}) {
|
||||
success: (res) => {
|
||||
console.log("请求响应:" + JSON.stringify(res));
|
||||
resolve(res.data);
|
||||
// if (res.statusCode && res.statusCode === 424) {
|
||||
// uni.setStorageSync("token", "");
|
||||
// goLogin();
|
||||
// }
|
||||
if (res.statusCode && res.statusCode === 424) {
|
||||
console.log("424错误,重新登录");
|
||||
loginAuth().then(async () => {
|
||||
// 检测是否绑定手机号
|
||||
const res = await checkPhone();
|
||||
if (!res.data) {
|
||||
goLogin();
|
||||
}
|
||||
});
|
||||
}
|
||||
},
|
||||
fail: (err) => {
|
||||
console.error("请求失败:", err);
|
||||
|
||||
20
router/index.js
Normal file
20
router/index.js
Normal file
@ -0,0 +1,20 @@
|
||||
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),
|
||||
});
|
||||
}
|
||||
@ -1,4 +1,4 @@
|
||||
export function GetWxMiniProgramUrlParam(url) {
|
||||
export function getUrlParams(url) {
|
||||
let theRequest = {};
|
||||
if(url.indexOf("#") != -1){
|
||||
const str=url.split("#")[1];
|
||||
@ -15,3 +15,23 @@ export function GetWxMiniProgramUrlParam(url) {
|
||||
}
|
||||
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('&') : '';
|
||||
}
|
||||
|
||||
@ -13,7 +13,12 @@ export class IdUtils {
|
||||
* @returns {string} 消息ID
|
||||
*/
|
||||
static generateMessageId() {
|
||||
return "mid" + new Date().getTime();
|
||||
const timestamp = 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;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user