Commit aea5507a authored by GuanHua's avatar GuanHua

fix: 添加各个门户域名获取方式

parent 4fede455
import { GlobalConfig } from '@/global/config'
import { getDefaultEnterprise, getChannelInfo, getIChannelInfo } from '@/utils'
import {
getInfoCenterUrl,
getlogisticsCenterUrl,
getManufactureCenterUrl,
getSrmCenterUrl,
getTopDomain,
} from '@/utils/getDomain'
export const NOT_CHANGE_VALUE = 'hello, world'
/**
* 请求头
*/
export const REQUEST_HEADER = 'http://'
/**
* 顶域
*/
const env = process.env.NODE_ENV
export const TOP_DOMAIN = getTopDomain(env, 'lingxidev.com')
export const TOP_DOMAIN_NO_PORT = getTopDomain(env, 'lingxidev.com', true)
/**
* 行情资讯域名
*/
export const INFO_CENTER_URL = getInfoCenterUrl(TOP_DOMAIN)
/**
* 企业采购域名
*/
export const SRM_CENTER_URL = getSrmCenterUrl(TOP_DOMAIN)
/**
* 物流服务域名
*/
export const LOGISTICS_CENTER_URL = getlogisticsCenterUrl(TOP_DOMAIN)
/**
* 加工服务域名
*/
export const MANUFACTURE_CENTER_URL = getManufactureCenterUrl(TOP_DOMAIN)
export const MALL_TYPE = {
1: '企业商城',
2: '积分商城',
3: '渠道商城',
4: '渠道自有商城',
5: '渠道积分商城'
}
export enum SHOP_TYPE {
/** 企业商城 */
mall = 1,
/** 积分商城 */
scoreMall = 2,
/** 渠道商城 */
channel = 3,
/** 渠道自有商城 */
ichannel = 4,
/** 渠道积分商城 */
channelScoreMall = 5,
}
export enum LAYOUT_TYPE {
/**
* 企业商城
*/
mall = 'mall',
/**
* 自营商城
*/
own = 'own',
/**
* 店铺(店铺商城)
*/
shop = 'shop',
/**
* 渠道商城
*/
channel = 'channel',
/**
* 渠道自有商城
*/
ichannel = 'ichannel',
/**
* 企业商城-积分商城
*/
scoreMall = 'scoreMall',
/**
* 店铺-积分兑换
*/
shopScoreMall = 'shopScoreMall',
/**
* 渠道商城-积分兑换
*/
channelScoreMall = 'channelScoreMall',
/**
* 店铺列表
*/
shopList = 'shopList',
/**
* 在线求购
*/
purchaseOnline = 'purchaseOnline'
}
// 本地环境跳过权限校验
export const isDev = process.env.NODE_ENV === "development"
// 暂时将权限访问关闭
// export const isDev = false
export const Environment_Status = {
0: "所有",
1: "web",
2: "H5",
3: "小程序",
4: "APP"
}
export enum FILTER_TYPE {
/**
* 常用筛选
*/
commonlyUsed = 'commonlyUsed',
/**
* 分类
*/
category = 'category',
/**
* 分类名称
*/
categoryName = 'categoryName',
/**
* 会员品类
*/
customerCategory = 'customerCategory',
/**
* 分类和属性
*/
categoryAndAttr = 'categoryAndAttr',
/**
* 风格
*/
style = 'style',
/**
* 品牌
*/
brand = 'brand',
/**
* 价格
*/
price = 'price',
/**
* 最低价格
*/
minPrice = 'minPrice',
/**
* 最高价格
*/
maxPrice = 'maxPrice',
/**
* 发货地
*/
useArea = 'useArea',
/**
* 发货地省份
*/
province = 'province',
/**
* 发货地市区
*/
city = 'city',
/**
* 商品类型
*/
commodityType = 'commodityType',
/**
* 活跃店铺
*/
activeStores = 'activeStores',
/**
* 最新加入
*/
newJoin = 'newJoin',
/**
* 所需积分
*/
points = 'points',
/**
* 最低积分
*/
minPoints = 'minPoints',
/**
* 最高积分
*/
maxPoints = 'maxPoints',
/**
* 商品名称
*/
name = 'name',
/**
* 排序
*/
sort = 'sort',
/**
* 价格排序
*/
priceSort = 'priceSort',
/**
* 价格从高到低
*/
priceSortHighToLow = 'priceSortHighToLow',
/**
* 价格从低到高
*/
priceSortLowToHigh = 'priceSortLowToHigh',
/**
* 销量从高到低
*/
soldSort = 'soldSort',
/**
* 信用排序
*/
creditSort = 'creditSort',
/**
* 信用从高到低
*/
creditSortHighToLow = 'creditSortHighToLow',
/**
* 信用从低到高
*/
creditSortLowToHigh = 'creditSortLowToHigh',
/**
* 店铺信用从高到低
*/
shopCreditSortHighToLow = 'shopCreditSortHighToLow',
/**
* 店铺信用从低到高
*/
shopCreditSortLowToHigh = 'shopCreditSortLowToHigh',
/**
* 时间排序
*/
dateSort = 'dateSort',
/**
* 时间从高到低
*/
dateSortHighToLow = 'dateSortHighToLow',
/**
* 时间从低到高
*/
dateSortLowToHigh = 'dateSortLowToHigh',
/**
* 属性筛选
*/
attribute = 'attribute',
/**
* 店铺地区筛选
*/
shopArea = 'shopArea'
}
// 商城类型
export const SHOP_TYPES = [
{
value: 1,
label: "企业商城"
},
{
value: 2,
label: "积分商城"
},
{
value: 3,
label: "渠道商城"
},
{
value: 4,
label: "渠道自有商城"
},
{
value: 5,
label: "渠道积分商城"
},
]
export const STATUS_ENUM = [
{
label: '全部',
value: null
},
{
label: '有效',
value: 1
},
{
label: '无效',
value: 0
}
]
// 1是阿里云oss服务器, 2是本地文件服务器
// 2020/10/21 本地文件服务器关闭, 现全部上传到oss - xjm
export const UPLOAD_TYPE = 1
export enum COMMODITY_TYPE {
/**
* 现货商品
*/
prompt = 1,
/**
*询价商品
*/
inquiry = 2,
/**
* 积分商品
*/
integral = 3
}
import { GlobalConfig } from '@/global/config';
import { INFO_CENTER_URL } from '@/constants'
const siteUrl = GlobalConfig.site.siteInfo.siteUrl;
......@@ -59,7 +60,7 @@ export const getMenuData = (shopId: number) => {
},
{
"id": 5,
"link": `${REQUEST_HEADER}info.${TOP_DOMAIN}`,
"link": INFO_CENTER_URL,
"name": "行情资讯",
"status": true,
"key": "shopInfomation",
......
import { GlobalConfig } from '@/global/config';
import { SRM_CENTER_URL, LOGISTICS_CENTER_URL, MANUFACTURE_CENTER_URL, INFO_CENTER_URL } from "@/constants"
const siteUrl = GlobalConfig.site.siteInfo.siteUrl;
......@@ -31,7 +32,7 @@ export const getMenuData = () => {
return [
{
"id": 0,
"link": `${REQUEST_HEADER}www.${TOP_DOMAIN}`,
"link": siteUrl,
"name": "首页",
"type": 1,
"status": true,
......@@ -47,7 +48,7 @@ export const getMenuData = () => {
},
{
"id": 2,
"link": `${REQUEST_HEADER}srm.${TOP_DOMAIN}`,
"link": SRM_CENTER_URL,
"name": "名企采购",
"type": 3,
"status": true,
......@@ -71,7 +72,7 @@ export const getMenuData = () => {
},
{
"id": 5,
"link": `${REQUEST_HEADER}logistics.${TOP_DOMAIN}`,
"link": LOGISTICS_CENTER_URL,
"name": "物流服务",
"type": 6,
"key": "logistics",
......@@ -79,7 +80,7 @@ export const getMenuData = () => {
},
{
"id": 6,
"link": `${REQUEST_HEADER}manufacture.${TOP_DOMAIN}`,
"link": MANUFACTURE_CENTER_URL,
"name": "加工服务",
"type": 7,
"status": true,
......@@ -95,7 +96,7 @@ export const getMenuData = () => {
},
{
"id": 8,
"link": `${REQUEST_HEADER}info.${TOP_DOMAIN}`,
"link": INFO_CENTER_URL,
"name": "行情资讯",
"type": 9,
"status": true,
......
import { GlobalConfig } from '../global/config'
/**
* 请求头
*/
export const REQUEST_HEADER = 'http://'
export const getTopDomainByHost = (url: string, isPort = false): string => {
if (!url) return ''
// 如果后缀带有端口号, 则把端口号也加上
const splitUrl = url.split(':')
if (splitUrl.length > 1 && isPort) {
return `${splitUrl[0].split('.').slice(-2).join('.')}`
}
return url.split('.').slice(-2).join('.')
}
/**
* 获取顶域
*/
export const getTopDomain = (env: string = 'production', defaultTopDomain: string = 'lingxidev.com', isPort: boolean = false) => {
return env !== 'development' ? getTopDomainByHost(GlobalConfig.site.siteInfo.siteUrl, isPort) : defaultTopDomain
}
/**
* 获取平台首页子域名
*/
const getPlatformSubDomain = (defaultSubDomian: string) => {
const siteUrl = GlobalConfig.site.siteInfo.siteUrl
return siteUrl.split('.')[0] || defaultSubDomian
}
/**
* 获取平台首页域名
*/
export const getPlatformDomain = (topDomain: string, defaultSubDomian: string = 'lx-www') => {
return `${REQUEST_HEADER}${getPlatformSubDomain(defaultSubDomian)}.${topDomain}`
}
/**
* 会员中心域名
*/
export const getMemberCenterUrl = (topDomain: string, defaultSubDomian: string = 'lx-member') => {
return `${REQUEST_HEADER}${defaultSubDomian}.${topDomain}`
}
export const getDefaultEnterprise = () => {
const shopInfo = GlobalConfig.web.shopInfo
const webMallList = shopInfo.filter((item: { environment: number; type: number, property?: any }) => item.environment === 1 && item.type === 1 && item.property === 1)
const defaultMall = webMallList.filter((item: any) => item.isDefault === 1)[0]
let result: any = undefined
if (defaultMall) {
result = defaultMall
} else {
if (webMallList && webMallList.length > 0) {
result = webMallList[0]
}
}
return result
}
const enterpriseInfo = getDefaultEnterprise()
/**
* 企业商城域名
*/
export const getEnterpriseCenterUrl = (topDomain: string) => {
return `${REQUEST_HEADER}${enterpriseInfo ? enterpriseInfo.url : 'lx-b2b'}.${topDomain}`
}
export const getChannelInfo = () => {
const shopInfo = GlobalConfig.web.shopInfo
const webMallList = shopInfo.filter((item: { environment: number; type: number }) => item.environment === 1 && item.type === 3)
return webMallList[0]
}
export const getIChannelInfo = () => {
const shopInfo = GlobalConfig.web.shopInfo
const webMallList = shopInfo.filter((item: { environment: number; type: number }) => item.environment === 1 && item.type === 4)
return webMallList[0]
}
const channelInfo = getChannelInfo()
const iChannelInfo = getIChannelInfo()
/**
* 渠道商城子域名
*/
export const getChannelCenterUrl = (topDomain: string) => {
return `${REQUEST_HEADER}${channelInfo ? channelInfo.url : 'lx-channel'}.${topDomain}`
}
/**
* 自有渠道商城子域名
*/
export const getIChannelCenterUrl = (topDomain: string) => {
return `${REQUEST_HEADER}${iChannelInfo ? iChannelInfo.url : 'lx-ichannel'}.${topDomain}`
}
const getShopInfoByType = (type: number) => {
const shopInfo = GlobalConfig.web.shopInfo
const webMallList = shopInfo.filter((item: any) => item.type === type)
return webMallList[0]
}
const infoDetail = getShopInfoByType(9)
const srmDetail = getShopInfoByType(6)
const logisticsDetail = getShopInfoByType(7)
const manufactureDetail = getShopInfoByType(8)
/**
* 行情资讯域名
*/
export const getInfoCenterUrl = (topDomain: string) => {
return `${REQUEST_HEADER}${infoDetail ? infoDetail.url : 'lx-info'}.${topDomain}`
}
/**
* 企业采购域名
*/
export const getSrmCenterUrl = (topDomain: string) => {
return `${REQUEST_HEADER}${srmDetail ? srmDetail.url : 'lx-srm'}.${topDomain}`
}
/**
* 物流服务域名
*/
export const getlogisticsCenterUrl = (topDomain: string) => {
return `${REQUEST_HEADER}${logisticsDetail ? logisticsDetail.url : 'lx-logistics'}.${topDomain}`
}
/**
* 加工服务域名
*/
export const getManufactureCenterUrl = (topDomain: string) => {
return `${REQUEST_HEADER}${manufactureDetail ? manufactureDetail.url : 'lx-manufacture'}.${topDomain}`
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment