修复已知问题

This commit is contained in:
2024-09-27 14:17:12 +08:00
parent c0328fa23e
commit 5e56c31300
299 changed files with 17512 additions and 987 deletions
+23 -9
View File
@@ -68,30 +68,44 @@ export function openUrl(url: string, params?: any): void {
* 拼接规则: {域名}{path}?spm=c.{用户ID}.{租户ID}.{栏目ID}.{商品ID}.{timestamp}&token={token}
* @return https:///websoft.top/product/detail/128.html?spm=c.5.3057.10005.undefined&token=DDkr1PpE9DouIVMjLEMt9733QsgG7oNV
*/
export function openSpmUrl(path: string, d?: any, id = 0): void {
const domain = getSiteDomain();
export function openSpmUrl(path?: string, d?: any, id = 0): void {
// const domain = getSiteDomain();
const domain = localStorage.getItem('Domain');
const spm = ref<string>('');
const token = ref<string>();
const url = ref<string>();
const model = ref<string>('c');
const tid = d?.tenantId || 0;
const mid = localStorage.getItem('MerchantId') || 0;
const pid = d?.parentId || 0;
const cid = d?.categoryId || 0;
const uid = localStorage.getItem('UserId') || 0;
const timestamp = ref(Date.now() / 1000);
token.value = `&token=${uuid()}`;
// 判断模型
if (d?.goodsId) {
model.value = 'g';
}
if (d?.articleId) {
model.value = 'a';
}
// TODO 封装租户ID和店铺ID
spm.value = `?spm=c.${uid}.${tid}.${pid}.${cid}.${id}.${timestamp.value}`;
spm.value = `?spm=${model.value}.${tid}.${mid}.${pid}.${cid}.${id}.${uid}.${
timestamp.value
}&token=${uuid()}`;
// TODO 含http直接跳转
if (path.startsWith('http')) {
window.open(`${path}${spm.value}`);
if (path?.startsWith('http')) {
window.open(`${path}`);
return;
}
// 跳转页面
url.value = `${domain}${path}${spm.value}${token.value}`;
window.open(`${url.value}`);
// TODO 跳转网站预览地址
if (domain && domain.length > 0) {
window.open(`https://${domain}${path}${spm.value}`);
return;
}
}
/**
+1 -1
View File
@@ -116,7 +116,7 @@ export function getSiteDomain(): string {
if (d.domain) {
localStorage.setItem('Domain', `https://${d.domain}`);
} else {
localStorage.setItem('Domain', `https://$${d.websiteCode}.wsdns.cn`);
localStorage.setItem('Domain', `https://${d.websiteCode}.wsdns.cn`);
}
return localStorage.getItem('Domain');
}
+9
View File
@@ -16,6 +16,15 @@ export const getMerchantName = () => {
return undefined;
};
// 获取商户Logo
export const getMerchantAvatar = () => {
const MerchantLogo = localStorage.getItem('MerchantLogo');
if (MerchantLogo) {
return MerchantLogo;
}
return undefined;
};
export const getRoleIdByMerchant = () => {
const id = localStorage.getItem('RoleIdByMerchant');
if (id) {
+5
View File
@@ -11,6 +11,7 @@ import { getToken, setToken } from './token-util';
import { logout } from './page-tab-util';
import type { ApiResult } from '@/api';
import { getHostname, getTenantId } from '@/utils/domain';
import { getMerchantId } from "@/utils/merchant";
const service = axios.create({
baseURL: API_BASE_URL
@@ -34,6 +35,10 @@ service.interceptors.request.use(
if (companyId) {
config.headers.common['CompanyId'] = companyId;
}
// 附加商户ID
if (getMerchantId()) {
config.headers.common['MerchantId'] = getMerchantId();
}
// 通过网站域名获取租户ID
if (getHostname()) {
config.headers.common['Domain'] = getHostname();