Compare commits

...

13 Commits

Author SHA1 Message Date
f585c83554 feat: 添加车牌组件 2025-09-18 20:47:39 +08:00
fd5902ca05 feat: 添加车牌的搭建 2025-09-18 20:44:29 +08:00
8af82e54ef feat: 工单的调整 2025-09-16 21:19:29 +08:00
cead891e69 feat: 抽屉中的数据加载问题优化 2025-09-16 21:07:54 +08:00
69fe1b80c8 feat: 订单调起前登录检验 2025-09-16 20:54:20 +08:00
6443b67d15 feat: 商品详情的价格的计算处理 2025-09-16 20:39:17 +08:00
zoujing
8d0c93206b feat: 配置clientId 2025-09-16 17:04:50 +08:00
zoujing
191d2394c5 feat: 发消息时的状态处理 2025-09-16 15:53:06 +08:00
zoujing
5849411e89 feat: WebSocket链接状态管理 2025-09-16 15:45:03 +08:00
zoujing
3e34f68406 feat: 样式调整 2025-09-16 10:30:19 +08:00
fc63bbc994 feat: 调整优化登录的逻辑 2025-09-15 22:52:44 +08:00
66c256cefd feat: 生成的唯一消息id 优化 2025-09-15 20:00:28 +08:00
1038dd3180 feat: 环境的配置 2025-09-15 19:01:22 +08:00
40 changed files with 721 additions and 286 deletions

View File

@ -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

View File

@ -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

View File

@ -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

Binary file not shown.

After

Width:  |  Height:  |  Size: 48 KiB

View 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>

View 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;
}
}
}

View File

@ -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));
// 10
return days === 0 ? 1 : days;
};
// visibleuni-popup
@ -441,4 +475,4 @@ onBeforeUnmount(() => {
<style lang="scss" scoped>
//
@import "./styles/index.scss";
</style>
</style>

View File

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

View File

@ -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;

View File

@ -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();
});
};

View File

@ -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 {

View File

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

View File

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

View File

@ -1,6 +1,5 @@
{
"pages": [
//pageshttps://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": {}
}

View File

@ -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; //
}
}

View File

@ -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();
}
});
});
};
//

View File

@ -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;
// IDmessageId
@ -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();
// tokensocket
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: "请等待当前回复完成",

View File

@ -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>

View File

@ -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(() => {

View File

@ -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>

View File

@ -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>

View File

@ -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 () => {

View File

@ -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);
});

View File

@ -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 {

View File

@ -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;
};

View File

@ -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);
}
};

View File

@ -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>

View File

@ -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;
}
}
}

View File

@ -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: {

View File

@ -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: {

View File

@ -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>

View File

@ -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>

View File

@ -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
View 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>

View File

@ -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("📦 onChunkReceivedres:", data)
console.log("📦 onChunkReceivedres:", 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
View 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;

View File

@ -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
View 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),
});
}

View File

@ -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('&') : '';
}

View File

@ -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;
}
}