Compare commits
2 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
31fefeb046 | ||
|
|
785040ecc8 |
@@ -1 +1,7 @@
|
|||||||
NODE_ENV = development
|
NODE_ENV = development
|
||||||
|
|
||||||
|
# 测试
|
||||||
|
VITE_BASE_URL = https://onefeel.brother7.cn/ingress
|
||||||
|
|
||||||
|
# 测试
|
||||||
|
VITE_WSS_URL = wss://onefeel.brother7.cn/ingress/agent/ws/chat
|
||||||
|
|||||||
@@ -1 +1,7 @@
|
|||||||
NODE_ENV = production
|
NODE_ENV = production
|
||||||
|
|
||||||
|
# 生产
|
||||||
|
VITE_BASE_URL = https://biz.nianxx.cn
|
||||||
|
|
||||||
|
# 生产
|
||||||
|
VITE_WSS_URL = wss://biz.nianxx.cn/agent/ws/chat
|
||||||
@@ -1 +1,7 @@
|
|||||||
NODE_ENV = staging
|
NODE_ENV = staging
|
||||||
|
|
||||||
|
# 生产
|
||||||
|
VITE_BASE_URL = https://biz.nianxx.cn
|
||||||
|
|
||||||
|
# 生产
|
||||||
|
VITE_WSS_URL = wss://biz.nianxx.cn/agent/ws/chat
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"zhinian": {
|
"zhinian": {
|
||||||
"clientId": "6",
|
"clientId": "2",
|
||||||
"appId": "wx5e79df5996572539",
|
"appId": "wx5e79df5996572539",
|
||||||
"name": "智念",
|
"name": "智念",
|
||||||
"placeholder": "快告诉智念您在想什么~",
|
"placeholder": "快告诉智念您在想什么~",
|
||||||
|
|||||||
@@ -1,11 +1,8 @@
|
|||||||
<script setup>
|
<script setup>
|
||||||
import { onLaunch, onShow, onHide } from "@dcloudio/uni-app";
|
import { onLaunch, onShow, onHide } from "@dcloudio/uni-app";
|
||||||
import { getEvnUrl } from "@/request/api/config";
|
|
||||||
import { refreshToken } from "@/hooks/useGoLogin";
|
|
||||||
|
|
||||||
onLaunch(() => {
|
onLaunch(async () => {
|
||||||
getEvnUrl({ versionValue: "1.0.1" });
|
console.log("App Launch");
|
||||||
refreshToken();
|
|
||||||
});
|
});
|
||||||
|
|
||||||
onShow(() => {
|
onShow(() => {
|
||||||
|
|||||||
@@ -27,11 +27,7 @@
|
|||||||
class="bg-F5F7FA border-box flex flex-items-center p-12 rounded-10 font-size-14 color-171717 mb-12"
|
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>
|
<text class="font-500 line-height-22 mr-20">联系电话</text>
|
||||||
<input
|
<input placeholder="请填写联系电话" v-model="contactPhone" />
|
||||||
placeholder="请填写联系电话"
|
|
||||||
v-model="contactPhone"
|
|
||||||
@input="handleContactPhoneInput"
|
|
||||||
/>
|
|
||||||
</view>
|
</view>
|
||||||
|
|
||||||
<view
|
<view
|
||||||
@@ -119,57 +115,19 @@
|
|||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script setup>
|
<script setup>
|
||||||
import { ref, computed, onMounted, nextTick, defineProps, watch } from "vue";
|
import { ref, onMounted, nextTick } from "vue";
|
||||||
import { SCROLL_TO_BOTTOM } from "@/constant/constant";
|
import { SCROLL_TO_BOTTOM } from "@/constant/constant";
|
||||||
import { createWorkOrder } from "@/request/api/WorkOrderApi";
|
import { createWorkOrder } from "@/request/api/WorkOrderApi";
|
||||||
import { updateImageFile } from "@/request/api/UpdateFile";
|
import { updateImageFile } from "@/request/api/UpdateFile";
|
||||||
import { zniconsMap } from "@/static/fonts/znicons.js";
|
import { zniconsMap } from "@/static/fonts/znicons.js";
|
||||||
|
|
||||||
const props = defineProps({
|
|
||||||
toolCall: {
|
|
||||||
type: Object,
|
|
||||||
default: () => ({}),
|
|
||||||
},
|
|
||||||
});
|
|
||||||
const workOrderTypeId = ref("");
|
const workOrderTypeId = ref("");
|
||||||
const roomId = ref("");
|
const roomId = ref("");
|
||||||
|
const contactPhone = ref("");
|
||||||
|
const contactText = ref("");
|
||||||
const contentImgUrl = ref("");
|
const contentImgUrl = ref("");
|
||||||
const isCallSuccess = ref(false); // 呼叫成功状态
|
const isCallSuccess = ref(false); // 呼叫成功状态
|
||||||
const workOrderId = ref(0); // 工单ID
|
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 = () => {
|
const handleChooseImage = () => {
|
||||||
@@ -185,11 +143,6 @@ const handleChooseImage = () => {
|
|||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
// 标记用户已编辑手机号
|
|
||||||
const handleContactPhoneInput = () => {
|
|
||||||
hasEditedPhone.value = true;
|
|
||||||
};
|
|
||||||
|
|
||||||
const handleDeleteImage = () => {
|
const handleDeleteImage = () => {
|
||||||
contentImgUrl.value = "";
|
contentImgUrl.value = "";
|
||||||
};
|
};
|
||||||
@@ -215,10 +168,7 @@ const handleCall = async () => {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const phoneToSubmit = hasEditedPhone.value
|
if (!contactPhone.value.trim()) {
|
||||||
? contactPhone.value
|
|
||||||
: originalPhone.value;
|
|
||||||
if (!phoneToSubmit.trim()) {
|
|
||||||
uni.showToast({ title: "请填写联系电话", icon: "none" });
|
uni.showToast({ title: "请填写联系电话", icon: "none" });
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -228,22 +178,19 @@ const handleCall = async () => {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
sendCreateWorkOrder(phoneToSubmit);
|
sendCreateWorkOrder();
|
||||||
};
|
};
|
||||||
|
|
||||||
/// 创建工单
|
/// 创建工单
|
||||||
const sendCreateWorkOrder = async (phoneToSubmit) => {
|
const sendCreateWorkOrder = async () => {
|
||||||
try {
|
try {
|
||||||
const params = {
|
const res = await createWorkOrder({
|
||||||
workOrderTypeId: workOrderTypeId.value,
|
workOrderTypeId: workOrderTypeId.value,
|
||||||
roomNo: roomId.value,
|
roomNo: roomId.value,
|
||||||
userPhone: phoneToSubmit,
|
userPhone: contactPhone.value,
|
||||||
content: contactText.value,
|
content: contactText.value,
|
||||||
contentImgUrl: contentImgUrl.value,
|
contentImgUrl: contentImgUrl.value,
|
||||||
};
|
});
|
||||||
console.log("🚀 ~ sendCreateWorkOrder ~ params:", params);
|
|
||||||
|
|
||||||
const res = await createWorkOrder(params);
|
|
||||||
|
|
||||||
if (res.code === 0) {
|
if (res.code === 0) {
|
||||||
// 保存工单ID
|
// 保存工单ID
|
||||||
|
|||||||
@@ -1,7 +1,6 @@
|
|||||||
import { wxLogin } from "../request/api/LoginApi";
|
|
||||||
import { loginAuth, bindPhone, checkPhone } from "@/manager/LoginManager";
|
import { loginAuth, bindPhone, checkPhone } from "@/manager/LoginManager";
|
||||||
import { clientId } from "@/constant/base";
|
import { clientId } from "@/constant/base";
|
||||||
import { NOTICE_EVENT_LOGIN_SUCCESS } from "@/constant/constant";
|
import { useAppStore } from "@/store";
|
||||||
|
|
||||||
// 跳转登录
|
// 跳转登录
|
||||||
export const goLogin = () => uni.navigateTo({ url: "/pages/login/index" });
|
export const goLogin = () => uni.navigateTo({ url: "/pages/login/index" });
|
||||||
@@ -47,44 +46,14 @@ export const onLogin = async (e) => {
|
|||||||
|
|
||||||
// 检测token
|
// 检测token
|
||||||
export const checkToken = () => {
|
export const checkToken = () => {
|
||||||
const token = uni.getStorageSync("token");
|
|
||||||
|
|
||||||
return new Promise((resolve) => {
|
return new Promise((resolve) => {
|
||||||
if (!token) {
|
const appStore = useAppStore();
|
||||||
|
console.log("appStore.hasToken: ", appStore.hasToken);
|
||||||
|
if (!appStore.hasToken) {
|
||||||
|
console.log("没有token,跳转到登录页");
|
||||||
goLogin();
|
goLogin();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
resolve();
|
resolve();
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
// 刷新token
|
|
||||||
export const refreshToken = () => {
|
|
||||||
const token = uni.getStorageSync("token");
|
|
||||||
|
|
||||||
if (!token) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
uni.login({
|
|
||||||
provider: "weixin", //使用微信登录
|
|
||||||
success: async ({ code }) => {
|
|
||||||
console.log("refreshToken", code);
|
|
||||||
const params = {
|
|
||||||
openIdCode: [code],
|
|
||||||
grant_type: "wechat",
|
|
||||||
scope: "server",
|
|
||||||
clientId: clientId,
|
|
||||||
};
|
|
||||||
console.log("获取到的微信授权params:", JSON.stringify(params));
|
|
||||||
const response = await wxLogin(params);
|
|
||||||
|
|
||||||
if (response.access_token) {
|
|
||||||
uni.setStorageSync("token", response.access_token);
|
|
||||||
// 登录成功后,触发登录成功事件
|
|
||||||
uni.$emit(NOTICE_EVENT_LOGIN_SUCCESS);
|
|
||||||
}
|
|
||||||
},
|
|
||||||
});
|
|
||||||
};
|
|
||||||
|
|||||||
@@ -22,8 +22,12 @@ export const getWeChatAuthCode = (e) => {
|
|||||||
uni.login({
|
uni.login({
|
||||||
provider,
|
provider,
|
||||||
onlyAuthorize: true,
|
onlyAuthorize: true,
|
||||||
success: (res) => resolve(res.code),
|
success: (res) => {
|
||||||
fail: (err) => reject(err),
|
resolve(res.code);
|
||||||
|
},
|
||||||
|
fail: (err) => {
|
||||||
|
reject(err);
|
||||||
|
},
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -11,6 +11,7 @@ import { NOTICE_EVENT_LOGIN_SUCCESS } from "@/constant/constant";
|
|||||||
const loginAuth = (e) => {
|
const loginAuth = (e) => {
|
||||||
uni.setStorageSync("token", "");
|
uni.setStorageSync("token", "");
|
||||||
const appStore = useAppStore();
|
const appStore = useAppStore();
|
||||||
|
appStore.setHasToken(false);
|
||||||
|
|
||||||
return new Promise(async (resolve, reject) => {
|
return new Promise(async (resolve, reject) => {
|
||||||
const openIdCode = await getWeChatAuthCode(e);
|
const openIdCode = await getWeChatAuthCode(e);
|
||||||
@@ -27,6 +28,8 @@ const loginAuth = (e) => {
|
|||||||
|
|
||||||
if (response.access_token) {
|
if (response.access_token) {
|
||||||
uni.setStorageSync("token", response.access_token);
|
uni.setStorageSync("token", response.access_token);
|
||||||
|
const appStore = useAppStore();
|
||||||
|
appStore.setHasToken(true);
|
||||||
// 登录成功后,触发登录成功事件
|
// 登录成功后,触发登录成功事件
|
||||||
uni.$emit(NOTICE_EVENT_LOGIN_SUCCESS);
|
uni.$emit(NOTICE_EVENT_LOGIN_SUCCESS);
|
||||||
resolve();
|
resolve();
|
||||||
|
|||||||
@@ -100,6 +100,8 @@ const handleLogout = () => {
|
|||||||
success: (res) => {
|
success: (res) => {
|
||||||
if (res.confirm) {
|
if (res.confirm) {
|
||||||
uni.clearStorageSync();
|
uni.clearStorageSync();
|
||||||
|
appStore.setHasToken(false);
|
||||||
|
appStore.setTokenExpired(true);
|
||||||
emits("close");
|
emits("close");
|
||||||
uni.$emit(NOTICE_EVENT_LOGOUT);
|
uni.$emit(NOTICE_EVENT_LOGOUT);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -65,10 +65,6 @@
|
|||||||
|
|
||||||
<!-- 录音按钮 -->
|
<!-- 录音按钮 -->
|
||||||
<RecordingWaveBtn v-if="visibleWaveBtn" ref="recordingWaveBtnRef" />
|
<RecordingWaveBtn v-if="visibleWaveBtn" ref="recordingWaveBtnRef" />
|
||||||
|
|
||||||
<view class="color-99A0AE font-size-9 text-center text-gray-400">
|
|
||||||
内容由AI大模型生成,请仔细鉴别
|
|
||||||
</view>
|
|
||||||
</view>
|
</view>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
|
|||||||
@@ -46,7 +46,6 @@
|
|||||||
v-else-if="
|
v-else-if="
|
||||||
item.toolCall.componentName === CompName.callServiceCard
|
item.toolCall.componentName === CompName.callServiceCard
|
||||||
"
|
"
|
||||||
:toolCall="item.toolCall"
|
|
||||||
/>
|
/>
|
||||||
<Feedback
|
<Feedback
|
||||||
v-else-if="
|
v-else-if="
|
||||||
@@ -75,6 +74,13 @@
|
|||||||
v-if="item.question"
|
v-if="item.question"
|
||||||
:question="item.question"
|
:question="item.question"
|
||||||
/>
|
/>
|
||||||
|
|
||||||
|
<view
|
||||||
|
v-if="!item.isLoading"
|
||||||
|
class="border-box color-99A0AE font-size-12 pl-12"
|
||||||
|
>
|
||||||
|
内容由AI大模型生成,请仔细鉴别
|
||||||
|
</view>
|
||||||
</template>
|
</template>
|
||||||
</ChatCardAI>
|
</ChatCardAI>
|
||||||
</template>
|
</template>
|
||||||
@@ -133,6 +139,7 @@ import {
|
|||||||
NOTICE_EVENT_LOGOUT,
|
NOTICE_EVENT_LOGOUT,
|
||||||
NOTICE_EVENT_LOGIN_SUCCESS,
|
NOTICE_EVENT_LOGIN_SUCCESS,
|
||||||
} from "@/constant/constant";
|
} from "@/constant/constant";
|
||||||
|
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/index.vue";
|
import ChatTopWelcome from "../ChatTopWelcome/index.vue";
|
||||||
import ChatTopNavBar from "../ChatTopNavBar/index.vue";
|
import ChatTopNavBar from "../ChatTopNavBar/index.vue";
|
||||||
@@ -346,9 +353,7 @@ onLoad(() => {
|
|||||||
// token存在,初始化数据
|
// token存在,初始化数据
|
||||||
const initHandler = () => {
|
const initHandler = () => {
|
||||||
console.log("initHandler");
|
console.log("initHandler");
|
||||||
const token = uni.getStorageSync("token");
|
if (!appStore.hasToken) return;
|
||||||
|
|
||||||
if (!token) return;
|
|
||||||
loadRecentConversation();
|
loadRecentConversation();
|
||||||
///loadConversationMsgList();
|
///loadConversationMsgList();
|
||||||
initWebSocket();
|
initWebSocket();
|
||||||
@@ -415,7 +420,7 @@ const initWebSocket = () => {
|
|||||||
|
|
||||||
// 使用配置的WebSocket服务器地址
|
// 使用配置的WebSocket服务器地址
|
||||||
const token = uni.getStorageSync("token");
|
const token = uni.getStorageSync("token");
|
||||||
const wsUrl = `${appStore.serverConfig.wssUrl}?access_token=${token}`;
|
const wsUrl = `${WSS_URL}?access_token=${token}`;
|
||||||
|
|
||||||
// 初始化WebSocket管理器
|
// 初始化WebSocket管理器
|
||||||
webSocketManager = new WebSocketManager({
|
webSocketManager = new WebSocketManager({
|
||||||
|
|||||||
@@ -12,13 +12,10 @@
|
|||||||
></view>
|
></view>
|
||||||
<text
|
<text
|
||||||
v-show="show"
|
v-show="show"
|
||||||
:class="[
|
class="font-size-14 font-500 color-171717 ml-10"
|
||||||
'font-size-14 font-500 color-171717 ml-10',
|
:class="{ 'text-animated': show }"
|
||||||
{ 'text-animated': show },
|
>沐沐</text
|
||||||
]"
|
|
||||||
>
|
>
|
||||||
{{ config.name }}
|
|
||||||
</text>
|
|
||||||
</view>
|
</view>
|
||||||
|
|
||||||
<view class="w-24 h-24"></view>
|
<view class="w-24 h-24"></view>
|
||||||
@@ -37,8 +34,10 @@ const props = defineProps({
|
|||||||
});
|
});
|
||||||
|
|
||||||
const show = ref(false);
|
const show = ref(false);
|
||||||
const config = getCurrentConfig();
|
|
||||||
const getStyle = computed(() => {
|
const getStyle = computed(() => {
|
||||||
|
const config = getCurrentConfig();
|
||||||
|
|
||||||
return {
|
return {
|
||||||
"--ipSmallImageStep": config.ipSmallImageStep,
|
"--ipSmallImageStep": config.ipSmallImageStep,
|
||||||
"--ipSmallImageHeight": config.ipSmallImageHeight,
|
"--ipSmallImageHeight": config.ipSmallImageHeight,
|
||||||
|
|||||||
@@ -13,6 +13,31 @@
|
|||||||
<image class="w-full h-full" :src="logo" mode="widthFix" />
|
<image class="w-full h-full" :src="logo" mode="widthFix" />
|
||||||
</view>
|
</view>
|
||||||
|
|
||||||
|
<view class="form">
|
||||||
|
<view
|
||||||
|
class="bg-white border-box p-12 rounded-10 flex flex-items-center mb-16"
|
||||||
|
>
|
||||||
|
<uni-icons class="mr-8" type="phone-filled" size="20" color="#999" />
|
||||||
|
<input
|
||||||
|
class="w-272"
|
||||||
|
type="tel"
|
||||||
|
v-model="form.username"
|
||||||
|
placeholder="请输入手机号"
|
||||||
|
maxlength="11"
|
||||||
|
/>
|
||||||
|
</view>
|
||||||
|
<view class="bg-white border-box p-12 rounded-10 flex flex-items-center">
|
||||||
|
<uni-icons class="mr-8" type="locked-filled" size="20" color="#999" />
|
||||||
|
<input
|
||||||
|
class="w-272"
|
||||||
|
type="text"
|
||||||
|
v-model="form.password"
|
||||||
|
password
|
||||||
|
placeholder="请输入密码"
|
||||||
|
/>
|
||||||
|
</view>
|
||||||
|
</view>
|
||||||
|
|
||||||
<!-- 协议勾选 -->
|
<!-- 协议勾选 -->
|
||||||
<view class="login-agreement flex flex-items-center">
|
<view class="login-agreement flex flex-items-center">
|
||||||
<CheckBox v-model="isAgree">
|
<CheckBox v-model="isAgree">
|
||||||
@@ -36,24 +61,8 @@
|
|||||||
<!-- 按钮区域 -->
|
<!-- 按钮区域 -->
|
||||||
<view class="login-btn-area">
|
<view class="login-btn-area">
|
||||||
<!-- 同意隐私协议并获取手机号按钮 -->
|
<!-- 同意隐私协议并获取手机号按钮 -->
|
||||||
|
<button class="login-btn" type="primary" @click="onSubmitForm">
|
||||||
<button
|
登 录
|
||||||
v-if="!isAgree"
|
|
||||||
class="login-btn"
|
|
||||||
type="primary"
|
|
||||||
@click="handleAgreeAndGetPhone"
|
|
||||||
>
|
|
||||||
手机号快捷登录
|
|
||||||
</button>
|
|
||||||
|
|
||||||
<button
|
|
||||||
v-if="isAgree && !appStore.tokenExpired"
|
|
||||||
class="login-btn"
|
|
||||||
type="primary"
|
|
||||||
open-type="getPhoneNumber"
|
|
||||||
@getphonenumber="getPhoneNumber"
|
|
||||||
>
|
|
||||||
手机号快捷登录
|
|
||||||
</button>
|
</button>
|
||||||
</view>
|
</view>
|
||||||
|
|
||||||
@@ -69,17 +78,25 @@
|
|||||||
<script setup>
|
<script setup>
|
||||||
import { ref, computed } from "vue";
|
import { ref, computed } from "vue";
|
||||||
import {
|
import {
|
||||||
|
wxLogin,
|
||||||
getServiceAgreement,
|
getServiceAgreement,
|
||||||
getPrivacyAgreement,
|
getPrivacyAgreement,
|
||||||
} from "@/request/api/LoginApi";
|
} from "@/request/api/LoginApi";
|
||||||
import { onLogin, goBack } from "@/hooks/useGoLogin";
|
import { goBack } from "@/hooks/useGoLogin";
|
||||||
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";
|
import { zniconsMap } from "@/static/fonts/znicons.js";
|
||||||
import { getCurrentConfig } from "@/constant/base";
|
import { getCurrentConfig } from "@/constant/base";
|
||||||
|
import { NOTICE_EVENT_LOGIN_SUCCESS } from "@/constant/constant";
|
||||||
import { useAppStore } from "@/store";
|
import { useAppStore } from "@/store";
|
||||||
const appStore = useAppStore();
|
const appStore = useAppStore();
|
||||||
|
|
||||||
|
const form = ref({
|
||||||
|
grant_type: "password",
|
||||||
|
scope: "server",
|
||||||
|
username: "",
|
||||||
|
password: "",
|
||||||
|
});
|
||||||
const isAgree = ref(false);
|
const isAgree = ref(false);
|
||||||
const visible = ref(false);
|
const visible = ref(false);
|
||||||
const serviceAgreement = ref("");
|
const serviceAgreement = ref("");
|
||||||
@@ -88,8 +105,24 @@ const privacyAgreement = ref("");
|
|||||||
const AgreeType = ref("service");
|
const AgreeType = ref("service");
|
||||||
const logo = computed(() => getCurrentConfig().logo);
|
const logo = computed(() => getCurrentConfig().logo);
|
||||||
|
|
||||||
// 同意隐私协议并获取手机号
|
// 提交表单操作
|
||||||
const handleAgreeAndGetPhone = () => {
|
const onSubmitForm = () => {
|
||||||
|
if (!form.value.username) {
|
||||||
|
uni.showToast({
|
||||||
|
title: "请输入手机号",
|
||||||
|
icon: "none",
|
||||||
|
});
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!form.value.password) {
|
||||||
|
uni.showToast({
|
||||||
|
title: "请输入密码",
|
||||||
|
icon: "none",
|
||||||
|
});
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (!isAgree.value) {
|
if (!isAgree.value) {
|
||||||
uni.showToast({
|
uni.showToast({
|
||||||
title: "请先同意服务协议和隐私协议",
|
title: "请先同意服务协议和隐私协议",
|
||||||
@@ -97,18 +130,30 @@ const handleAgreeAndGetPhone = () => {
|
|||||||
});
|
});
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
};
|
|
||||||
|
|
||||||
const getPhoneNumber = (e) => {
|
if (form.value.password !== "YehdBPev") {
|
||||||
onLogin(e)
|
uni.showToast({
|
||||||
.then(() => {
|
title: "密码错误",
|
||||||
uni.showToast({
|
icon: "none",
|
||||||
title: "登录成功",
|
});
|
||||||
icon: "success",
|
return;
|
||||||
});
|
}
|
||||||
goBack();
|
|
||||||
})
|
wxLogin(form.value).then((res) => {
|
||||||
.catch(() => {});
|
uni.showToast({
|
||||||
|
title: "登录成功",
|
||||||
|
icon: "success",
|
||||||
|
});
|
||||||
|
|
||||||
|
if (res.access_token) {
|
||||||
|
uni.setStorageSync("token", res.access_token);
|
||||||
|
appStore.setHasToken(true);
|
||||||
|
// 登录成功后,触发登录成功事件
|
||||||
|
uni.$emit(NOTICE_EVENT_LOGIN_SUCCESS);
|
||||||
|
}
|
||||||
|
|
||||||
|
goBack();
|
||||||
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
// 处理同意协议点击事件
|
// 处理同意协议点击事件
|
||||||
|
|||||||
@@ -36,8 +36,16 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.form {
|
||||||
|
margin-top: 40px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.w-272 {
|
||||||
|
width: 272px;
|
||||||
|
}
|
||||||
|
|
||||||
.login-agreement {
|
.login-agreement {
|
||||||
margin-top: 80px;
|
margin-top: 40px;
|
||||||
width: 304px;
|
width: 304px;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
|
import { BASE_URL } from "@/request/base/baseUrl";
|
||||||
import { goLogin } from "@/hooks/useGoLogin";
|
import { goLogin } from "@/hooks/useGoLogin";
|
||||||
import { useAppStore } from "@/store";
|
|
||||||
|
|
||||||
/// 请求流式数据的API
|
/// 请求流式数据的API
|
||||||
const API = "/agent/assistant/chat";
|
const API = "/agent/assistant/chat";
|
||||||
@@ -93,9 +93,8 @@ const agentChatStream = (params, onChunk) => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
// #ifdef MP-WEIXIN
|
// #ifdef MP-WEIXIN
|
||||||
const { serverConfig } = useAppStore();
|
|
||||||
requestTask = uni.request({
|
requestTask = uni.request({
|
||||||
url: serverConfig.baseUrl + API, // 替换为你的接口地址
|
url: BASE_URL + API, // 替换为你的接口地址
|
||||||
method: "POST",
|
method: "POST",
|
||||||
data: params,
|
data: params,
|
||||||
enableChunked: true,
|
enableChunked: true,
|
||||||
|
|||||||
@@ -1,9 +1,8 @@
|
|||||||
|
import { BASE_URL } from "@/request/base/baseUrl";
|
||||||
import { getCurrentConfig } from "@/constant/base";
|
import { getCurrentConfig } from "@/constant/base";
|
||||||
import { useAppStore } from "@/store";
|
|
||||||
|
|
||||||
export const updateImageFile = (file) => {
|
export const updateImageFile = (file) => {
|
||||||
const { serverConfig } = useAppStore();
|
const url = BASE_URL + "/hotelBiz/hotBizCommon/upload";
|
||||||
const url = serverConfig.baseUrl + "/hotelBiz/hotBizCommon/upload";
|
|
||||||
const token = uni.getStorageSync("token");
|
const token = uni.getStorageSync("token");
|
||||||
const clientId = getCurrentConfig().clientId;
|
const clientId = getCurrentConfig().clientId;
|
||||||
|
|
||||||
|
|||||||
@@ -1,17 +0,0 @@
|
|||||||
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 };
|
|
||||||
@@ -1 +1,19 @@
|
|||||||
|
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;
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
import { goLogin } from "../../hooks/useGoLogin";
|
import { goLogin } from "../../hooks/useGoLogin";
|
||||||
|
import { BASE_URL } from "./baseUrl";
|
||||||
import { getCurrentConfig } from "@/constant/base";
|
import { getCurrentConfig } from "@/constant/base";
|
||||||
import { useAppStore } from "@/store";
|
import { useAppStore } from "@/store";
|
||||||
import { NOTICE_EVENT_LOGOUT } from "@/constant/constant";
|
import { NOTICE_EVENT_LOGOUT } from "@/constant/constant";
|
||||||
@@ -13,10 +14,9 @@ const defaultConfig = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
function request(url, args = {}, method = "POST", customConfig = {}) {
|
function request(url, args = {}, method = "POST", customConfig = {}) {
|
||||||
const appStore = useAppStore();
|
|
||||||
// 判断 url 是否以 http 开头
|
// 判断 url 是否以 http 开头
|
||||||
if (!/^http/.test(url)) {
|
if (!/^http/.test(url)) {
|
||||||
url = appStore.serverConfig?.baseUrl + url;
|
url = BASE_URL + url;
|
||||||
}
|
}
|
||||||
// 动态获取 token
|
// 动态获取 token
|
||||||
const token = uni.getStorageSync("token");
|
const token = uni.getStorageSync("token");
|
||||||
@@ -25,7 +25,6 @@ function request(url, args = {}, method = "POST", customConfig = {}) {
|
|||||||
...defaultConfig.header,
|
...defaultConfig.header,
|
||||||
...customConfig.header,
|
...customConfig.header,
|
||||||
};
|
};
|
||||||
|
|
||||||
// 判断是否需要 token
|
// 判断是否需要 token
|
||||||
if (customConfig.noToken) {
|
if (customConfig.noToken) {
|
||||||
delete header.Authorization;
|
delete header.Authorization;
|
||||||
@@ -59,6 +58,9 @@ function request(url, args = {}, method = "POST", customConfig = {}) {
|
|||||||
if (res.statusCode && res.statusCode === 424) {
|
if (res.statusCode && res.statusCode === 424) {
|
||||||
console.log("424错误,重新登录");
|
console.log("424错误,重新登录");
|
||||||
uni.setStorageSync("token", "");
|
uni.setStorageSync("token", "");
|
||||||
|
const appStore = useAppStore();
|
||||||
|
appStore.setHasToken(false);
|
||||||
|
appStore.setTokenExpired(true);
|
||||||
uni.$emit(NOTICE_EVENT_LOGOUT);
|
uni.$emit(NOTICE_EVENT_LOGOUT);
|
||||||
goLogin();
|
goLogin();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,12 +4,10 @@ export const useAppStore = defineStore("app", {
|
|||||||
state() {
|
state() {
|
||||||
return {
|
return {
|
||||||
title: "",
|
title: "",
|
||||||
sceneId: "", // 分身场景id
|
sceneId: "", /// 分身场景id
|
||||||
previewImageData: [], // 预览图片数据
|
hasToken: false, /// 是否有token
|
||||||
serverConfig: {
|
tokenExpired: false, /// token是否过期
|
||||||
baseUrl: "https://onefeel.brother7.cn/ingress", // 服务器基础地址
|
previewImageData: [], /// 预览图片数据
|
||||||
wssUrl: "wss://onefeel.brother7.cn/ingress/agent/ws/chat", // 服务器ws地址
|
|
||||||
}, // 服务器配置
|
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
getters: {},
|
getters: {},
|
||||||
@@ -21,12 +19,15 @@ export const useAppStore = defineStore("app", {
|
|||||||
setSceneId(data) {
|
setSceneId(data) {
|
||||||
this.sceneId = data;
|
this.sceneId = data;
|
||||||
},
|
},
|
||||||
|
setHasToken(status) {
|
||||||
|
this.hasToken = status;
|
||||||
|
},
|
||||||
|
setTokenExpired(status) {
|
||||||
|
this.tokenExpired = status;
|
||||||
|
},
|
||||||
setPreviewImageData(data) {
|
setPreviewImageData(data) {
|
||||||
this.previewImageData = data;
|
this.previewImageData = data;
|
||||||
},
|
},
|
||||||
setServerConfig(data) {
|
|
||||||
this.serverConfig = data;
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
|
|
||||||
unistorage: true,
|
unistorage: true,
|
||||||
|
|||||||
Reference in New Issue
Block a user