粒子研究院前台前端
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

96 lines
3.4 KiB

2 years ago
import Setting from '@/setting'
import Util from '@/libs/util'
export default {
data() {
return {
2 years ago
id: +this.$route.query.id
2 years ago
}
},
2 years ago
computed: {
2 years ago
site() {
return this.$route.query.siteId || this.$store.state.content.site
}
2 years ago
},
2 years ago
mounted() {
},
methods: {
// 点击栏目回调
columnTo(to) {
2 years ago
const { typeId,menuVisible } = to
console.log('typeId=>' ,typeId)
console.log('to=>' ,to)
2 years ago
console.log('menuVisible=>' ,menuVisible)
2 years ago
// 跳转链接
if (typeId === 2) {
2 years ago
if ( menuVisible === 1 || to.children.find(i=>i.menuVisible ===1)) return
2 years ago
let href = to.linkAddress
const cType = to.connectionType
if (cType !== 2) { // 非站外链接
const ids = href.split('-') // 栏目文章是用-分割的,栏目是必选,文章不是必选。选择了文章则跳转到文章页,否则跳转到栏目页
// 站点id:站内链接取当前站点,其他站点链接取siteSelection
const site = cType === 1 ?
2 years ago
(this.site) :
2 years ago
to.siteSelection
if (ids[1]) { // 文章
2 years ago
href = '/article?articleId=' + ids[1]
2 years ago
} else { // 栏目
const columnIds = ids[0].split(',')
href = '/column?id=' + columnIds[columnIds.length - 1]
}
href = this.$router.resolve(href + '&siteId=' + site).href
}
// 是否新窗口打开
if (to.isOpen) {
2 years ago
var userAgent = navigator.userAgent;
var isSafari = /Safari/.test(userAgent) && !/Chrome/.test(userAgent);
if(isSafari) {
window.location.href = href
}else {
window.open(href)
}
2 years ago
} else {
location.href = href
}
} else if (typeId !== 4 || (typeId === 4 && !to.children.length)) {
// 常规栏目跳转到column页,长页栏目直接获取path
2 years ago
this.$router.push(`/${typeId === 3 ? to.path : 'column'}?id=${to.id}&siteId=${this.site}`).catch(err => {})
2 years ago
}
},
2 years ago
// 跳转文章页面
toArtice(item) {
2 years ago
if (item.articleTemplate === 24) { // 链接
let href = item.linkAddress
const cType = item.connectionType
if (cType !== 2) { // 非站外链接
const ids = href.split('-') // 栏目文章是用-分割的,栏目是必选,文章不是必选。选择了文章则跳转到文章页,否则跳转到栏目页
// 站点id:站内链接取当前站点,其他站点链接取siteSelection
const site = cType === 1 ?
2 years ago
(this.site) :
2 years ago
item.siteSelection
if (ids[1]) { // 文章
href = '/article?articleId=' + ids[1]
} else { // 栏目
const columnIds = ids[0].split(',')
href = '/column?id=' + columnIds[columnIds.length - 1]
}
href = this.$router.resolve(href + '&siteId=' + site).href
}
// 是否新窗口打开
if (item.isOpen) {
2 years ago
var userAgent = navigator.userAgent;
var isSafari = /Safari/.test(userAgent) && !/Chrome/.test(userAgent);
if(isSafari) {
window.location.href = href
}else {
window.open(href)
}
2 years ago
} else {
location.href = href
}
} else {
2 years ago
this.$router.push(`/article?articleId=${item.id}&site=${this.site}&id=${item.columnId}`)
2 years ago
}
2 years ago
}
2 years ago
}
};