5 Commits

Author SHA1 Message Date
duanshuwen
de272b1160 feat: 修改登录界面文案 2025-11-15 10:17:12 +08:00
duanshuwen
47d1c5ab6f feat: 服务地址动态获取 2025-11-13 21:22:37 +08:00
duanshuwen
1028e20d42 feat: 服务接口地址动态获取 2025-11-13 19:43:03 +08:00
duanshuwen
48932e3851 feat: 工单服务数据回显 2025-11-13 18:40:15 +08:00
duanshuwen
9749e20971 feat: 完善首页顶部交互 2025-11-13 17:54:35 +08:00
14 changed files with 115 additions and 74 deletions

View File

@@ -1,7 +1 @@
NODE_ENV = development
# 测试
VITE_BASE_URL = https://onefeel.brother7.cn/ingress
# 测试
VITE_WSS_URL = wss://onefeel.brother7.cn/ingress/agent/ws/chat

View File

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

View File

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

View File

@@ -1,8 +1,9 @@
<script setup>
import { onLaunch, onShow, onHide } from "@dcloudio/uni-app";
import { getEvnUrl } from "@/request/api/config";
onLaunch(async () => {
console.log("App Launch");
onLaunch(() => {
getEvnUrl({ versionValue: "1.0.1" });
});
onShow(() => {

View File

@@ -27,7 +27,11 @@
class="bg-F5F7FA border-box flex flex-items-center p-12 rounded-10 font-size-14 color-171717 mb-12"
>
<text class="font-500 line-height-22 mr-20">联系电话</text>
<input placeholder="请填写联系电话" v-model="contactPhone" />
<input
placeholder="请填写联系电话"
v-model="contactPhone"
@input="handleContactPhoneInput"
/>
</view>
<view
@@ -115,19 +119,57 @@
</template>
<script setup>
import { ref, onMounted, nextTick } from "vue";
import { ref, computed, onMounted, nextTick, defineProps, watch } from "vue";
import { SCROLL_TO_BOTTOM } from "@/constant/constant";
import { createWorkOrder } from "@/request/api/WorkOrderApi";
import { updateImageFile } from "@/request/api/UpdateFile";
import { zniconsMap } from "@/static/fonts/znicons.js";
const props = defineProps({
toolCall: {
type: Object,
default: () => ({}),
},
});
const workOrderTypeId = ref("");
const roomId = ref("");
const contactPhone = ref("");
const contactText = ref("");
const contentImgUrl = ref("");
const isCallSuccess = ref(false); // 呼叫成功状态
const workOrderId = ref(0); // 工单ID
const toolResult = computed(() => {
if (props.toolCall?.toolResult) {
return JSON.parse(props.toolCall?.toolResult);
} else {
return {};
}
});
// 原始手机号(未脱敏)
const originalPhone = ref("");
// 展示与输入绑定的手机号(初始为脱敏)
const contactPhone = ref("");
// 是否用户已编辑过手机号(一旦编辑则不再脱敏)
const hasEditedPhone = ref(false);
// 手机号脱敏138****1234仅对11位数字进行处理
const maskPhone = (phone) => {
if (!phone) return "";
return String(phone).replace(/(\d{3})\d{4}(\d{4})/, "$1****$2");
};
// 监听工具返回结果,初始化原始与脱敏显示
watch(
toolResult,
(val) => {
originalPhone.value = val?.userPhone || "";
hasEditedPhone.value = false;
contactPhone.value = maskPhone(originalPhone.value);
},
{ immediate: true }
);
const contactText = computed({
get: () => toolResult.value?.callServiceContent || "",
set: (val) => (contactText.value = val),
});
// 处理图片上传
const handleChooseImage = () => {
@@ -143,6 +185,11 @@ const handleChooseImage = () => {
});
};
// 标记用户已编辑手机号
const handleContactPhoneInput = () => {
hasEditedPhone.value = true;
};
const handleDeleteImage = () => {
contentImgUrl.value = "";
};
@@ -168,7 +215,10 @@ const handleCall = async () => {
return;
}
if (!contactPhone.value.trim()) {
const phoneToSubmit = hasEditedPhone.value
? contactPhone.value
: originalPhone.value;
if (!phoneToSubmit.trim()) {
uni.showToast({ title: "请填写联系电话", icon: "none" });
return;
}
@@ -178,19 +228,22 @@ const handleCall = async () => {
return;
}
sendCreateWorkOrder();
sendCreateWorkOrder(phoneToSubmit);
};
/// 创建工单
const sendCreateWorkOrder = async () => {
const sendCreateWorkOrder = async (phoneToSubmit) => {
try {
const res = await createWorkOrder({
const params = {
workOrderTypeId: workOrderTypeId.value,
roomNo: roomId.value,
userPhone: contactPhone.value,
userPhone: phoneToSubmit,
content: contactText.value,
contentImgUrl: contentImgUrl.value,
});
};
console.log("🚀 ~ sendCreateWorkOrder ~ params:", params);
const res = await createWorkOrder(params);
if (res.code === 0) {
// 保存工单ID

View File

@@ -46,6 +46,7 @@
v-else-if="
item.toolCall.componentName === CompName.callServiceCard
"
:toolCall="item.toolCall"
/>
<Feedback
v-else-if="
@@ -132,7 +133,6 @@ import {
NOTICE_EVENT_LOGOUT,
NOTICE_EVENT_LOGIN_SUCCESS,
} from "@/constant/constant";
import { WSS_URL } from "@/request/base/baseUrl";
import { MessageRole, MessageType, CompName } from "@/model/ChatModel";
import ChatTopWelcome from "../ChatTopWelcome/index.vue";
import ChatTopNavBar from "../ChatTopNavBar/index.vue";
@@ -413,7 +413,7 @@ const initWebSocket = () => {
// 使用配置的WebSocket服务器地址
const token = uni.getStorageSync("token");
const wsUrl = `${WSS_URL}?access_token=${token}`;
const wsUrl = `${appStore.serverConfig.wssUrl}?access_token=${token}`;
// 初始化WebSocket管理器
webSocketManager = new WebSocketManager({

View File

@@ -12,10 +12,13 @@
></view>
<text
v-show="show"
class="font-size-14 font-500 color-171717 ml-10"
:class="{ 'text-animated': show }"
>沐沐</text
:class="[
'font-size-14 font-500 color-171717 ml-10',
{ 'text-animated': show },
]"
>
{{ config.name }}
</text>
</view>
<view class="w-24 h-24"></view>
@@ -34,10 +37,8 @@ const props = defineProps({
});
const show = ref(false);
const config = getCurrentConfig();
const getStyle = computed(() => {
const config = getCurrentConfig();
return {
"--ipSmallImageStep": config.ipSmallImageStep,
"--ipSmallImageHeight": config.ipSmallImageHeight,

View File

@@ -43,8 +43,7 @@
type="primary"
@click="handleAgreeAndGetPhone"
>
<uni-icons type="weixin" size="20" color="#fff"></uni-icons>
微信一键登录
手机号快捷登录
</button>
<button
@@ -54,8 +53,7 @@
open-type="getPhoneNumber"
@getphonenumber="getPhoneNumber"
>
<uni-icons type="weixin" size="20" color="#fff"></uni-icons>
微信一键登录
手机号快捷登录
</button>
<button
@@ -64,8 +62,7 @@
type="primary"
@click="handleLogin"
>
<uni-icons type="weixin" size="20" color="#fff"></uni-icons>
微信一键登录
手机号快捷登录
</button>
</view>

View File

@@ -1,5 +1,5 @@
import { BASE_URL } from "@/request/base/baseUrl";
import { goLogin } from "@/hooks/useGoLogin";
import { useAppStore } from "@/store";
/// 请求流式数据的API
const API = "/agent/assistant/chat";
@@ -93,8 +93,9 @@ const agentChatStream = (params, onChunk) => {
};
// #ifdef MP-WEIXIN
const { serverConfig } = useAppStore();
requestTask = uni.request({
url: BASE_URL + API, // 替换为你的接口地址
url: serverConfig.baseUrl + API, // 替换为你的接口地址
method: "POST",
data: params,
enableChunked: true,

View File

@@ -1,8 +1,9 @@
import { BASE_URL } from "@/request/base/baseUrl";
import { getCurrentConfig } from "@/constant/base";
import { useAppStore } from "@/store";
export const updateImageFile = (file) => {
const url = BASE_URL + "/hotelBiz/hotBizCommon/upload";
const { serverConfig } = useAppStore();
const url = serverConfig.baseUrl + "/hotelBiz/hotBizCommon/upload";
const token = uni.getStorageSync("token");
const clientId = getCurrentConfig().clientId;

17
src/request/api/config.js Normal file
View File

@@ -0,0 +1,17 @@
import request from "../base/request";
import { isProd } from "@/constant/base";
import { useAppStore } from "@/store";
// 获取服务地址
const getEvnUrl = (args) => {
if (isProd) {
const appStore = useAppStore();
request
.post("https://biz.nianxx.cn/hotelBiz/mainScene/getServiceUrl", args)
.then(({ data }) => {
appStore.setServerConfig(data);
});
}
};
export { getEvnUrl };

View File

@@ -1,19 +1 @@
import { isProd } from '@/constant/base.js';
// 测试
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,4 @@
import { goLogin } from "../../hooks/useGoLogin";
import { BASE_URL } from "./baseUrl";
import { getCurrentConfig } from "@/constant/base";
import { useAppStore } from "@/store";
import { NOTICE_EVENT_LOGOUT } from "@/constant/constant";
@@ -14,9 +13,10 @@ const defaultConfig = {
};
function request(url, args = {}, method = "POST", customConfig = {}) {
const appStore = useAppStore();
// 判断 url 是否以 http 开头
if (!/^http/.test(url)) {
url = BASE_URL + url;
url = appStore.serverConfig?.baseUrl + url;
}
// 动态获取 token
const token = uni.getStorageSync("token");
@@ -58,7 +58,6 @@ function request(url, args = {}, method = "POST", customConfig = {}) {
if (res.statusCode && res.statusCode === 424) {
console.log("424错误重新登录");
uni.setStorageSync("token", "");
const appStore = useAppStore();
appStore.setHasToken(false);
appStore.setTokenExpired(true);
uni.$emit(NOTICE_EVENT_LOGOUT);

View File

@@ -4,10 +4,14 @@ export const useAppStore = defineStore("app", {
state() {
return {
title: "",
sceneId: "", /// 分身场景id
hasToken: false, /// 是否有token
tokenExpired: false, /// token是否过期
previewImageData: [], /// 预览图片数据
sceneId: "", // 分身场景id
hasToken: false, // 是否有token
tokenExpired: false, // token是否过期
previewImageData: [], // 预览图片数据
serverConfig: {
baseUrl: "https://onefeel.brother7.cn/ingress", // 服务器基础地址
wssUrl: "wss://onefeel.brother7.cn/ingress/agent/ws/chat", // 服务器ws地址
}, // 服务器配置
};
},
getters: {},
@@ -28,6 +32,9 @@ export const useAppStore = defineStore("app", {
setPreviewImageData(data) {
this.previewImageData = data;
},
setServerConfig(data) {
this.serverConfig = data;
},
},
unistorage: true,