| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143 |
- export default class DealSeoData {
- constructor({ $axios, req, app, redirect, store }) {
- this.$axios = $axios
- this.req = req
- this.app = app
- this.redirect = redirect
- this.store = store
- this.selected = {
- city: 0,
- industry: 0,
- techType: 0,
- }
- this.page = {
- page: 1,
- size: 10,
- total: 0
- }
- this.finished = false
- this.dataList = []
- this.provinces = []
- }
- async dealData() {
- let { name, path, params, fullPath } = this.app.context.route
- let res = await this.$axios.get('/api/kaifawu/get_options')
- const { cities, industries, tech_types } = res.data.data || {}
- let typeList = { city: cities, industry: industries, techType: tech_types }
- this.typeList = typeList
- //查找中文
- let match = params.pathMatch || ''
- let list = match.split('/').map(item => item.toLocaleLowerCase())
- list.length = Math.min(list.length, 3) //防止url超出
- let keys = Object.keys(typeList)
- //3 * 3 * n的循环 n < 100
- list.forEach(item => {
- keys.forEach(keys => {
- typeList[ keys ].forEach(typeItem => {
- if (typeItem.slug === item) {
- this.selected[ keys ] = typeItem.id
- this.selected[ keys + 'Name' ] = typeItem.name
- }
- })
- })
- })
- return {
- footer: await this.getFooterData(),
- }
- }
- async getFooterData() {
- //设置底部link列表
- const typeList = this.typeList
- const { city, industry, techType, cityName = "", industryName = "", techTypeName = "", proviceName } = this.selected
- const { headers: { host = '' } } = this.req || { headers: {}}
- const kaifainUrl = this.store.state.domainConfig.kaifainUrl
- let footer = {
- baseLink: "", link: [
- { name: "", data: [] }, { name: "", data: [] },
- ],
- }
- //设置baseLink
- if (host.indexOf('local') !== -1) {
- footer.baseLink = 'http://' + host
- } else if (host) {
- footer.baseLink = 'https://' + host
- }
- if (city && !industry && !techType) {
- //只有城市的
- footer.link[ 0 ].name = "热门城市技术解决方案"
- footer.link[ 1 ].name = `${cityName}技术解决方案`
- footer.link[ 0 ].data = typeList.city.map((item) => {
- return { name: `${item.name}技术解决方案`, url: `${kaifainUrl}/${item.slug}/` }
- })
- footer.link[ 1 ].data = typeList.industry.map((item) => {
- return { name: `${cityName}${item.name}技术解决方案`, url: `${kaifainUrl}/${city}/${item.slug}/` }
- })
- } else if (!city && industry && !techType) {
- //只有行业的
- footer.link[ 0 ].name = "其它行业领域技术解决方案"
- footer.link[ 1 ].name = `热门城市${industryName}技术解决方案`
- footer.link[ 0 ].data = typeList.industry.map((item) => {
- return { name: `${item.name}技术解决方案`, url: `${kaifainUrl}/${item.slug}/` }
- })
- footer.link[ 1 ].data = typeList.city.map((item) => {
- return { name: `${item.name}${industryName}技术解决方案`, url: `${kaifainUrl}/${item.slug}/${industry}/` }
- })
- } else if (!city && !industry && techType) {
- //只有技术分类
- footer.link[ 0 ].name = `其他行业领域${techTypeName}技术解决方案`
- footer.link[ 1 ].name = `热门城市${techTypeName}技术解决方案`
- footer.link[ 0 ].data = typeList.industry.map((item) => {
- return { name: `${item.name}${techTypeName}技术解决方案`, url: `${kaifainUrl}/${item.slug}/${techType}/` }
- })
- footer.link[ 1 ].data = typeList.city.map((item) => {
- return { name: `${item.name}${techTypeName}技术解决方案`, url: `${kaifainUrl}/${techType}/${item.slug}/` }
- })
- } else if (city && industry && !techType) {
- //${cityName}${industryName}
- footer.link[ 0 ].name = `热门城市技术解决方案`
- footer.link[ 1 ].name = `其他行业领域技术解决方案`
- footer.link[ 0 ].data = typeList.city.map((item) => {
- return { name: `${item.name}技术解决方案`, url: `${kaifainUrl}/${item.slug}/` }
- })
- footer.link[ 1 ].data = typeList.industry.map((item) => {
- return { name: `${item.name}技术解决方案`, url: `${kaifainUrl}/${item.slug}/` }
- })
- } else if (city && !industry && techType) {
- //${cityName}${techTypeName}
- footer.link[ 0 ].name = `热门城市技术解决方案`
- footer.link[ 1 ].name = `其他行业领域技术解决方案`
- footer.link[ 0 ].data = typeList.city.map((item) => {
- return { name: `${item.name}技术解决方案`, url: `${kaifainUrl}/${item.slug}/` }
- })
- footer.link[ 1 ].data = typeList.industry.map((item) => {
- return { name: `${item.name}技术解决方案`, url: `${kaifainUrl}/${item.slug}/` }
- })
- } else if (!city && industry && techType) {
- //${industryName}${techTypeName}
- footer.link[ 0 ].name = `其他行业领域技术解决方案`
- footer.link[ 1 ].name = `其他行业技术分类${industryName}技术解决方案`
- footer.link[ 0 ].data = typeList.industry.map((item) => {
- return { name: `${item.name}技术解决方案`, url: `${kaifainUrl}/${item.slug}/` }
- })
- footer.link[ 1 ].data = typeList.techType.map((item) => {
- return { name: `${industryName}${item.name}技术解决方案`, url: `${kaifainUrl}/${industry}/${item.slug}/` }
- })
- } else {
- //非特定的url
- footer.link[ 0 ].name = "热门城市技术解决方案"
- footer.link[ 1 ].name = "行业领域技术解决方案"
- footer.link[ 0 ].data = typeList.city.map((item) => {
- return { name: `${item.name}技术解决方案`, url: `${kaifainUrl}/${item.slug}/` }
- })
- footer.link[ 1 ].data = typeList.industry.map((item) => {
- return { name: `${item.name}技术解决方案`, url: `${kaifainUrl}/${item.slug}/` }
- })
- }
- return footer
- }
- }
|