Compare commits
6 Commits
fix-109
...
9c658e9f9f
| Author | SHA1 | Date | |
|---|---|---|---|
| 9c658e9f9f | |||
| 7e02429f6e | |||
| 71a1083887 | |||
| 972c777177 | |||
|
|
ae2fb40d72 | ||
| 27b2052cec |
@@ -1,5 +1,5 @@
|
|||||||
{
|
{
|
||||||
"appid": "wx23f86d809ae80259",
|
"appid": "wx5e79df5996572539",
|
||||||
"compileType": "miniprogram",
|
"compileType": "miniprogram",
|
||||||
"libVersion": "3.8.10",
|
"libVersion": "3.8.10",
|
||||||
"packOptions": {
|
"packOptions": {
|
||||||
|
|||||||
@@ -200,6 +200,7 @@ function main() {
|
|||||||
console.log("\n🎉 所有文件更新完成!");
|
console.log("\n🎉 所有文件更新完成!");
|
||||||
console.log(`💡 已切换到 ${CLIENT_CONFIGS[clientName].name} 客户端配置`);
|
console.log(`💡 已切换到 ${CLIENT_CONFIGS[clientName].name} 客户端配置`);
|
||||||
console.log("💡 提示: 请检查文件内容确认更新正确");
|
console.log("💡 提示: 请检查文件内容确认更新正确");
|
||||||
|
console.log("\n💡 版本升级: 请到request/api/config.js文件中更新versionValue版本号\n");
|
||||||
} else {
|
} else {
|
||||||
console.log("\n❌ 部分文件更新失败,请检查错误信息");
|
console.log("\n❌ 部分文件更新失败,请检查错误信息");
|
||||||
process.exit(1);
|
process.exit(1);
|
||||||
|
|||||||
@@ -5,11 +5,14 @@ import { refreshToken } from "@/hooks/useGoLogin";
|
|||||||
import { getAccessToken } from "@/constant/token";
|
import { getAccessToken } from "@/constant/token";
|
||||||
|
|
||||||
onLaunch(async () => {
|
onLaunch(async () => {
|
||||||
await getEvnUrl({ versionValue: "1.0.3" });
|
/// 获取环境配置
|
||||||
|
await getEvnUrl();
|
||||||
|
|
||||||
|
/// 获取token
|
||||||
const token = getAccessToken();
|
const token = getAccessToken();
|
||||||
|
|
||||||
if (token) {
|
if (token) {
|
||||||
|
/// 刷新token
|
||||||
refreshToken();
|
refreshToken();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@@ -21,6 +24,7 @@ onShow(() => {
|
|||||||
onHide(() => {
|
onHide(() => {
|
||||||
console.log("App Hide");
|
console.log("App Hide");
|
||||||
});
|
});
|
||||||
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style lang="scss">
|
<style lang="scss">
|
||||||
|
|||||||
@@ -12,7 +12,7 @@ import rawConfigs from '../../client-configs.json' with { type: 'json' };
|
|||||||
export const CLIENT_CONFIGS = rawConfigs;
|
export const CLIENT_CONFIGS = rawConfigs;
|
||||||
|
|
||||||
// 获取当前用户端配置
|
// 获取当前用户端配置
|
||||||
export const getCurrentConfig = () => CLIENT_CONFIGS.duohua;
|
export const getCurrentConfig = () => CLIENT_CONFIGS.zhinian;
|
||||||
export const clientId = getCurrentConfig().clientId;
|
export const clientId = getCurrentConfig().clientId;
|
||||||
export const appId = getCurrentConfig().appId;
|
export const appId = getCurrentConfig().appId;
|
||||||
|
|
||||||
@@ -42,4 +42,4 @@ export const currentClientType = () => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
// 环境配置 - 智念客户端使用测试环境,其他客户端使用生产环境
|
// 环境配置 - 智念客户端使用测试环境,其他客户端使用生产环境
|
||||||
export const isProd = currentClientType() !== ClientType.ZHINIAN;
|
export const isZhiNian = currentClientType() === ClientType.ZHINIAN;
|
||||||
|
|||||||
@@ -1,8 +1,8 @@
|
|||||||
import { wxLogin, checkUserPhone } from "@/request/api/LoginApi";
|
import { oauthToken, checkUserPhone } from "@/request/api/LoginApi";
|
||||||
import { loginAuth, bindPhone } from "@/manager/LoginManager";
|
import { loginAuth, bindPhone } from "@/manager/LoginManager";
|
||||||
import { clientId } from "@/constant/base";
|
import { clientId } from "@/constant/base";
|
||||||
|
import { getAccessToken, removeAccessToken, setAccessToken } from "../constant/token";
|
||||||
import { NOTICE_EVENT_LOGIN_SUCCESS } from "@/constant/constant";
|
import { NOTICE_EVENT_LOGIN_SUCCESS } from "@/constant/constant";
|
||||||
import { getAccessToken, setAccessToken } from "../constant/token";
|
|
||||||
|
|
||||||
// 跳转登录
|
// 跳转登录
|
||||||
export const goLogin = () => uni.navigateTo({ url: "/pages/login/index" });
|
export const goLogin = () => uni.navigateTo({ url: "/pages/login/index" });
|
||||||
@@ -41,7 +41,13 @@ export const onLogin = async (e) => {
|
|||||||
const params = { wechatPhoneCode: code, clientId: clientId };
|
const params = { wechatPhoneCode: code, clientId: clientId };
|
||||||
const res = await bindPhone(params);
|
const res = await bindPhone(params);
|
||||||
if (res.data) {
|
if (res.data) {
|
||||||
|
// 登录成功后,触发登录成功事件
|
||||||
|
uni.$emit(NOTICE_EVENT_LOGIN_SUCCESS);
|
||||||
resolve();
|
resolve();
|
||||||
|
} else {
|
||||||
|
console.log("绑定手机号失败");
|
||||||
|
removeAccessToken();
|
||||||
|
reject();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
@@ -62,7 +68,7 @@ export const checkToken = () => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
// 刷新token
|
// 刷新token
|
||||||
export const refreshToken = (needLogin = false) => {
|
export const refreshToken = () => {
|
||||||
return new Promise(async (resolve) => {
|
return new Promise(async (resolve) => {
|
||||||
uni.login({
|
uni.login({
|
||||||
provider: "weixin", //使用微信登录
|
provider: "weixin", //使用微信登录
|
||||||
@@ -76,13 +82,10 @@ export const refreshToken = (needLogin = false) => {
|
|||||||
};
|
};
|
||||||
console.log("获取到的微信授权params:", JSON.stringify(params));
|
console.log("获取到的微信授权params:", JSON.stringify(params));
|
||||||
|
|
||||||
const response = await wxLogin(params);
|
const response = await oauthToken(params);
|
||||||
|
|
||||||
if (needLogin && response.access_token) {
|
|
||||||
setAccessToken(response.access_token);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (response.access_token) {
|
if (response.access_token) {
|
||||||
|
setAccessToken(response.access_token);
|
||||||
|
|
||||||
const checkRes = await checkUserPhone({
|
const checkRes = await checkUserPhone({
|
||||||
token: response.access_token,
|
token: response.access_token,
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
import { wxLogin, bindUserPhone } from "../request/api/LoginApi";
|
import { oauthToken, bindUserPhone } from "../request/api/LoginApi";
|
||||||
import { getWeChatAuthCode } from "./AuthManager";
|
import { getWeChatAuthCode } from "./AuthManager";
|
||||||
import { clientId } from "@/constant/base";
|
import { clientId } from "@/constant/base";
|
||||||
import { NOTICE_EVENT_LOGIN_SUCCESS } from "@/constant/constant";
|
import { NOTICE_EVENT_LOGIN_SUCCESS } from "@/constant/constant";
|
||||||
@@ -17,15 +17,11 @@ const loginAuth = (e) => {
|
|||||||
clientId: clientId,
|
clientId: clientId,
|
||||||
};
|
};
|
||||||
console.log("获取到的微信授权params:", JSON.stringify(params));
|
console.log("获取到的微信授权params:", JSON.stringify(params));
|
||||||
const response = await wxLogin(params);
|
const response = await oauthToken(params);
|
||||||
console.log("获取到的微信授权response:", response);
|
console.log("获取到的微信授权response:", response);
|
||||||
|
|
||||||
if (response.access_token) {
|
if (response.access_token) {
|
||||||
console.log("进入条件");
|
|
||||||
setAccessToken(response.access_token);
|
setAccessToken(response.access_token);
|
||||||
|
|
||||||
// 登录成功后,触发登录成功事件
|
|
||||||
uni.$emit(NOTICE_EVENT_LOGIN_SUCCESS);
|
|
||||||
resolve();
|
resolve();
|
||||||
} else {
|
} else {
|
||||||
reject(response.message || "登录失败");
|
reject(response.message || "登录失败");
|
||||||
|
|||||||
@@ -60,7 +60,7 @@
|
|||||||
朵花:wx23f86d809ae80259
|
朵花:wx23f86d809ae80259
|
||||||
*/
|
*/
|
||||||
"mp-weixin": {
|
"mp-weixin": {
|
||||||
"appid": "wx23f86d809ae80259",
|
"appid": "wx5e79df5996572539",
|
||||||
"setting": {
|
"setting": {
|
||||||
"urlCheck": false,
|
"urlCheck": false,
|
||||||
"minified": true
|
"minified": true
|
||||||
|
|||||||
@@ -102,6 +102,9 @@ const handleLogout = () => {
|
|||||||
uni.clearStorageSync();
|
uni.clearStorageSync();
|
||||||
emits("close");
|
emits("close");
|
||||||
uni.$emit(NOTICE_EVENT_LOGOUT);
|
uni.$emit(NOTICE_EVENT_LOGOUT);
|
||||||
|
uni.showToast({
|
||||||
|
title: "退出登录成功",
|
||||||
|
});
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -258,9 +258,6 @@ const addNoticeListener = () => {
|
|||||||
|
|
||||||
uni.$on(NOTICE_EVENT_LOGOUT, () => {
|
uni.$on(NOTICE_EVENT_LOGOUT, () => {
|
||||||
resetConfig();
|
resetConfig();
|
||||||
uni.showToast({
|
|
||||||
title: "退出登录成功",
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
|
|
||||||
uni.$on(SCROLL_TO_BOTTOM, () => {
|
uni.$on(SCROLL_TO_BOTTOM, () => {
|
||||||
@@ -605,9 +602,6 @@ const sendChat = (message, isInstruct = false) => {
|
|||||||
const messageContent = isInstruct ? commonType : message;
|
const messageContent = isInstruct ? commonType : message;
|
||||||
currentSessionMessageId = IdUtils.generateMessageId();
|
currentSessionMessageId = IdUtils.generateMessageId();
|
||||||
|
|
||||||
// 重置消息状态,为新消息做准备
|
|
||||||
resetMessageState();
|
|
||||||
|
|
||||||
// 插入AI消息
|
// 插入AI消息
|
||||||
const aiMsg = {
|
const aiMsg = {
|
||||||
msgId: `msg_${chatMsgList.value.length}`,
|
msgId: `msg_${chatMsgList.value.length}`,
|
||||||
@@ -630,8 +624,10 @@ const sendChat = (message, isInstruct = false) => {
|
|||||||
chatMsgList.value[aiMsgIndex].msg = "发送消息失败,请重试";
|
chatMsgList.value[aiMsgIndex].msg = "发送消息失败,请重试";
|
||||||
chatMsgList.value[aiMsgIndex].isLoading = false;
|
chatMsgList.value[aiMsgIndex].isLoading = false;
|
||||||
isSessionActive.value = false;
|
isSessionActive.value = false;
|
||||||
resetMessageState();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 重置消息状态,为新消息做准备
|
||||||
|
resetMessageState();
|
||||||
};
|
};
|
||||||
|
|
||||||
// 停止请求函数
|
// 停止请求函数
|
||||||
|
|||||||
@@ -28,9 +28,10 @@
|
|||||||
<!-- 按钮区域 -->
|
<!-- 按钮区域 -->
|
||||||
<view class="login-btn-area">
|
<view class="login-btn-area">
|
||||||
<!-- 同意隐私协议并获取手机号按钮 -->
|
<!-- 同意隐私协议并获取手机号按钮 -->
|
||||||
|
<button v-if="needWxAuthLogin" class="login-btn" type="primary" open-type="getPhoneNumber" @getphonenumber="getPhoneNumber">
|
||||||
<button class="login-btn" type="primary" :open-type="needWxLogin ? 'getPhoneNumber' : ''"
|
手机号快捷登录
|
||||||
@getphonenumber="getPhoneNumber" @click="handleAgreeAndGetPhone">
|
</button>
|
||||||
|
<button v-else class="login-btn" type="primary" @click="handleAgreeAndGetPhone">
|
||||||
手机号快捷登录
|
手机号快捷登录
|
||||||
</button>
|
</button>
|
||||||
</view>
|
</view>
|
||||||
@@ -52,7 +53,8 @@ import AgreePopup from "./components/AgreePopup/index.vue";
|
|||||||
import { zniconsMap } from "@/static/fonts/znicons";
|
import { zniconsMap } from "@/static/fonts/znicons";
|
||||||
import { getCurrentConfig } from "@/constant/base";
|
import { getCurrentConfig } from "@/constant/base";
|
||||||
|
|
||||||
const needWxLogin = ref(false);
|
// 是否需要微信手机号授权登录
|
||||||
|
const needWxAuthLogin = ref(false);
|
||||||
const isAgree = ref(false);
|
const isAgree = ref(false);
|
||||||
const visible = ref(false);
|
const visible = ref(false);
|
||||||
const serviceAgreement = ref("");
|
const serviceAgreement = ref("");
|
||||||
@@ -64,7 +66,7 @@ const logo = computed(() => getCurrentConfig().logo);
|
|||||||
// 同意隐私协议并获取手机号
|
// 同意隐私协议并获取手机号
|
||||||
const handleAgreeAndGetPhone = () => {
|
const handleAgreeAndGetPhone = () => {
|
||||||
// 如果需要微信登录,直接返回
|
// 如果需要微信登录,直接返回
|
||||||
if (needWxLogin.value) {
|
if (needWxAuthLogin.value) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -76,19 +78,36 @@ const handleAgreeAndGetPhone = () => {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
refreshToken(true).then(() => goBack());
|
refreshToken().then(() => loginSuccess());
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/// 获取授权后绑定手机号登录
|
||||||
const getPhoneNumber = (e) => {
|
const getPhoneNumber = (e) => {
|
||||||
onLogin(e)
|
if (!isAgree.value) {
|
||||||
.then(() => {
|
uni.showToast({
|
||||||
|
title: "请先同意服务协议和隐私协议",
|
||||||
|
icon: "none",
|
||||||
|
});
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
onLogin(e).then(() => loginSuccess())
|
||||||
|
.catch(() => {
|
||||||
|
uni.showToast({
|
||||||
|
title: "获取登录手机号失败",
|
||||||
|
icon: "none",
|
||||||
|
});
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
/// 登录成功返回上一页
|
||||||
|
const loginSuccess = () => {
|
||||||
uni.showToast({
|
uni.showToast({
|
||||||
title: "登录成功",
|
title: "登录成功",
|
||||||
icon: "success",
|
icon: "success",
|
||||||
});
|
});
|
||||||
|
setTimeout(() => {
|
||||||
goBack();
|
goBack();
|
||||||
})
|
}, 500);
|
||||||
.catch(() => { });
|
|
||||||
};
|
};
|
||||||
|
|
||||||
// 处理同意协议点击事件
|
// 处理同意协议点击事件
|
||||||
@@ -111,7 +130,6 @@ const getServiceAgreementData = async () => {
|
|||||||
const { data } = await getServiceAgreement();
|
const { data } = await getServiceAgreement();
|
||||||
serviceAgreement.value = data;
|
serviceAgreement.value = data;
|
||||||
};
|
};
|
||||||
|
|
||||||
getServiceAgreementData();
|
getServiceAgreementData();
|
||||||
|
|
||||||
// 获取隐私协议数据
|
// 获取隐私协议数据
|
||||||
@@ -119,15 +137,15 @@ const getPrivacyAgreementData = async () => {
|
|||||||
const { data } = await getPrivacyAgreement();
|
const { data } = await getPrivacyAgreement();
|
||||||
privacyAgreement.value = data;
|
privacyAgreement.value = data;
|
||||||
};
|
};
|
||||||
|
|
||||||
getPrivacyAgreementData();
|
getPrivacyAgreementData();
|
||||||
|
|
||||||
// 页面显示时刷新token
|
// 页面显示时刷新token
|
||||||
onShow(async () => {
|
onShow(async () => {
|
||||||
const res = await refreshToken();
|
const res = await refreshToken();
|
||||||
|
needWxAuthLogin.value = res;
|
||||||
needWxLogin.value = res;
|
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style lang="scss" scoped>
|
<style lang="scss" scoped>
|
||||||
|
|||||||
@@ -1,16 +1,14 @@
|
|||||||
import { removeAccessToken } from "@/constant/token";
|
import { removeAccessToken } from "@/constant/token";
|
||||||
import request from "../base/request";
|
import request from "../base/request";
|
||||||
|
|
||||||
const wxLogin = (args) => {
|
const oauthToken = (args) => {
|
||||||
const config = {
|
const config = {
|
||||||
header: {
|
header: {
|
||||||
Authorization: "Basic Y3VzdG9tOmN1c3RvbQ==", // 可在此动态设置 token
|
Authorization: "Basic Y3VzdG9tOmN1c3RvbQ==", // 可在此动态设置 token
|
||||||
"Content-Type": "application/x-www-form-urlencoded",
|
"Content-Type": "application/x-www-form-urlencoded",
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
removeAccessToken();
|
removeAccessToken();
|
||||||
|
|
||||||
return request.post("/auth/oauth2/token", args, config);
|
return request.post("/auth/oauth2/token", args, config);
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -40,7 +38,7 @@ const getPrivacyAgreement = (args) => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
export {
|
export {
|
||||||
wxLogin,
|
oauthToken,
|
||||||
bindUserPhone,
|
bindUserPhone,
|
||||||
checkUserPhone,
|
checkUserPhone,
|
||||||
getLoginUserPhone,
|
getLoginUserPhone,
|
||||||
|
|||||||
@@ -1,10 +1,25 @@
|
|||||||
import request from "../base/request";
|
import request from "../base/request";
|
||||||
import { isProd } from "@/constant/base";
|
import { isZhiNian } from "@/constant/base";
|
||||||
import { useAppStore } from "@/store";
|
import { useAppStore } from "@/store";
|
||||||
|
import { devUrl, proUrl, wssDevUrl } from "../base/baseUrl";
|
||||||
|
|
||||||
|
/// 版本号, 每次发版本前增加
|
||||||
|
const versionValue = "1.0.3";
|
||||||
|
|
||||||
// 获取服务地址
|
// 获取服务地址
|
||||||
const getEvnUrl = async (args) => {
|
const getEvnUrl = async () => {
|
||||||
const res = await request.post("https://biz.nianxx.cn/hotelBiz/mainScene/getServiceUrl", args)
|
/// 智念客户端不需要获取环境地址
|
||||||
|
if (isZhiNian) {
|
||||||
|
const appStore = useAppStore();
|
||||||
|
appStore.setServerConfig({
|
||||||
|
baseUrl: devUrl, // 服务器基础地址
|
||||||
|
wssUrl: wssDevUrl, // 服务器wss地址
|
||||||
|
});
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
const apiUrl = proUrl + "/hotelBiz/mainScene/getServiceUrl";
|
||||||
|
const res = await request.post(apiUrl, { versionValue: versionValue });
|
||||||
if (res && res.code == 0 && res.data) {
|
if (res && res.code == 0 && res.data) {
|
||||||
const appStore = useAppStore();
|
const appStore = useAppStore();
|
||||||
appStore.setServerConfig(res.data);
|
appStore.setServerConfig(res.data);
|
||||||
|
|||||||
@@ -1 +1,12 @@
|
|||||||
|
/// 生产环境基础地址
|
||||||
|
export const proUrl = "https://biz.nianxx.cn";
|
||||||
|
|
||||||
|
/// 生产环境服务器wss地址
|
||||||
|
export const wssProUrl = "wss://biz.nianxx.cn/ingress/agent/ws/chat";
|
||||||
|
|
||||||
|
/// 服务器基础地址
|
||||||
|
export const devUrl = "https://onefeel.brother7.cn/ingress";
|
||||||
|
|
||||||
|
/// 测试服务器wss地址
|
||||||
|
export const wssDevUrl = "wss://onefeel.brother7.cn/ingress/agent/ws/chat";
|
||||||
|
|
||||||
|
|||||||
@@ -59,9 +59,8 @@ function request(url, args = {}, method = "POST", customConfig = {}) {
|
|||||||
resolve(res.data);
|
resolve(res.data);
|
||||||
if (res.statusCode && res.statusCode === 424) {
|
if (res.statusCode && res.statusCode === 424) {
|
||||||
console.log("424错误,重新登录");
|
console.log("424错误,重新登录");
|
||||||
// removeAccessToken();
|
removeAccessToken();
|
||||||
uni.$emit(NOTICE_EVENT_LOGOUT);
|
uni.$emit(NOTICE_EVENT_LOGOUT);
|
||||||
// goLogin();
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
fail: (err) => {
|
fail: (err) => {
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
import { defineStore } from "pinia";
|
import { defineStore } from "pinia";
|
||||||
|
import { devUrl, wssDevUrl } from "../../request/base/baseUrl";
|
||||||
|
|
||||||
export const useAppStore = defineStore("app", {
|
export const useAppStore = defineStore("app", {
|
||||||
state() {
|
state() {
|
||||||
@@ -6,10 +7,10 @@ export const useAppStore = defineStore("app", {
|
|||||||
title: "",
|
title: "",
|
||||||
sceneId: "", // 分身场景id
|
sceneId: "", // 分身场景id
|
||||||
previewImageData: [], // 预览图片数据
|
previewImageData: [], // 预览图片数据
|
||||||
serverConfig: {
|
serverConfig: { // 服务器配置
|
||||||
baseUrl: "https://onefeel.brother7.cn/ingress", // 服务器基础地址
|
baseUrl: devUrl, // 服务器基础地址
|
||||||
wssUrl: "wss://onefeel.brother7.cn/ingress/agent/ws/chat", // 服务器ws地址
|
wssUrl: wssDevUrl, // 服务器ws地址
|
||||||
}, // 服务器配置
|
},
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
getters: {},
|
getters: {},
|
||||||
|
|||||||
Reference in New Issue
Block a user