提交 cd2c8b54 authored 作者: lihuihui's avatar lihuihui

替换新接口

上级 a32b4811
<template> <template>
<div> <div class="link-content">
<template v-if="item.news"> <template v-if="item.news">
<nuxt-link <a
v-if="typeof item.news.data.source == 'string'" :target="item.news.data.uri !== '' ? '_blank' : '_self'"
:target="item.news.data.source !== '' ? '_blank' : '_self'" :href="item.news.data.uri !== '' ? item.news.data.uri : `${item.news.path}/${item.news.data.id}`">
:to="item.news.data.source !== '' ? item.news.data.source : `${item.news.path}/${item.news.data.id}`">
<slot /> <slot />
</nuxt-link> </a>
</template> </template>
<template v-else> <template v-else>
<nuxt-link <nuxt-link
...@@ -22,3 +21,8 @@ export default { ...@@ -22,3 +21,8 @@ export default {
props: { item: { type: Object } } props: { item: { type: Object } }
} }
</script> </script>
<style lang="scss" scoped>
.link-content{
height: 100%;
}
</style>
...@@ -2,15 +2,8 @@ ...@@ -2,15 +2,8 @@
<div class="banner-content" @mouseenter="swiperStop" @mouseleave="swiperStart"> <div class="banner-content" @mouseenter="swiperStop" @mouseleave="swiperStart">
<div v-swiper:mySwiper="swiperOption" ref="mySwiper"> <div v-swiper:mySwiper="swiperOption" ref="mySwiper">
<div class="swiper-wrapper"> <div class="swiper-wrapper">
<div class="swiper-slide" v-for="(item, index) in listData" :key="index"> <div class="swiper-slide" v-for="(item, index) in list" :key="index">
<app-link :item="{ <img :src="item.web_img_uri" />
news: {
data: item,
path: '/news/hot'
}
}">
<img :src="item.photo_uri" />
</app-link>
</div> </div>
</div> </div>
<!-- <div class="swiper-pagination swiper-pagination-bullets"></div> --> <!-- <div class="swiper-pagination swiper-pagination-bullets"></div> -->
...@@ -29,7 +22,7 @@ export default { ...@@ -29,7 +22,7 @@ export default {
}, },
data() { data() {
return { return {
listData: [], list: [],
// 轮播图配置信息, 更多请参考 swiper.js 中文网,上面很详细。 // 轮播图配置信息, 更多请参考 swiper.js 中文网,上面很详细。
swiperOption: { swiperOption: {
speed: 400, speed: 400,
...@@ -46,15 +39,9 @@ export default { ...@@ -46,15 +39,9 @@ export default {
} }
}, },
async fetch() { async fetch() {
const params = { const params = { project_id: process.env.projectId, type_tag: 'ad_banner' }
page: 1, this.list = await this.$axios.get('/api/cms/api/v1/advertisements', { params }).then(res => res.data.data)
per_page: 100,
type: 69,
project_id: process.env.projectId
}
this.listData = await this.$axios.get('/api/zws/v1/cms/news', { params }).then(res => {
return res
})
}, },
computed: { computed: {
swiper() { swiper() {
......
<template> <template>
<div class="news-content-box"> <div class="news-content-box">
<m-title :data="titleParams" /> <m-title :data="titleParams" />
<div class="content-box"> <div class="content-box" v-if="Object.keys(listData.first).length">
<div class="news-left"> <div class="news-left">
<app-link :item="{ <app-link :item="{ news: { data: listData.first, path: '/news/hot' } }">
news: { <img :src="listData.first.web_img_uri" alt="" />
data: listData.first,
path: '/news/hot'
}
}">
<img :src="listData.first.photo_uri" alt="" />
<div class="mantle-box"> <div class="mantle-box">
<div class="tit">{{ listData.first.title }}</div> <div class="tit">{{ listData.first.title }}</div>
<div class="con-txt">{{ listData.first.summary }}</div> <div class="con-txt">{{ listData.first.abstract }}</div>
</div> </div>
</app-link> </app-link>
</div> </div>
<ul class="news-right"> <ul class="news-right">
<li v-for="(item, index) in listData.list" :key="index"> <li v-for="(item, index) in listData.list" :key="index">
<app-link :item="{ <app-link :item="{ news: { data: listData.first, path: '/news/hot' } }">
news: { <div class="time">{{ formatDate(item.start_time) }}</div>
data: listData.first,
path: '/news/hot'
}
}">
<div class="time">{{ item.created_time }}</div>
<div class="news-r-title">{{ item.title }}</div> <div class="news-r-title">{{ item.title }}</div>
<div class="del">{{ item.summary }}</div> <div class="del">{{ item.abstract }}</div>
</app-link> </app-link>
</li> </li>
</ul> </ul>
...@@ -43,14 +33,9 @@ export default { ...@@ -43,14 +33,9 @@ export default {
AppLink AppLink
}, },
async fetch() { async fetch() {
const params = { const params = { project_id: process.env.projectId, type_tag: 'article_news_hot', page: 1, limit: 4 }
page: 1, await this.$axios.get('/api/cms/api/v1/articles', { params }).then(res => {
per_page: 4, this.data = res.data.data || []
type: 80,
project_id: process.env.projectId
}
await this.$axios.get('/api/zws/v1/cms/news', { params }).then(res => {
this.data = res || []
}) })
}, },
data() { data() {
...@@ -59,10 +44,7 @@ export default { ...@@ -59,10 +44,7 @@ export default {
titleParams: { titleParams: {
name: '最新动态', name: '最新动态',
more: { more: {
path: '/news/hot', path: '/news/hot'
query: {
type: 80
}
} }
} }
} }
...@@ -74,17 +56,10 @@ export default { ...@@ -74,17 +56,10 @@ export default {
} }
}, },
methods: { methods: {
goPage(item) { formatDate(value) {
if (item.source === '') { const date = new Date(value * 1000)
this.$router.push({ console.log(date.getMonth())
path: '/news/hot-detail', return date.getFullYear() + '/' + (date.getMonth() + 1) + '/' + date.getDate()
query: {
id: item.id
}
})
} else {
window.open(item.source)
}
} }
} }
} }
......
...@@ -5,13 +5,8 @@ ...@@ -5,13 +5,8 @@
<div v-swiper:mySwiper="swiperOption" ref="mySwiper"> <div v-swiper:mySwiper="swiperOption" ref="mySwiper">
<div class="swiper-wrapper"> <div class="swiper-wrapper">
<div class="swiper-slide" v-for="(item, index) in listData" :key="index"> <div class="swiper-slide" v-for="(item, index) in listData" :key="index">
<app-link :item="{ <app-link :item="{ news: { data: item, path: '/news/hot' } }">
news: { <img :src="item.web_img_uri" />
data: item,
path: '/news/hot'
}
}">
<img :src="item.photo_uri" />
<div class="text">{{ item.title }}</div> <div class="text">{{ item.title }}</div>
</app-link> </app-link>
</div> </div>
...@@ -57,15 +52,8 @@ export default { ...@@ -57,15 +52,8 @@ export default {
} }
}, },
async fetch() { async fetch() {
const params = { const params = { project_id: process.env.projectId, type_tag: 'article_publish_class' }
page: 1, this.listData = await this.$axios.get('/api/cms/api/v1/articles', { params }).then(res => res.data.data)
per_page: 100,
type: 72,
project_id: process.env.projectId
}
this.listData = await this.$axios.get('/api/zws/v1/cms/news', { params }).then(res => {
return res
})
}, },
computed: { computed: {
swiper() { swiper() {
...@@ -84,18 +72,6 @@ export default { ...@@ -84,18 +72,6 @@ export default {
}, },
swiperStart() { swiperStart() {
this.swiper.autoplay.start() this.swiper.autoplay.start()
},
goPage(item) {
if (item.source === '') {
this.$router.push({
path: '/news/hot-detail',
query: {
id: item.id
}
})
} else {
window.open(item.source)
}
} }
} }
} }
......
...@@ -5,14 +5,9 @@ ...@@ -5,14 +5,9 @@
<div class="banner-box" @mouseenter="swiperStop" @mouseleave="swiperStart"> <div class="banner-box" @mouseenter="swiperStop" @mouseleave="swiperStart">
<div v-swiper:mySwiper="swiperOption" ref="mySwiper"> <div v-swiper:mySwiper="swiperOption" ref="mySwiper">
<div class="swiper-wrapper"> <div class="swiper-wrapper">
<div class="swiper-slide" v-for="(item, index) in listData" :key="index" @click="goPage(item)"> <div class="swiper-slide" v-for="(item, index) in listData" :key="index">
<app-link :item="{ <app-link :item="{ news: { data: item, path: '/news/hot' } }">
news: { <img :src="item.web_img_uri" />
data: item,
path: '/news/hot'
}
}">
<img :src="item.photo_uri" />
</app-link> </app-link>
</div> </div>
</div> </div>
...@@ -103,7 +98,7 @@ export default { ...@@ -103,7 +98,7 @@ export default {
degree: '', degree: '',
name: '', name: '',
phone: '', phone: '',
channel: 19960, // channel: 19960,
project_id: process.env.projectId project_id: process.env.projectId
}, },
value: '', value: '',
...@@ -130,15 +125,8 @@ export default { ...@@ -130,15 +125,8 @@ export default {
} }
}, },
async fetch() { async fetch() {
const params = { const params = { project_id: process.env.projectId, type_tag: 'kelley_alumni_share' }
page: 1, this.listData = await this.$axios.get('/api/cms/api/v1/articles', { params }).then(res => res.data.data)
per_page: 100,
type: 81,
project_id: process.env.projectId
}
this.listData = await this.$axios.get('/api/zws/v1/cms/news', { params }).then(res => {
return res
})
}, },
computed: { computed: {
swiper() { swiper() {
...@@ -178,19 +166,7 @@ export default { ...@@ -178,19 +166,7 @@ export default {
this.swiper.autoplay.stop() this.swiper.autoplay.stop()
}, },
swiperStart() { swiperStart() {
// this.swiper.autoplay.start() this.swiper.autoplay.start()
},
goPage(item) {
if (item.source === '') {
this.$router.push({
path: '/alumni/detail',
query: {
id: item.id
}
})
} else {
window.open(item.source)
}
} }
} }
} }
...@@ -198,7 +174,6 @@ export default { ...@@ -198,7 +174,6 @@ export default {
<style lang="scss" scoped> <style lang="scss" scoped>
.presence-content-box { .presence-content-box {
min-width: 1200px;
padding-top: 80px; padding-top: 80px;
.m-title { .m-title {
width: 1200px; width: 1200px;
......
...@@ -2,14 +2,28 @@ ...@@ -2,14 +2,28 @@
<div class="news-content-box"> <div class="news-content-box">
<ul class="list-content"> <ul class="list-content">
<template v-for="(item, index) in data"> <template v-for="(item, index) in data">
<li @click="handleClick(item)" :key="index"> <template v-if="item.uri">
<img :src="item.photo_uri" alt="" /> <a :href="item.uri" target="_black" :key="index">
<li>
<img :src="item.web_img_uri" alt="" />
<div class="right-con"> <div class="right-con">
<div class="time">{{ item.created_time }}</div> <div class="time">{{ formatDate(item.start_time) }}</div>
<div class="title">{{ item.title }}</div> <div class="title">{{ item.title }}</div>
<div class="text">{{ item.summary }}</div> <div class="text">{{ item.abstract }}</div>
</div> </div>
</li> </li>
</a>
</template>
<template v-else>
<li :key="index" @click="handleClick(item)">
<img :src="item.web_img_uri" alt="" />
<div class="right-con">
<div class="time">{{ formatDate(item.start_time) }}</div>
<div class="title">{{ item.title }}</div>
<div class="text">{{ item.abstract }}</div>
</div>
</li>
</template>
</template> </template>
</ul> </ul>
</div> </div>
...@@ -27,13 +41,16 @@ export default { ...@@ -27,13 +41,16 @@ export default {
} }
}, },
methods: { methods: {
formatDate(value) {
const date = new Date(value * 1000)
return date.getFullYear() + '/' + (date.getMonth() + 1) + '/' + date.getDate()
},
handleClick(item) { handleClick(item) {
if (item.source) {
window.open(item.source)
} else {
this.$emit('onClick', item) this.$emit('onClick', item)
} }
} },
mounted() {
console.log(this.data)
} }
} }
</script> </script>
......
...@@ -7,13 +7,8 @@ ...@@ -7,13 +7,8 @@
</div> </div>
<ul class="list-box"> <ul class="list-box">
<li v-for="(item, index) in listData" :key="index"> <li v-for="(item, index) in listData" :key="index">
<app-link :item="{ <app-link :item="{ news: { data: item, path: '/news/hot' } }">
news: { <img :src="item.web_img_uri" alt="" />
data: item,
path: '/news/hot'
}
}">
<img :src="item.photo_uri" alt="" />
<div class="dec">{{ item.title }}</div> <div class="dec">{{ item.title }}</div>
</app-link> </app-link>
</li> </li>
...@@ -35,19 +30,16 @@ export default { ...@@ -35,19 +30,16 @@ export default {
} }
}, },
async fetch() { async fetch() {
this.data = await this.$axios.get(`/api/zws/v1/cms/news/${this.$route.params.id}`).then(res => {
return res
})
const params = { const params = {
project_id: process.env.projectId,
type_tag: 'article_news_hot',
is_recommend: 1,
page: 1, page: 1,
per_page: 100, limit: 3
type: 80,
project_id: process.env.projectId
} }
this.listData = await this.$axios.get('/api/zws/v1/cms/news', { params }).then(res => { this.listData = await this.$axios.get('/api/cms/api/v1/articles', { params }).then(res => {
return res.filter((item, index) => { console.log(res.data.data)
return index < 3 return res.data.data
})
}) })
}, },
methods: { methods: {
......
...@@ -6,7 +6,7 @@ let config = {} ...@@ -6,7 +6,7 @@ let config = {}
if (process.env.NODE_ENV === 'production') { if (process.env.NODE_ENV === 'production') {
config = { config = {
env: { env: {
projectId: '1012', projectId: '6805762100502200320',
baseURL: 'https://project-api.ezijing.com', baseURL: 'https://project-api.ezijing.com',
loginURL: 'https://login.ezijing.com/auth' loginURL: 'https://login.ezijing.com/auth'
}, },
...@@ -15,7 +15,7 @@ if (process.env.NODE_ENV === 'production') { ...@@ -15,7 +15,7 @@ if (process.env.NODE_ENV === 'production') {
} else { } else {
config = { config = {
env: { env: {
projectId: '1012', projectId: '6805762100502200320',
baseURL: 'https://project-api.ezijing.com', baseURL: 'https://project-api.ezijing.com',
loginURL: 'https://login.ezijing.com/auth' loginURL: 'https://login.ezijing.com/auth'
}, },
......
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
<div class="el-icon-arrow-left"></div> <div class="el-icon-arrow-left"></div>
<div class="text">返回</div> <div class="text">返回</div>
</div> </div>
<div class="times">{{ data.created_time }}</div> <div class="times">{{ formatDate(data.start_time) }}</div>
<div class="titles">{{ data.title }}</div> <div class="titles">{{ data.title }}</div>
<div class="article-content" v-html="data.content"></div> <div class="article-content" v-html="data.content"></div>
<recommend /> <recommend />
...@@ -44,29 +44,16 @@ export default { ...@@ -44,29 +44,16 @@ export default {
} }
}, },
async fetch() { async fetch() {
this.data = await this.$axios.get(`/api/zws/v1/cms/news/${this.$route.params.id}`).then(res => { this.data = await this.$axios.get(`/api/cms/api/v1/article/${this.$route.params.id}/detail`).then(res => {
return res return res.data
})
const params = {
page: 1,
per_page: 100,
type: 74,
project_id: 1012
}
this.listData = await this.$axios.get('/api/zws/v1/cms/news', { params }).then(res => {
return res.filter((item, index) => {
return index < 3
})
}) })
}, },
mounted() {}, mounted() {},
methods: { methods: {
goPage(item) { formatDate(value) {
if (item.source) { const date = new Date(value * 1000)
window.open(item.source) console.log(date.getMonth())
} else { return date.getFullYear() + '/' + (date.getMonth() + 1) + '/' + date.getDate()
this.$router.push({ name: 'alumni-sharing-id', params: { id: item.id } })
}
} }
} }
} }
......
...@@ -15,15 +15,8 @@ export default { ...@@ -15,15 +15,8 @@ export default {
newsItem newsItem
}, },
async fetch() { async fetch() {
const params = { const params = { project_id: process.env.projectId, type_tag: 'kelley_alumni_share' }
page: 1, this.newsList = await this.$axios.get('/api/cms/api/v1/articles', { params }).then(res => res.data.data)
per_page: 100,
type: this.$route.query.type || 80,
project_id: process.env.projectId
}
this.newsList = await this.$axios.get('/api/zws/v1/cms/news', { params }).then(res => {
return res
})
}, },
data() { data() {
return { return {
......
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
<div class="el-icon-arrow-left"></div> <div class="el-icon-arrow-left"></div>
<div class="text">返回</div> <div class="text">返回</div>
</div> </div>
<div class="times">{{ data.created_time }}</div> <div class="times">{{ formatDate(data.start_time) }}</div>
<div class="titles">{{ data.title }}</div> <div class="titles">{{ data.title }}</div>
<div class="article-content" v-html="data.content"></div> <div class="article-content" v-html="data.content"></div>
<recommend /> <recommend />
...@@ -44,28 +44,15 @@ export default { ...@@ -44,28 +44,15 @@ export default {
} }
}, },
async fetch() { async fetch() {
this.data = await this.$axios.get(`/api/zws/v1/cms/news/${this.$route.params.id}`).then(res => { this.data = await this.$axios.get(`/api/cms/api/v1/article/${this.$route.params.id}/detail`).then(res => {
return res return res.data
})
const params = {
page: 1,
per_page: 100,
type: 80,
project_id: process.env.projectId
}
this.listData = await this.$axios.get('/api/zws/v1/cms/news', { params }).then(res => {
return res.filter((item, index) => {
return index < 3
})
}) })
}, },
methods: { methods: {
goPage(item) { formatDate(value) {
if (item.source) { const date = new Date(value * 1000)
window.open(item.source) console.log(date.getMonth())
} else { return date.getFullYear() + '/' + (date.getMonth() + 1) + '/' + date.getDate()
this.$router.push({ name: 'news-hot-id', params: { id: item.id } })
}
} }
} }
} }
......
...@@ -15,15 +15,8 @@ export default { ...@@ -15,15 +15,8 @@ export default {
newsItem newsItem
}, },
async fetch() { async fetch() {
const params = { const params = { project_id: process.env.projectId, type_tag: this.$route.query.type || 'article_news_hot' }
page: 1, this.newsList = await this.$axios.get('/api/cms/api/v1/articles', { params }).then(res => res.data.data)
per_page: 100,
type: this.$route.query.type || 80,
project_id: process.env.projectId
}
this.newsList = await this.$axios.get('/api/zws/v1/cms/news', { params }).then(res => {
return res
})
}, },
data() { data() {
return { return {
......
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
<div class="el-icon-arrow-left"></div> <div class="el-icon-arrow-left"></div>
<div class="text">返回</div> <div class="text">返回</div>
</div> </div>
<div class="times">{{ data.created_time }}</div> <div class="times">{{ formatDate(data.start_time) }}</div>
<div class="titles">{{ data.title }}</div> <div class="titles">{{ data.title }}</div>
<div class="article-content" v-html="data.content"></div> <div class="article-content" v-html="data.content"></div>
<recommend /> <recommend />
...@@ -45,29 +45,16 @@ export default { ...@@ -45,29 +45,16 @@ export default {
} }
}, },
async fetch() { async fetch() {
this.data = await this.$axios.get(`/api/zws/v1/cms/news/${this.$route.query.id}`).then(res => { this.data = await this.$axios.get(`/api/cms/api/v1/article/${this.$route.params.id}/detail`).then(res => {
return res return res.data
})
const params = {
page: 1,
per_page: 100,
type: 53,
project_id: process.env.projectId
}
this.listData = await this.$axios.get('/api/zws/v1/cms/news', { params }).then(res => {
return res.filter((item, index) => {
return index < 3
})
}) })
}, },
mounted() {}, mounted() {},
methods: { methods: {
goPage(item) { formatDate(value) {
if (item.source) { const date = new Date(value * 1000)
window.open(item.source) console.log(date.getMonth())
} else { return date.getFullYear() + '/' + (date.getMonth() + 1) + '/' + date.getDate()
this.$router.push({ name: 'news-interview-id', params: { id: item.id } })
}
} }
} }
} }
......
<template> <template>
<div class="hot-content-box"> <div class="hot-content-box">
<app-frame :data="frameParams"> <app-frame :data="frameParams">
...@@ -16,15 +15,8 @@ export default { ...@@ -16,15 +15,8 @@ export default {
newsItem newsItem
}, },
async fetch() { async fetch() {
const params = { const params = { project_id: process.env.projectId, type_tag: 'kelley_interview' }
page: 1, this.newsList = await this.$axios.get('/api/cms/api/v1/articles', { params }).then(res => res.data.data)
per_page: 100,
type: this.$route.query.type || 53,
project_id: 1012
}
this.newsList = await this.$axios.get('/api/zws/v1/cms/news', { params }).then(res => {
return res
})
}, },
data() { data() {
return { return {
......
...@@ -14,16 +14,39 @@ const httpRequest = axios.create({ ...@@ -14,16 +14,39 @@ const httpRequest = axios.create({
// 请求拦截 // 请求拦截
httpRequest.interceptors.request.use( httpRequest.interceptors.request.use(
function(config) { function(config) {
if (config.headers['Content-Type'] === 'application/x-www-form-urlencoded') {
config.data = qs.stringify(config.data)
}
if (config.headers['Content-Type'] === 'multipart/form-data') { if (config.headers['Content-Type'] === 'multipart/form-data') {
const form = new window.FormData() const form = new window.FormData()
for (const key in config.data) { for (const key in config.data) {
form.append(key, config.data[key]) form.append(key, config.data[key])
} }
config.data = form config.data = form
} else {
const defaultParams = {
timestamp: parseInt(Date.now() / 1000),
nonce: Math.random()
.toString(36)
.slice(-8)
} }
// 接口请求参数
let params = config.params || config.data
// 排序
function alphabeticalSort(a, b) {
return a.localeCompare(b)
}
params = Object.assign({}, defaultParams, params)
const str = qs.stringify(Object.assign({}, params, { salt: 'n7xAav2tSjn9Ysnr' }), { sort: alphabeticalSort })
const strs = qs.parse(str)
Object.keys(strs).map(item => {
strs[item] = Array.isArray(strs[item]) ? JSON.stringify(strs[item]) : strs[item]
})
params.signature = 'UG7wBenexQhiuD2wpCwuxkU0jqcj006d'
if (config.method === 'post') {
config.data = params
} else {
config.params = params
}
}
return config return config
}, },
function(error) { function(error) {
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论