跨域配置

master
wujingling0908 1 week ago
parent a025523fc5
commit 570fb1e334
  1. 235
      patch.txt
  2. 4
      src/utils/config.js
  3. 2
      vite.config.js

@ -1,235 +0,0 @@
*** Begin Patch
*** Update File: D:\code\taibao\customAgent\src\views\chat.vue
@@ -421,10 +421,14 @@
}
}
-// 北极星SDK鉴权
-function initBxSDK() {
+
+// 北极星SDK鉴权
+const initBxSDK = () => {
setConfig({
url: isProd() ? "life-open.cpic.com.cn/fop/ui/poc/shumeng/h5" : "life-open-sit.cpic.com.cn/fop/ui/poc/shumeng/h5",
deb: "false",
})
}
- // 异步微信鉴权方法
- function async initWxAuth(versionNo1) {
+
+// 异步微信鉴权方法
+const initWxAuth = async (versionNo1) => {
try {
- // 异步获取微信配置参数
- const res = await this.getWxAuthConfig(versionNo1);
+ // 异步获取微信配置参数
+ const res = await getWxAuthConfig(versionNo1);
if (!res.success) {
@@ -459,8 +463,9 @@
}
}
- // 获取微信鉴权配置参数
- function async getWxAuthConfig(versionNo1) {
+// 获取微信鉴权配置参数
+const getWxAuthConfig = async (versionNo1) => {
const v1 = versionNo1
try {
@@ -471,3 +476,3 @@
const encryptUrl = Encrypt(key, iv, url)
- const response = await this.("thirdPartyAuth/getGwResultByUrl", {
+ const response = await Post("thirdPartyAuth/getGwResultByUrl", {
url: encryptUrl
@@ -486,48 +491,35 @@
// 微信鉴权成功后的回调
-function onWxAuthSuccess() {
+const onWxAuthSuccess = () => {
console.log('微信鉴权成功');
- Toast('wx.ready回调')
+ showToast('wx.ready回调')
}
-function disableShare() {
- var that = this;
+
+const disableShare = () => {
try {
//禁止分享
if (typeof WeixinJSBridge == "undefined") {
if (document.addEventListener) {
document.addEventListener(
"WeixinJSBridgeReady",
- that.onBridgeReady(),
+ onBridgeReady,
false
);
} else if (document.attachEvent) {
- document.attachEvent("WeixinJSBridgeReady", that.onBridgeReady());
- document.attachEvent("onWeixinJSBridgeReady", that.onBridgeReady());
+ document.attachEvent("WeixinJSBridgeReady", onBridgeReady);
+ document.attachEvent("onWeixinJSBridgeReady", onBridgeReady);
}
} else {
- that.onBridgeReady();
+ onBridgeReady();
}
} catch (error) {
console.log("禁止分享hideOptionMenu", error.message);
}
}
-function onBridgeReady() {
+
+const onBridgeReady = () => {
WeixinJSBridge.call("hideOptionMenu");
}
-//链接人工客服
-function transferLabor() {
- var that = this;
- let sendParmas = {
- reqAndResType: "1", //1文本 2图片 3问提评价
- msgType: "01", //01文本 02图片
- msgText: "转接寿险人工客服",
- msgSource: this.manualService, //1机器人 2人工
- cmd: "ZJSXRGFW",
- // qaId: item.qaId, // 2022.03需求记录
- };
-
- // let current = event.currentTarget;
-
- //统计转人工 8月28日
- // this.statisticsTransferLabor(item);
-
- // 如果当前websocket链接已存在
- if (
- this.. &&
- this...readyState != this...CLOSED
- ) {
- // console.log(res)
- Toast("当前已经在人工会话中");
- // current.disabled = true;
- return;
- }
-
- //http接口
- var transferToast = Toast.loading({
- message: "转接中...",
- duration: 0,
- loadingType: "spinner",
- forbidClick: true,
- });
-
- this.
- .dispatch("transferCustomer", sendParmas)
- .then((res) => {
- transferToast.clear();
- // console.log(res)
- // current.disabled = true;
- // //用户行为统计 start
- // this.getUserBehavior(item.qaId, '5', 'ZJSXRGFW'); // 延期
- // //用户行为统计 end
-
- //我要转人工
- if (res.cmd === "ZJSXRGFWCONNECTION") {
- //初始化websocket 如果当前还是机器人
- that.setWebsocket(); //转人工
- return;
- }
-
- //其他消息 直接展示消息列表中
- this.set_chatList(res);
- //滚动到底部
- this.scrollTopBody();
- })
- .catch((err) => {
- transferToast.clear();
- console.log(err);
- });
-}
-//建立websocket
-function setWebsocket() {
- var that = this;
- try {
- //http接口
- var socketToast = Toast.loading({
- message: "连接中...",
- duration: 0,
- loadingType: "spinner",
- forbidClick: true,
- });
-
- //建立websocket
- this..initWebSocket(() => {
- that.
- .dispatch("setConnectToEasemob")
- .then((res) => {
- socketToast.clear();
- // if(res.connection){//机器人转人工
- // that.set_manualService(res.msgSource);
- // }
-
- // //用户行为统计 start
- // that.getUserBehavior(item.qaId, "5", "ZJSXRGFW");
- // //用户行为统计 end
- })
- .catch((err) => {
- socketToast.clear();
- console.log(err);
- });
- });
- } catch (err) {
- console.log(err.message);
- }
-}
-function scrollTopBody() {
- setTimeout(() => {
- //滚动到底部
- try {
- this.mescrollContent.scrollTop =
- this.mescrollContent.scrollHeight || 0;
- } catch (error) {
- console.log(error.message);
- }
- }, 300);
-}
-function loadSdk(){
+
+// 加载SDK
+const loadSdk = () => {
const script = document.createElement('script');
- this.("config/mydConfig", {})
+ Post("config/mydConfig", {})
.then((res) => {
@@ -538,3 +530,3 @@
script.onload = () => {
- this.set_sdkLoaded(true)
+ store.set_sdkLoaded?.(true)
console.log('SDK successed');
@@ -549,5 +541,6 @@
})
}
-//获取高温用户弹窗数据
-function getHotUserData(){
- this.("product/tip/select")
+
+// 获取高温用户弹窗数据
+const getHotUserData = () => {
+ Get("product/tip/select")
.then((res) => {
@@ -559,3 +552,3 @@
if (res.data.rhetoricString && res.data.productTipEntityList.length > 0) {
- this.set_hotUserData(hotUserData);
+ store.set_hotUserData?.(hotUserData);
}
@@ -563,7 +556,7 @@
const now = new Date();
const clickTime = \-\-\ \:\:\;
- const userId = this.userId;
- const source = this.source;
- const sessionId = this.sessionId;
+ const userId = store.userId;
+ const source = store.source;
+ const sessionId = store.sessionId;
// 调用埋点接口
- this.("product/record/save", {
+ Post("product/record/save", {
userId: userId,
*** End Patch

@ -6,8 +6,8 @@ const isWs = protocol === 'https:' ? 'wss' : 'ws'
// liics 的 HTTP/WebSocket 服务与页面使用同一域名;本地开发也由 Vite
// 直接代理 /liics_api,因此浏览器里看到的请求路径在各环境保持一致。
const config = {
baseUrl: '/liics_api/',
WSURL: `${isWs}://${host}/liics_api/webSocket/`,
baseUrl: '/yykf/liics_api/',
WSURL: `${isWs}://${host}/yykf/liics_api/webSocket/`,
envType: import.meta.env.DEV ? 'dev' : 'production',
BASEURL: currentUrl.origin,
}

@ -15,7 +15,7 @@ export default defineConfig(({ command }) => {
server: {
proxy: {
'/liics_api': {
target: 'https://ssp-sit.cpic.com.cn',
target: 'https://aioblu-sit.cpic.com.cn',
changeOrigin: true,
ws: true,
},

Loading…
Cancel
Save