mirror of
https://gitee.com/beijing_hongye_huicheng/lilishop-ui.git
synced 2026-08-06 02:47:29 +08:00
Merge branch 'fix/im-vue3-migration'
This commit is contained in:
@@ -3,7 +3,7 @@
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import { Message } from "@/utils/message";
|
||||
import { Modal } from "@/utils/message";
|
||||
import { getIMDetail } from "@/api/common";
|
||||
import Storage from "@/plugins/storage";
|
||||
import { getMemberMsg } from "@/api/login";
|
||||
@@ -15,28 +15,52 @@ export default {
|
||||
};
|
||||
},
|
||||
methods: {
|
||||
promptLogin() {
|
||||
Modal.confirm({
|
||||
title: "温馨提示",
|
||||
content: "请登录后执行此操作",
|
||||
okText: "立即登录",
|
||||
cancelText: "取消",
|
||||
onOk: () => {
|
||||
this.$router.push({
|
||||
path: "/login",
|
||||
query: {
|
||||
rePath: this.$route.path,
|
||||
query: JSON.stringify(this.$route.query || {}),
|
||||
},
|
||||
});
|
||||
},
|
||||
});
|
||||
},
|
||||
// 跳转im客服
|
||||
async IMService(id, goodsId, skuId) {
|
||||
if (!Storage.getItem("accessToken")) {
|
||||
this.promptLogin();
|
||||
return;
|
||||
}
|
||||
|
||||
// 获取访问Token
|
||||
let accessToken = Storage.getItem("accessToken");
|
||||
await this.getIMDetailMethods();
|
||||
const userInfo = await getMemberMsg();
|
||||
if (userInfo.success) {
|
||||
//携带商品Id,在IM可以发送商品信息
|
||||
if(goodsId && skuId){
|
||||
window.open(
|
||||
this.IMLink + "?token=" + accessToken + "&id=" + (id || this.storeMsg.storeId) + "&goodsId=" + goodsId + "&skuId=" + skuId
|
||||
);
|
||||
}else{
|
||||
window.open(
|
||||
this.IMLink + "?token=" + accessToken + "&id=" + (id || this.storeMsg.storeId)
|
||||
);
|
||||
try {
|
||||
await this.getIMDetailMethods();
|
||||
const userInfo = await getMemberMsg();
|
||||
if (!userInfo.success) {
|
||||
this.promptLogin();
|
||||
return;
|
||||
}
|
||||
|
||||
} else {
|
||||
Message.error("请登录后再联系客服");
|
||||
return;
|
||||
const accessToken = Storage.getItem("accessToken");
|
||||
const storeId = id || this.storeMsg?.storeId;
|
||||
const baseUrl = `${this.IMLink}?token=${accessToken}&id=${storeId}`;
|
||||
|
||||
if (goodsId && skuId) {
|
||||
window.open(`${baseUrl}&goodsId=${goodsId}&skuId=${skuId}`);
|
||||
} else {
|
||||
window.open(baseUrl);
|
||||
}
|
||||
} catch {
|
||||
// token 过期等场景由 request 拦截器处理;未登录时避免未捕获异常
|
||||
if (!Storage.getItem("accessToken")) {
|
||||
this.promptLogin();
|
||||
}
|
||||
}
|
||||
},
|
||||
// 获取im信息
|
||||
|
||||
@@ -284,7 +284,7 @@ export default {
|
||||
// 跳转店铺首页
|
||||
goShopPage(id) {
|
||||
let routeUrl = this.$router.resolve({
|
||||
path: "/Merchant",
|
||||
path: "/merchant",
|
||||
query: { id },
|
||||
});
|
||||
window.open(routeUrl.href, "_blank");
|
||||
|
||||
@@ -177,7 +177,7 @@ export default {
|
||||
let url
|
||||
if (this.params.type === 'STORE') {
|
||||
url = this.$router.resolve({
|
||||
path: '/Merchant',
|
||||
path: '/merchant',
|
||||
query: { 'id': storeId }
|
||||
})
|
||||
} else {
|
||||
|
||||
@@ -198,7 +198,7 @@ export default {
|
||||
// 跳转店铺首页
|
||||
shopPage(id) {
|
||||
let routeUrl = this.$router.resolve({
|
||||
path: '/Merchant',
|
||||
path: '/merchant',
|
||||
query: {id: id}
|
||||
});
|
||||
window.open(routeUrl.href, '_blank');
|
||||
|
||||
@@ -265,7 +265,7 @@ export default {
|
||||
// 跳转店铺首页
|
||||
shopPage (id) {
|
||||
let routeUrl = this.$router.resolve({
|
||||
path: '/Merchant',
|
||||
path: '/merchant',
|
||||
query: { id: id }
|
||||
});
|
||||
window.open(routeUrl.href, '_blank');
|
||||
|
||||
@@ -424,7 +424,7 @@ export default {
|
||||
// 跳转店铺首页
|
||||
shopPage(id) {
|
||||
let routeUrl = this.$router.resolve({
|
||||
path: "/Merchant",
|
||||
path: "/merchant",
|
||||
query: { id: id },
|
||||
});
|
||||
window.open(routeUrl.href, "_blank");
|
||||
|
||||
@@ -71,7 +71,7 @@ export default {
|
||||
// 跳转店铺首页
|
||||
shopPage(id) {
|
||||
let routeUrl = this.$router.resolve({
|
||||
path: "/Merchant",
|
||||
path: "/merchant",
|
||||
query: { id: id },
|
||||
});
|
||||
window.open(routeUrl.href, "_blank");
|
||||
|
||||
@@ -794,7 +794,7 @@ export default {
|
||||
// 跳转店铺首页
|
||||
goShopPage(id) {
|
||||
let routeUrl = this.$router.resolve({
|
||||
path: "/Merchant",
|
||||
path: "/merchant",
|
||||
query: { id: id },
|
||||
});
|
||||
window.open(routeUrl.href, "_blank");
|
||||
|
||||
Reference in New Issue
Block a user