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://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
|
|
||||||
|
|||||||
@ -1,13 +1,7 @@
|
|||||||
NODE_ENV = production
|
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://biz.nianxx.cn/agent/ws/chat
|
||||||
|
|
||||||
# 测试
|
|
||||||
VITE_WSS_URL = wss://onefeel.brother7.cn/ingress/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
|
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://biz.nianxx.cn/agent/ws/chat
|
||||||
|
|
||||||
# 测试
|
|
||||||
VITE_WSS_URL = wss://onefeel.brother7.cn/ingress/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: {
|
priceData: {
|
||||||
type: Array,
|
type: Array,
|
||||||
default: () => [
|
default: () => [{ date: "", price: "-", stock: "0" }],
|
||||||
{date: '', price: '-', stock: '0'}
|
|
||||||
],
|
|
||||||
},
|
},
|
||||||
|
|
||||||
// 默认选中日期
|
// 默认选中日期
|
||||||
@ -210,7 +208,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;
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -387,22 +385,58 @@ 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);
|
||||||
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显示
|
// 监听visible属性变化,控制uni-popup显示
|
||||||
|
|||||||
@ -1,7 +1,7 @@
|
|||||||
// 颜色系统
|
// 颜色系统
|
||||||
$primary-color: #1890ff;
|
$primary-color: #1890ff;
|
||||||
$primary-light: #e6f7ff;
|
$primary-light: #e6f7ff;
|
||||||
$primary-dark: #0050b3;
|
$primary-dark: #1890ff;
|
||||||
|
|
||||||
// 中性色
|
// 中性色
|
||||||
$text-primary: #262626;
|
$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) => {
|
export const onLogin = async (e) => {
|
||||||
const token = uni.getStorageSync("token");
|
return new Promise(async (resolve) => {
|
||||||
|
await loginAuth().then(async () => {
|
||||||
|
const { code } = e.detail;
|
||||||
|
console.info("onLogin code: ", code);
|
||||||
|
|
||||||
if (token) return;
|
// 绑定手机号
|
||||||
|
const params = { wechatPhoneCode: code, clientId: clientId };
|
||||||
const { code } = e.detail;
|
const res = await bindPhone(params);
|
||||||
console.info("onLogin code: ", code);
|
if (res.data) {
|
||||||
|
resolve();
|
||||||
loginAuth().then(async () => {
|
}
|
||||||
// 检测是否绑定手机号
|
});
|
||||||
const res = await checkPhone();
|
|
||||||
|
|
||||||
if (res.data) return;
|
|
||||||
|
|
||||||
const params = { wechatPhoneCode: code, clientId: "2" };
|
|
||||||
|
|
||||||
// 绑定手机号
|
|
||||||
bindPhone(params);
|
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -29,9 +29,13 @@ export const onLogin = (e) => {
|
|||||||
export const checkToken = async () => {
|
export const checkToken = async () => {
|
||||||
return new Promise((resolve) => {
|
return new Promise((resolve) => {
|
||||||
const token = uni.getStorageSync("token");
|
const token = uni.getStorageSync("token");
|
||||||
|
if (!token) {
|
||||||
if (!token) return;
|
console.log("token不存在,重新登录");
|
||||||
|
loginAuth().then(() => {
|
||||||
resolve(token);
|
resolve();
|
||||||
|
});
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
resolve();
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|||||||
@ -5,6 +5,7 @@ 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) => {
|
||||||
@ -14,15 +15,13 @@ const loginAuth = () => {
|
|||||||
openIdCode: [openIdCode],
|
openIdCode: [openIdCode],
|
||||||
grant_type: "wechat",
|
grant_type: "wechat",
|
||||||
scope: "server",
|
scope: "server",
|
||||||
clientId: "2",
|
clientId: clientId,
|
||||||
});
|
});
|
||||||
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 {
|
||||||
|
|||||||
@ -55,7 +55,10 @@
|
|||||||
},
|
},
|
||||||
/* 快应用特有相关 */
|
/* 快应用特有相关 */
|
||||||
"quickapp": {},
|
"quickapp": {},
|
||||||
/* 小程序特有相关 朵花用:wx23f86d809ae80259 测试用:wx5e79df5996572539 */
|
/* 小程序特有相关 同时更改 project.config.json文件
|
||||||
|
智念:wx5e79df5996572539
|
||||||
|
朵花:wx23f86d809ae80259
|
||||||
|
*/
|
||||||
"mp-weixin": {
|
"mp-weixin": {
|
||||||
"appid": "wx5e79df5996572539",
|
"appid": "wx5e79df5996572539",
|
||||||
"setting": {
|
"setting": {
|
||||||
|
|||||||
@ -16,4 +16,5 @@ export const CompName = {
|
|||||||
createWorkOrderCard: "createWorkOrderCard",
|
createWorkOrderCard: "createWorkOrderCard",
|
||||||
feedbackCard: "feedbackCard",
|
feedbackCard: "feedbackCard",
|
||||||
discoveryCard: "discoveryCard",
|
discoveryCard: "discoveryCard",
|
||||||
|
addLicensePlate: "addLicensePlate",
|
||||||
};
|
};
|
||||||
17
pages.json
17
pages.json
@ -1,6 +1,5 @@
|
|||||||
{
|
{
|
||||||
"pages": [
|
"pages": [
|
||||||
//pages数组中第一项表示应用启动页,参考:https://uniapp.dcloud.io/collocation/pages
|
|
||||||
{
|
{
|
||||||
"path": "pages/index/index",
|
"path": "pages/index/index",
|
||||||
"style": {
|
"style": {
|
||||||
@ -47,13 +46,21 @@
|
|||||||
"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": {}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -84,6 +84,9 @@ 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; // ✅ 强制换行
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -9,8 +9,6 @@
|
|||||||
|
|
||||||
<!-- 输入框/语音按钮容器 -->
|
<!-- 输入框/语音按钮容器 -->
|
||||||
<view class="input-button-container">
|
<view class="input-button-container">
|
||||||
<Interceptor />
|
|
||||||
|
|
||||||
<textarea
|
<textarea
|
||||||
ref="textareaRef"
|
ref="textareaRef"
|
||||||
v-if="!isVoiceMode"
|
v-if="!isVoiceMode"
|
||||||
@ -63,9 +61,7 @@
|
|||||||
|
|
||||||
<script setup>
|
<script setup>
|
||||||
import { ref, watch, nextTick, onMounted, defineExpose } from "vue";
|
import { ref, watch, nextTick, onMounted, defineExpose } from "vue";
|
||||||
import { checkToken } from "@/hooks/useGoLogin";
|
|
||||||
import RecordingWaveBtn from "@/components/Speech/RecordingWaveBtn.vue";
|
import RecordingWaveBtn from "@/components/Speech/RecordingWaveBtn.vue";
|
||||||
import Interceptor from "@/components/Interceptor/index.vue";
|
|
||||||
|
|
||||||
const plugin = requirePlugin("WechatSI");
|
const plugin = requirePlugin("WechatSI");
|
||||||
const manager = plugin.getRecordRecognitionManager();
|
const manager = plugin.getRecordRecognitionManager();
|
||||||
@ -117,8 +113,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;
|
||||||
|
|
||||||
@ -128,7 +123,6 @@ const handleVoiceTouchStart = () => {
|
|||||||
recordingWaveBtnRef.value.startAnimation();
|
recordingWaveBtnRef.value.startAnimation();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
});
|
|
||||||
};
|
};
|
||||||
|
|
||||||
// 处理语音按钮长按结束
|
// 处理语音按钮长按结束
|
||||||
|
|||||||
@ -42,7 +42,6 @@
|
|||||||
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">
|
||||||
@ -71,6 +70,12 @@
|
|||||||
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>
|
||||||
@ -143,7 +148,7 @@ import {
|
|||||||
RECOMMEND_POSTS_TITLE,
|
RECOMMEND_POSTS_TITLE,
|
||||||
SEND_COMMAND_TEXT,
|
SEND_COMMAND_TEXT,
|
||||||
} from "@/constant/constant";
|
} from "@/constant/constant";
|
||||||
import { WSS_URL } from "@/constant/base";
|
import { WSS_URL } from "@/request/base/baseUrl";
|
||||||
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";
|
||||||
@ -162,6 +167,7 @@ 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,
|
||||||
@ -170,9 +176,9 @@ import {
|
|||||||
import WebSocketManager from "@/utils/WebSocketManager";
|
import WebSocketManager from "@/utils/WebSocketManager";
|
||||||
import TypewriterManager from "@/utils/TypewriterManager";
|
import TypewriterManager from "@/utils/TypewriterManager";
|
||||||
import { IdUtils } from "@/utils";
|
import { IdUtils } from "@/utils";
|
||||||
import { useAppStore } from "@/store";
|
import { goLogin } from "@/hooks/useGoLogin";
|
||||||
import { checkToken } from "@/hooks/useGoLogin";
|
|
||||||
|
|
||||||
|
import { useAppStore } from "@/store";
|
||||||
const appStore = useAppStore();
|
const appStore = useAppStore();
|
||||||
/// 导航栏相关
|
/// 导航栏相关
|
||||||
const statusBarHeight = ref(20);
|
const statusBarHeight = ref(20);
|
||||||
@ -212,6 +218,8 @@ let commonType = "";
|
|||||||
|
|
||||||
// WebSocket 相关
|
// WebSocket 相关
|
||||||
let webSocketManager = null;
|
let webSocketManager = null;
|
||||||
|
/// WebSocket 连接状态
|
||||||
|
let webSocketConnectStatus = false;
|
||||||
// 打字机管理器
|
// 打字机管理器
|
||||||
let typewriterManager = null;
|
let typewriterManager = null;
|
||||||
// 当前会话的消息ID,用于保持发送和终止的messageId一致
|
// 当前会话的消息ID,用于保持发送和终止的messageId一致
|
||||||
@ -285,6 +293,11 @@ 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({
|
||||||
@ -356,9 +369,9 @@ onLoad(() => {
|
|||||||
// token存在,初始化数据
|
// token存在,初始化数据
|
||||||
const initHandler = () => {
|
const initHandler = () => {
|
||||||
console.log("initHandler");
|
console.log("initHandler");
|
||||||
|
if (!appStore.hasToken) return;
|
||||||
loadRecentConversation();
|
loadRecentConversation();
|
||||||
loadConversationMsgList();
|
///loadConversationMsgList();
|
||||||
initWebSocket();
|
initWebSocket();
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -368,6 +381,7 @@ watch(
|
|||||||
() => appStore.hasToken,
|
() => appStore.hasToken,
|
||||||
(newValue) => {
|
(newValue) => {
|
||||||
if (newValue) {
|
if (newValue) {
|
||||||
|
console.log("token存在,初始化数据");
|
||||||
initHandler();
|
initHandler();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -380,7 +394,7 @@ onMounted(() => {
|
|||||||
initTypewriterManager();
|
initTypewriterManager();
|
||||||
|
|
||||||
// 有token时,加载最近会话、最近消息、初始化socket
|
// 有token时,加载最近会话、最近消息、初始化socket
|
||||||
checkToken().then(() => initHandler());
|
initHandler();
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error("页面初始化错误:", error);
|
console.error("页面初始化错误:", error);
|
||||||
}
|
}
|
||||||
@ -441,12 +455,14 @@ 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;
|
||||||
// 停止打字机效果
|
// 停止打字机效果
|
||||||
@ -457,6 +473,7 @@ const initWebSocket = () => {
|
|||||||
|
|
||||||
// 错误回调
|
// 错误回调
|
||||||
onError: (error) => {
|
onError: (error) => {
|
||||||
|
webSocketConnectStatus = false;
|
||||||
isSessionActive.value = false;
|
isSessionActive.value = false;
|
||||||
console.error("WebSocket错误:", error);
|
console.error("WebSocket错误:", error);
|
||||||
},
|
},
|
||||||
@ -474,9 +491,14 @@ const initWebSocket = () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
// 初始化连接
|
// 初始化连接
|
||||||
webSocketManager.connect().catch((error) => {
|
webSocketManager
|
||||||
console.error("WebSocket连接失败:", error);
|
.connect()
|
||||||
});
|
.then(() => {
|
||||||
|
webSocketConnectStatus = true;
|
||||||
|
})
|
||||||
|
.catch((error) => {
|
||||||
|
console.error("WebSocket连接失败:", error);
|
||||||
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
// 处理WebSocket消息
|
// 处理WebSocket消息
|
||||||
@ -599,6 +621,22 @@ 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: "请等待当前回复完成",
|
||||||
|
|||||||
@ -7,8 +7,6 @@
|
|||||||
:key="index"
|
:key="index"
|
||||||
>
|
>
|
||||||
<view class="more-tips-item-title" @click="sendReply(item)">
|
<view class="more-tips-item-title" @click="sendReply(item)">
|
||||||
<Interceptor />
|
|
||||||
|
|
||||||
{{ item }}
|
{{ item }}
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
@ -18,9 +16,6 @@
|
|||||||
|
|
||||||
<script setup>
|
<script setup>
|
||||||
import { defineProps } from "vue";
|
import { defineProps } from "vue";
|
||||||
import { checkToken } from "@/hooks/useGoLogin";
|
|
||||||
import Interceptor from "@/components/Interceptor/index.vue";
|
|
||||||
|
|
||||||
const emits = defineEmits(["replySent"]);
|
const emits = defineEmits(["replySent"]);
|
||||||
|
|
||||||
defineProps({
|
defineProps({
|
||||||
@ -39,8 +34,7 @@ defineProps({
|
|||||||
});
|
});
|
||||||
|
|
||||||
const sendReply = (text) => {
|
const sendReply = (text) => {
|
||||||
// 向父组件传递数据
|
emits("replySent", text);
|
||||||
checkToken().then(() => emits("replySent", text));
|
|
||||||
};
|
};
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
|||||||
@ -7,8 +7,6 @@
|
|||||||
:key="index"
|
:key="index"
|
||||||
@click="sendReply(item)"
|
@click="sendReply(item)"
|
||||||
>
|
>
|
||||||
<Interceptor />
|
|
||||||
|
|
||||||
<image
|
<image
|
||||||
class="quick-access-item-bg"
|
class="quick-access-item-bg"
|
||||||
src="/static/quick/quick_icon_bg.png"
|
src="/static/quick/quick_icon_bg.png"
|
||||||
@ -26,15 +24,12 @@
|
|||||||
|
|
||||||
<script setup>
|
<script setup>
|
||||||
import { onMounted, ref } from "vue";
|
import { onMounted, ref } from "vue";
|
||||||
import { checkToken } from "@/hooks/useGoLogin";
|
|
||||||
import Interceptor from "@/components/Interceptor/index.vue";
|
|
||||||
|
|
||||||
const itemList = ref([]);
|
const itemList = ref([]);
|
||||||
|
|
||||||
const emits = defineEmits(["replySent"]);
|
const emits = defineEmits(["replySent"]);
|
||||||
|
|
||||||
const sendReply = (item) => {
|
const sendReply = (item) => {
|
||||||
checkToken().then(() => emits("replySent", item)); // 向父组件传递数据
|
emits("replySent", item); // 向父组件传递数据
|
||||||
};
|
};
|
||||||
|
|
||||||
onMounted(() => {
|
onMounted(() => {
|
||||||
|
|||||||
@ -11,18 +11,30 @@
|
|||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script setup>
|
<script setup>
|
||||||
import { defineEmits, ref } from "vue";
|
import { ref } from "vue";
|
||||||
import DrawerHome from "@/pages/drawer/DrawerHome.vue";
|
import DrawerHome from "@/pages/drawer/DrawerHome.vue";
|
||||||
|
import { goLogin } from "@/hooks/useGoLogin";
|
||||||
|
import { useAppStore } from "@/store";
|
||||||
|
const appStore = useAppStore();
|
||||||
const showLeft = ref(false);
|
const showLeft = ref(false);
|
||||||
|
|
||||||
// 打开窗口
|
// 打开窗口
|
||||||
const showDrawer = (e) => {
|
const showDrawer = (e) => {
|
||||||
|
if (!appStore.hasToken) {
|
||||||
|
console.log("没有token,跳转到登录页");
|
||||||
|
goLogin();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
showLeft.value.open();
|
showLeft.value.open();
|
||||||
|
// 发送抽屉显示事件
|
||||||
|
uni.$emit("drawerShow");
|
||||||
};
|
};
|
||||||
// 关闭窗口
|
// 关闭窗口
|
||||||
const closeDrawer = (e) => {
|
const closeDrawer = (e) => {
|
||||||
showLeft.value.close();
|
showLeft.value.close();
|
||||||
|
// 发送抽屉隐藏事件
|
||||||
|
uni.$emit("drawerHide");
|
||||||
};
|
};
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
|||||||
@ -11,18 +11,41 @@
|
|||||||
<text class="title">我的</text>
|
<text class="title">我的</text>
|
||||||
</view>
|
</view>
|
||||||
|
|
||||||
<MineSetting />
|
<MineSetting v-if="isDrawerVisible" />
|
||||||
</view>
|
</view>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script setup>
|
<script setup>
|
||||||
import MineSetting from "./MineSetting.vue";
|
import MineSetting from "./MineSetting.vue";
|
||||||
import { defineEmits } from "vue";
|
import { defineEmits, ref, onMounted, onUnmounted } from "vue";
|
||||||
const emits = defineEmits(["closeDrawer"]);
|
const emits = defineEmits(["closeDrawer"]);
|
||||||
|
|
||||||
|
const isDrawerVisible = ref(false);
|
||||||
|
|
||||||
const closeDrawer = () => {
|
const closeDrawer = () => {
|
||||||
|
isDrawerVisible.value = false;
|
||||||
emits("closeDrawer");
|
emits("closeDrawer");
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// 监听抽屉显示事件
|
||||||
|
const handleDrawerShow = () => {
|
||||||
|
isDrawerVisible.value = true;
|
||||||
|
};
|
||||||
|
|
||||||
|
// 监听抽屉隐藏事件
|
||||||
|
const handleDrawerHide = () => {
|
||||||
|
isDrawerVisible.value = false;
|
||||||
|
};
|
||||||
|
|
||||||
|
onMounted(() => {
|
||||||
|
uni.$on("drawerShow", handleDrawerShow);
|
||||||
|
uni.$on("drawerHide", handleDrawerHide);
|
||||||
|
});
|
||||||
|
|
||||||
|
onUnmounted(() => {
|
||||||
|
uni.$off("drawerShow", handleDrawerShow);
|
||||||
|
uni.$off("drawerHide", handleDrawerHide);
|
||||||
|
});
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style lang="scss" scoped>
|
<style lang="scss" scoped>
|
||||||
|
|||||||
@ -38,7 +38,6 @@
|
|||||||
<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({
|
||||||
@ -60,11 +59,9 @@ 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 () => {
|
||||||
|
|||||||
@ -39,8 +39,18 @@
|
|||||||
}}</view>
|
}}</view>
|
||||||
<view class="goods-price">
|
<view class="goods-price">
|
||||||
<text class="currency">¥</text>
|
<text class="currency">¥</text>
|
||||||
<text class="price">
|
<template v-if="goodsData.commodityTypeCode === '0'">
|
||||||
{{ goodsData.specificationPrice || 399 }}
|
<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>
|
</text>
|
||||||
</view>
|
</view>
|
||||||
<view
|
<view
|
||||||
@ -95,7 +105,11 @@
|
|||||||
|
|
||||||
<!-- 总价区域 -->
|
<!-- 总价区域 -->
|
||||||
<SumCard
|
<SumCard
|
||||||
:referencePrice="goodsData.specificationPrice"
|
:referencePrice="
|
||||||
|
goodsData.commodityTypeCode === '0'
|
||||||
|
? goodsData.calculatedTotalPrice
|
||||||
|
: goodsData.specificationPrice
|
||||||
|
"
|
||||||
:discount="totalPrice"
|
:discount="totalPrice"
|
||||||
/>
|
/>
|
||||||
</view>
|
</view>
|
||||||
@ -180,7 +194,10 @@ const isDeleting = ref(false); // 标志位,防止删除时watch冲突
|
|||||||
|
|
||||||
// 计算属性
|
// 计算属性
|
||||||
const totalPrice = computed(() => {
|
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);
|
return (price * quantity.value).toFixed(0);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@ -92,6 +92,13 @@
|
|||||||
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 {
|
||||||
|
|||||||
@ -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">{{ goodsData.specificationPrice || 399 }}</text>
|
<text class="price">{{ calculatedTotalPrice }}</text>
|
||||||
</view>
|
</view>
|
||||||
<view class="buy-button" @click="showConfirmPopup">立即抢购</view>
|
<view class="buy-button" @click="showConfirmPopup">立即抢购</view>
|
||||||
</view>
|
</view>
|
||||||
@ -103,20 +103,34 @@ 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);
|
||||||
@ -272,6 +286,63 @@ 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;
|
||||||
};
|
};
|
||||||
|
|||||||
@ -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 { GetWxMiniProgramUrlParam } from "@/utils/UrlParams";
|
import { getUrlParams } 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 = GetWxMiniProgramUrlParam(qrUrl);
|
const params = getUrlParams(qrUrl);
|
||||||
appStore.setSceneId(params.sceneId);
|
appStore.setSceneId(params.sceneId);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|||||||
@ -1,5 +1,12 @@
|
|||||||
<template>
|
<template>
|
||||||
<view class="login-wrapper" :style="{ backgroundImage: `url(${loginBg})` }">
|
<view class="login-wrapper" :style="{ backgroundImage: `url(${loginBg})` }">
|
||||||
|
<!-- 返回按钮 -->
|
||||||
|
<view class="back-btn" @click="goBack">
|
||||||
|
<uni-icons fontFamily="znicons" size="24" color="#333">{{
|
||||||
|
zniconsMap["zn-nav-arrow-left"]
|
||||||
|
}}</uni-icons>
|
||||||
|
</view>
|
||||||
|
|
||||||
<!-- 头部内容 -->
|
<!-- 头部内容 -->
|
||||||
<view class="login-header">
|
<view class="login-header">
|
||||||
<!-- 卡通形象 -->
|
<!-- 卡通形象 -->
|
||||||
@ -31,7 +38,7 @@
|
|||||||
class="login-btn"
|
class="login-btn"
|
||||||
open-type="getPhoneNumber"
|
open-type="getPhoneNumber"
|
||||||
type="primary"
|
type="primary"
|
||||||
@getphonenumber="onLogin"
|
@getphonenumber="getPhoneNumber"
|
||||||
>
|
>
|
||||||
微信一键登录
|
微信一键登录
|
||||||
</button>
|
</button>
|
||||||
@ -66,15 +73,15 @@
|
|||||||
|
|
||||||
<script setup>
|
<script setup>
|
||||||
import { ref, computed } from "vue";
|
import { ref, computed } from "vue";
|
||||||
import { loginAuth, bindPhone, checkPhone } from "@/manager/LoginManager";
|
|
||||||
import {
|
import {
|
||||||
getServiceAgreement,
|
getServiceAgreement,
|
||||||
getPrivacyAgreement,
|
getPrivacyAgreement,
|
||||||
} from "@/request/api/LoginApi";
|
} from "@/request/api/LoginApi";
|
||||||
import { goHome } from "@/hooks/useGoHome";
|
import { onLogin, goBack } from "@/hooks/useGoLogin";
|
||||||
import loginBg from "./images/bg.png";
|
import loginBg from "./images/bg.png";
|
||||||
import CheckBox from "@/components/CheckBox/index.vue";
|
import CheckBox from "@/components/CheckBox/index.vue";
|
||||||
import AgreePopup from "./components/AgreePopup/index.vue";
|
import AgreePopup from "./components/AgreePopup/index.vue";
|
||||||
|
import { zniconsMap } from "@/static/fonts/znicons.js";
|
||||||
|
|
||||||
const isAgree = ref(false);
|
const isAgree = ref(false);
|
||||||
const visible = ref(false);
|
const visible = ref(false);
|
||||||
@ -94,30 +101,20 @@ const handleAgreeAndGetPhone = () => {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
const onLogin = (e) => {
|
const getPhoneNumber = (e) => {
|
||||||
const { code } = e.detail;
|
onLogin(e)
|
||||||
console.info("onLogin code: ", code);
|
.then(() => {
|
||||||
|
uni.showToast({
|
||||||
loginAuth()
|
title: "登录成功",
|
||||||
.then(async () => {
|
icon: "success",
|
||||||
// 检测是否绑定手机号,已绑定则直接跳转首页,未绑定则获取手机号并绑定
|
|
||||||
const res = await checkPhone();
|
|
||||||
|
|
||||||
if (res.data) {
|
|
||||||
return goHome();
|
|
||||||
}
|
|
||||||
|
|
||||||
const { data } = await bindPhone({
|
|
||||||
wechatPhoneCode: code,
|
|
||||||
clientId: "2",
|
|
||||||
});
|
});
|
||||||
|
goBack();
|
||||||
if (data) {
|
|
||||||
goHome();
|
|
||||||
}
|
|
||||||
})
|
})
|
||||||
.catch((err) => {
|
.catch(() => {
|
||||||
console.error("登录失败", err);
|
uni.showToast({
|
||||||
|
title: "登录失败",
|
||||||
|
icon: "none",
|
||||||
|
});
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -155,4 +152,8 @@ getPrivacyAgreementData();
|
|||||||
|
|
||||||
<style lang="scss" scoped>
|
<style lang="scss" scoped>
|
||||||
@import "./styles/index.scss";
|
@import "./styles/index.scss";
|
||||||
|
@font-face {
|
||||||
|
font-family: znicons;
|
||||||
|
src: url("@/static/fonts/znicons.ttf");
|
||||||
|
}
|
||||||
</style>
|
</style>
|
||||||
|
|||||||
@ -1,63 +1,75 @@
|
|||||||
.login-wrapper {
|
.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;
|
display: flex;
|
||||||
flex-direction: column;
|
|
||||||
align-items: center;
|
align-items: center;
|
||||||
box-sizing: border-box;
|
justify-content: center;
|
||||||
font-family: PingFang SC, PingFang SC;
|
z-index: 10;
|
||||||
height: 100vh;
|
}
|
||||||
padding-top: 168px;
|
|
||||||
position: relative;
|
|
||||||
background-position: 0 0;
|
|
||||||
background-size: 100% 100%;
|
|
||||||
background-repeat: no-repeat;
|
|
||||||
|
|
||||||
.login-header {
|
.login-header {
|
||||||
text-align: center;
|
text-align: center;
|
||||||
max-height: 223px;
|
max-height: 223px;
|
||||||
|
|
||||||
.login-avatar {
|
.login-avatar {
|
||||||
width: 150px;
|
width: 150px;
|
||||||
display: block;
|
display: block;
|
||||||
}
|
|
||||||
|
|
||||||
.login-title {
|
|
||||||
width: 137px;
|
|
||||||
height: 32px;
|
|
||||||
margin: 6px auto;
|
|
||||||
}
|
|
||||||
|
|
||||||
.login-desc {
|
|
||||||
font-size: 12px;
|
|
||||||
color: #1e4c69;
|
|
||||||
line-height: 24px;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.login-btn-area {
|
.login-title {
|
||||||
margin-top: 46px;
|
width: 137px;
|
||||||
width: 297px;
|
height: 32px;
|
||||||
|
margin: 6px auto;
|
||||||
.login-btn {
|
|
||||||
background: linear-gradient(246deg, #22a7ff 0%, #2567ff 100%);
|
|
||||||
width: 100%;
|
|
||||||
border-radius: 50px;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.login-agreement {
|
.login-desc {
|
||||||
margin-top: 20px;
|
font-size: 12px;
|
||||||
display: flex;
|
color: #1e4c69;
|
||||||
align-items: center;
|
line-height: 24px;
|
||||||
|
|
||||||
.login-agreement-text {
|
|
||||||
font-size: 14px;
|
|
||||||
color: #666;
|
|
||||||
}
|
|
||||||
|
|
||||||
.login-agreement-link {
|
|
||||||
font-size: 14px;
|
|
||||||
color: #007aff;
|
|
||||||
margin: 0 5px;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.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"
|
v-for="(item, index) in commodityDTO.commodityList"
|
||||||
:key="`${item.commodityId}-${index}`"
|
: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> -->
|
<!-- <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>
|
||||||
</Interceptor>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
@ -47,7 +47,6 @@
|
|||||||
<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: {
|
||||||
|
|||||||
@ -7,7 +7,6 @@
|
|||||||
:key="`${item.commodityId}-${index}`"
|
:key="`${item.commodityId}-${index}`"
|
||||||
>
|
>
|
||||||
<view class="mk-card-item" @click="placeOrderHandle(item)">
|
<view class="mk-card-item" @click="placeOrderHandle(item)">
|
||||||
<Interceptor />
|
|
||||||
<image
|
<image
|
||||||
class="card-img"
|
class="card-img"
|
||||||
:src="item.commodityPhoto"
|
:src="item.commodityPhoto"
|
||||||
@ -51,7 +50,6 @@
|
|||||||
import { defineProps } from "vue";
|
import { defineProps } from "vue";
|
||||||
import { checkToken } from "@/hooks/useGoLogin";
|
import { checkToken } from "@/hooks/useGoLogin";
|
||||||
import ModuleTitle from "@/components/ModuleTitle/index.vue";
|
import ModuleTitle from "@/components/ModuleTitle/index.vue";
|
||||||
import Interceptor from "@/components/Interceptor/index.vue";
|
|
||||||
|
|
||||||
const props = defineProps({
|
const props = defineProps({
|
||||||
commodityList: {
|
commodityList: {
|
||||||
|
|||||||
@ -7,8 +7,6 @@
|
|||||||
:key="index"
|
:key="index"
|
||||||
>
|
>
|
||||||
<view class="mk-card-item" @click="sendReply(item)">
|
<view class="mk-card-item" @click="sendReply(item)">
|
||||||
<Interceptor />
|
|
||||||
|
|
||||||
<image
|
<image
|
||||||
class="card-img"
|
class="card-img"
|
||||||
:src="item.coverPhoto"
|
:src="item.coverPhoto"
|
||||||
@ -24,8 +22,6 @@
|
|||||||
<script setup>
|
<script setup>
|
||||||
import { RECOMMEND_POSTS_TITLE } from "@/constant/constant";
|
import { RECOMMEND_POSTS_TITLE } from "@/constant/constant";
|
||||||
import { defineProps } from "vue";
|
import { defineProps } from "vue";
|
||||||
import { checkToken } from "@/hooks/useGoLogin";
|
|
||||||
import Interceptor from "@/components/Interceptor/index.vue";
|
|
||||||
import ModuleTitle from "@/components/ModuleTitle/index.vue";
|
import ModuleTitle from "@/components/ModuleTitle/index.vue";
|
||||||
|
|
||||||
const props = defineProps({
|
const props = defineProps({
|
||||||
@ -36,10 +32,8 @@ const props = defineProps({
|
|||||||
});
|
});
|
||||||
|
|
||||||
const sendReply = (item) => {
|
const sendReply = (item) => {
|
||||||
checkToken().then(() => {
|
const topic = item.userInputContent || item.topic.replace(/^#/, "");
|
||||||
const topic = item.userInputContent || item.topic.replace(/^#/, "");
|
uni.$emit(RECOMMEND_POSTS_TITLE, topic);
|
||||||
uni.$emit(RECOMMEND_POSTS_TITLE, topic);
|
|
||||||
});
|
|
||||||
};
|
};
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
|||||||
@ -7,7 +7,6 @@
|
|||||||
:key="index"
|
:key="index"
|
||||||
>
|
>
|
||||||
<view class="mk-card-item" @click="sendReply(item)">
|
<view class="mk-card-item" @click="sendReply(item)">
|
||||||
<Interceptor />
|
|
||||||
<image class="card-img" :src="item.coverPhoto" mode="aspectFill" />
|
<image class="card-img" :src="item.coverPhoto" mode="aspectFill" />
|
||||||
|
|
||||||
<view class="overlay-gradient">
|
<view class="overlay-gradient">
|
||||||
@ -22,8 +21,6 @@
|
|||||||
<script setup>
|
<script setup>
|
||||||
import { defineProps } from "vue";
|
import { defineProps } from "vue";
|
||||||
import { RECOMMEND_POSTS_TITLE } from "@/constant/constant";
|
import { RECOMMEND_POSTS_TITLE } from "@/constant/constant";
|
||||||
import { checkToken } from "@/hooks/useGoLogin";
|
|
||||||
import Interceptor from "@/components/Interceptor/index.vue";
|
|
||||||
import ModuleTitle from "@/components/ModuleTitle/index.vue";
|
import ModuleTitle from "@/components/ModuleTitle/index.vue";
|
||||||
|
|
||||||
const props = defineProps({
|
const props = defineProps({
|
||||||
@ -34,10 +31,8 @@ const props = defineProps({
|
|||||||
});
|
});
|
||||||
|
|
||||||
const sendReply = (item) => {
|
const sendReply = (item) => {
|
||||||
checkToken().then(() => {
|
const topic = item.userInputContent || item.topic.replace(/^#/, "");
|
||||||
const topic = item.userInputContent || item.topic.replace(/^#/, "");
|
uni.$emit(RECOMMEND_POSTS_TITLE, topic);
|
||||||
uni.$emit(RECOMMEND_POSTS_TITLE, topic);
|
|
||||||
});
|
|
||||||
};
|
};
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
|||||||
@ -7,7 +7,11 @@
|
|||||||
<view class="order-title">
|
<view class="order-title">
|
||||||
{{ orderData.workOrderTypeName || orderData.commodityName }}
|
{{ orderData.workOrderTypeName || orderData.commodityName }}
|
||||||
</view>
|
</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>
|
||||||
<view
|
<view
|
||||||
v-if="orderData.status !== 'pending'"
|
v-if="orderData.status !== 'pending'"
|
||||||
@ -107,6 +111,7 @@ const getStatusText = (status) => {
|
|||||||
|
|
||||||
// 处理卡片点击
|
// 处理卡片点击
|
||||||
const handleCardClick = () => {
|
const handleCardClick = () => {
|
||||||
|
if (props.orderData.orderType === undefined) return;
|
||||||
emit("click", props.orderData);
|
emit("click", props.orderData);
|
||||||
};
|
};
|
||||||
</script>
|
</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";
|
import { goLogin } from "@/hooks/useGoLogin";
|
||||||
|
|
||||||
/// 请求流式数据的API
|
/// 请求流式数据的API
|
||||||
const API = '/agent/assistant/chat';
|
const API = "/agent/assistant/chat";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取AI聊天流式信息(仅微信小程序支持)
|
* 获取AI聊天流式信息(仅微信小程序支持)
|
||||||
@ -15,8 +15,8 @@ const API = '/agent/assistant/chat';
|
|||||||
let requestTask = null;
|
let requestTask = null;
|
||||||
let isAborted = false;
|
let isAborted = false;
|
||||||
let currentPromiseReject = null;
|
let currentPromiseReject = null;
|
||||||
let lastRequestId = null; // 记录上一次请求ID
|
let lastRequestId = null; // 记录上一次请求ID
|
||||||
let activeRequestId = null; // 记录当前活动请求ID
|
let activeRequestId = null; // 记录当前活动请求ID
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 终止的请求
|
* 终止的请求
|
||||||
@ -31,7 +31,7 @@ const stopAbortTask = () => {
|
|||||||
activeRequestId = null;
|
activeRequestId = null;
|
||||||
|
|
||||||
if (currentPromiseReject) {
|
if (currentPromiseReject) {
|
||||||
currentPromiseReject(new Error('请求已被用户终止'));
|
currentPromiseReject(new Error("请求已被用户终止"));
|
||||||
currentPromiseReject = null;
|
currentPromiseReject = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -39,16 +39,16 @@ 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
|
||||||
|
|
||||||
// 重置状态
|
// 重置状态
|
||||||
@ -80,28 +80,30 @@ const agentChatStream = (params, onChunk) => {
|
|||||||
currentPromiseReject = reject;
|
currentPromiseReject = reject;
|
||||||
|
|
||||||
// 更新请求ID追踪
|
// 更新请求ID追踪
|
||||||
lastRequestId = activeRequestId; // 保存上一次请求ID
|
lastRequestId = activeRequestId; // 保存上一次请求ID
|
||||||
activeRequestId = requestId; // 设置新的活动请求ID
|
activeRequestId = requestId; // 设置新的活动请求ID
|
||||||
|
|
||||||
console.log(`🚀 发送请求 [${requestId}], 上一次请求ID [${lastRequestId}]`);
|
console.log(`🚀 发送请求 [${requestId}], 上一次请求ID [${lastRequestId}]`);
|
||||||
|
|
||||||
// 检查数据块是否来自已终止的请求
|
// 检查数据块是否来自已终止的请求
|
||||||
const isStaleData = (dataRequestId) => {
|
const isStaleData = (dataRequestId) => {
|
||||||
return dataRequestId === lastRequestId || dataRequestId !== activeRequestId;
|
return (
|
||||||
|
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}] 成功`);
|
||||||
@ -122,30 +124,39 @@ const agentChatStream = (params, onChunk) => {
|
|||||||
// 使用 requestId 来验证请求有效性
|
// 使用 requestId 来验证请求有效性
|
||||||
if (!isAborted && activeRequestId === requestId) {
|
if (!isAborted && activeRequestId === requestId) {
|
||||||
if (res.statusCode !== 200) {
|
if (res.statusCode !== 200) {
|
||||||
console.log(`❌ 请求 [${requestId}] 完成但状态错误,状态:`, res.statusCode);
|
console.log(
|
||||||
if(res.statusCode === 424) {
|
`❌ 请求 [${requestId}] 完成但状态错误,状态:`,
|
||||||
uni.setStorageSync('token', '');
|
res.statusCode
|
||||||
|
);
|
||||||
|
if (res.statusCode === 424) {
|
||||||
|
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(`❌ 请求 [${requestId}] ${isAborted ? '已终止' : '已过期'},忽略complete回调`);
|
console.log(
|
||||||
|
`❌ 请求 [${requestId}] ${
|
||||||
|
isAborted ? "已终止" : "已过期"
|
||||||
|
},忽略complete回调`
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
requestTask.onHeadersReceived(res => {
|
requestTask.onHeadersReceived((res) => {
|
||||||
// 使用 requestId 验证请求有效性
|
// 使用 requestId 验证请求有效性
|
||||||
if (isAborted || activeRequestId !== requestId) {
|
if (isAborted || activeRequestId !== requestId) {
|
||||||
console.log(`🚫 Headers [${requestId}] ${isAborted ? '已终止' : '已过期'},忽略`);
|
console.log(
|
||||||
|
`🚫 Headers [${requestId}] ${isAborted ? "已终止" : "已过期"},忽略`
|
||||||
|
);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -158,7 +169,7 @@ const agentChatStream = (params, onChunk) => {
|
|||||||
onChunk({
|
onChunk({
|
||||||
error: true,
|
error: true,
|
||||||
message: `服务器错误(${status})`,
|
message: `服务器错误(${status})`,
|
||||||
detail: res
|
detail: res,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
// 终止异常请求
|
// 终止异常请求
|
||||||
@ -168,7 +179,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}] 已终止或过期,忽略`);
|
||||||
@ -176,15 +187,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("📦 onChunkReceived,res:", data)
|
console.log("📦 onChunkReceived,res:", data);
|
||||||
|
|
||||||
// 再次验证请求有效性
|
// 再次验证请求有效性
|
||||||
if (isAborted || activeRequestId !== requestId) {
|
if (isAborted || activeRequestId !== requestId) {
|
||||||
@ -193,7 +204,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);
|
||||||
}
|
}
|
||||||
@ -201,14 +212,16 @@ const agentChatStream = (params, onChunk) => {
|
|||||||
});
|
});
|
||||||
// #endif
|
// #endif
|
||||||
});
|
});
|
||||||
}
|
};
|
||||||
|
|
||||||
// window.atob兼容性处理
|
// window.atob兼容性处理
|
||||||
const weAtob = (string) => {
|
const weAtob = (string) => {
|
||||||
const b64re = /^(?:[A-Za-z\d+/]{4})*?(?:[A-Za-z\d+/]{2}(?:==)?|[A-Za-z\d+/]{3}=?)?$/;
|
const b64re =
|
||||||
const b64 = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=';
|
/^(?:[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 编码
|
// 验证 Base64 编码
|
||||||
if (!b64re.test(string)) {
|
if (!b64re.test(string)) {
|
||||||
throw new TypeError(
|
throw new TypeError(
|
||||||
@ -218,15 +231,15 @@ 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;
|
||||||
|
|
||||||
for (; i < string.length;) {
|
for (; i < string.length; ) {
|
||||||
bitmap =
|
bitmap =
|
||||||
(b64.indexOf(string.charAt(i++)) << 18) |
|
(b64.indexOf(string.charAt(i++)) << 18) |
|
||||||
(b64.indexOf(string.charAt(i++)) << 12) |
|
(b64.indexOf(string.charAt(i++)) << 12) |
|
||||||
@ -236,10 +249,7 @@ 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(
|
result += String.fromCharCode((bitmap >> 16) & 255, (bitmap >> 8) & 255);
|
||||||
(bitmap >> 16) & 255,
|
|
||||||
(bitmap >> 8) & 255
|
|
||||||
);
|
|
||||||
} else {
|
} else {
|
||||||
result += String.fromCharCode(
|
result += String.fromCharCode(
|
||||||
(bitmap >> 16) & 255,
|
(bitmap >> 16) & 255,
|
||||||
@ -251,7 +261,6 @@ const weAtob = (string) => {
|
|||||||
return result;
|
return result;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
// 解析SSE分段数据
|
// 解析SSE分段数据
|
||||||
const parseSSEChunk = (raw) => {
|
const parseSSEChunk = (raw) => {
|
||||||
const results = [];
|
const results = [];
|
||||||
@ -264,7 +273,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());
|
||||||
}
|
}
|
||||||
@ -272,18 +281,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 };
|
||||||
|
|||||||
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 = {
|
const defaultConfig = {
|
||||||
header: {
|
header: {
|
||||||
@ -50,10 +51,16 @@ function request(url, args = {}, method = "POST", customConfig = {}) {
|
|||||||
success: (res) => {
|
success: (res) => {
|
||||||
console.log("请求响应:" + JSON.stringify(res));
|
console.log("请求响应:" + JSON.stringify(res));
|
||||||
resolve(res.data);
|
resolve(res.data);
|
||||||
// if (res.statusCode && res.statusCode === 424) {
|
if (res.statusCode && res.statusCode === 424) {
|
||||||
// uni.setStorageSync("token", "");
|
console.log("424错误,重新登录");
|
||||||
// goLogin();
|
loginAuth().then(async () => {
|
||||||
// }
|
// 检测是否绑定手机号
|
||||||
|
const res = await checkPhone();
|
||||||
|
if (!res.data) {
|
||||||
|
goLogin();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
},
|
},
|
||||||
fail: (err) => {
|
fail: (err) => {
|
||||||
console.error("请求失败:", err);
|
console.error("请求失败:", err);
|
||||||
|
|||||||
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 = {};
|
let theRequest = {};
|
||||||
if(url.indexOf("#") != -1){
|
if(url.indexOf("#") != -1){
|
||||||
const str=url.split("#")[1];
|
const str=url.split("#")[1];
|
||||||
@ -15,3 +15,23 @@ export function GetWxMiniProgramUrlParam(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('&') : '';
|
||||||
|
}
|
||||||
|
|||||||
@ -13,7 +13,12 @@ export class IdUtils {
|
|||||||
* @returns {string} 消息ID
|
* @returns {string} 消息ID
|
||||||
*/
|
*/
|
||||||
static generateMessageId() {
|
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