Commit e77ec803 by yangchen

实现assemblyList接口,informationList接口,将之前实现的接口改名为bannerList和computilityList

parent 5055cb78
......@@ -10,13 +10,16 @@ import request from '@/utils/request'
// }
export function banner() {
return request({ url: '/biz/banner-info/list', method: 'get' })
return request({
url: '/biz/banner-info/bannerList',
method: 'get'
})
}
// 获取组件服务列表数据
export function assemblyList (query) {
return request({
url: '/api/v1/assemblyList',
url: '/biz/assembly/assemblyList',
method: 'get',
params: query
})
......@@ -33,7 +36,7 @@ export function assemblyType (query) {
// 获取活动资讯列表数据
export function informationList (query) {
return request({
url: '/api/v1/information',
url: '/biz/information/informationList',
method: 'get',
params: query
})
......@@ -61,7 +64,7 @@ export function partnerList (query) {
// 获取计算资源相关
export function informationResourceList(query){
return request({
url:'/biz/computility-information/list',
url:'/biz/computility-information/computilityList',
method: 'get'
})
}
......@@ -35,7 +35,7 @@
@click="i.id === 1? $router.push('/computingResource/resourceList?type=' + x.category):openAssembly(x)"
>
<!-- style="background: url("@/assets/images/indexImg/resource1.png") no-repeat center center / 100%;"-->
<div class="resource-box" :style="{background: `url(${index === 0 ?baseUrl+x.image:baseUrl+x.homeImage}) no-repeat center center / 100%`}">
<div class="resource-box" :style="{background: `url(${index === 0 ?x.image:x.homeImage}) no-repeat center center / 100%`}">
<div class="title">{{ x.title }}</div>
<div class="introduce">{{ index === 0 ? x.information : x.description }}</div>
</div>
......@@ -74,7 +74,7 @@
<div class="content" v-html="informationMainData.remark"></div>
</div>
</div>
<img :src="baseUrl + informationMainData.image" alt="">
<img :src="informationMainData.image" alt="">
</div>
</div>
</el-col>
......@@ -190,35 +190,71 @@ const dialogTitle = ref('')
const iframeSrc = ref('')
const iframeShow = ref(false)
// function getBanner() {
// banner().then(res => {
// bannerImgList.value = res.data.sort(function (a, b) {
// return a.orderNum - b.orderNum
// })
// })
// }
function getBanner() {
banner().then(res => {
bannerImgList.value = res.data.sort(function (a, b) {
// 筛选条件:showStatus为1且image字段存在且不为空
const validData = res.data.filter(item =>
item.showStatus === 1 &&
item.image &&
item.image.trim() !== ''
);
// 对筛选后的数据进行排序
bannerImgList.value = validData.sort(function (a, b) {
return a.orderNum - b.orderNum
})
})
}
// function getBanner() {
// banner().then(res => {
// // 筛选条件:showStatus为1且image字段存在且不为空
// const validData = res.data.filter(item =>
// item.showStatus === 1 &&
// item.image &&
// item.image.trim() !== ''
// );
//
// // 对筛选后的数据进行排序
// bannerImgList.value = validData.sort(function (a, b) {
getBanner()
// function getAssemblyList() {
// assemblyList({type: 0}).then(res => {
// const data = res.data.sort(function (a, b) {
// return a.orderNum - b.orderNum
// })
// assemblyData.value = data.length > 3 ? data.slice(0, 3) : data
// list.value[1].assemblyData = data.length > 3 ? data.slice(0, 3) : data
// })
// }
getBanner()
function getAassemblyList() {
// function getAssemblyList() {
// assemblyList({type: 0}).then(res => {
// const data = res.data.sort(function (a, b) {
// return a.orderNum - b.orderNum
// }).map(item => {
// // 处理description字段,去除<p>标签
// if (item.description) {
// item.description = item.description.replace(/<p>/g, '').replace(/<\/p>/g, '')
// }
// return item
// })
// assemblyData.value = data.length > 3 ? data.slice(0, 3) : data
// list.value[1].assemblyData = data.length > 3 ? data.slice(0, 3) : data
// })
// }
function getAssemblyList() {
assemblyList({type: 0}).then(res => {
const data = res.data.sort(function (a, b) {
// 筛选条件:showStatus为1且description字段存在
const filteredData = res.data.filter(item =>
item.showStatus === true &&
item.description
);
const data = filteredData.sort(function (a, b) {
return a.orderNum - b.orderNum
}).map(item => {
// 处理description字段,去除<p>标签
if (item.description) {
item.description = item.description.replace(/<p>/g, '').replace(/<\/p>/g, '')
}
return item
})
assemblyData.value = data.length > 3 ? data.slice(0, 3) : data
list.value[1].assemblyData = data.length > 3 ? data.slice(0, 3) : data
......@@ -226,35 +262,79 @@ function getAassemblyList() {
}
// 计算自选
// function getResource() {
// informationResourceList().then(res => {
// list.value[0].assemblyData = res.data.length > 3 ? res.data.slice(0, 3) : res.data
// console.log(list.value[0].assemblyData, 'list.value[0].assemblyData')
// })
// }
function getResource() {
informationResourceList().then(res => {
list.value[0].assemblyData = res.data.length > 3 ? res.data.slice(0, 3) : res.data
console.log(list.value[0].assemblyData, 'list.value[0].assemblyData')
})
// 筛选条件:showStatus为true的数据
const filteredData = res.data.filter(item => item.showStatus === true);
// 可选:同时处理information字段,去除<p>标签
const processedData = filteredData.map(item => {
if (item.information) {
item.information = item.information.replace(/<p>/g, '').replace(/<\/p>/g, '');
}
return item;
});
list.value[0].assemblyData = processedData.length > 3 ? processedData.slice(0, 3) : processedData;
console.log(list.value[0].assemblyData, 'list.value[0].assemblyData');
});
}
getAassemblyList()
getAssemblyList()
getResource()
const informationData = ref([])
const informationMainData = ref({})
// function getInformation() {
// informationList().then(res => {
// res.data.forEach(item => {
// item.year = new Date(item.createTime).getFullYear()
// item.month = new Date(item.createTime).getMonth() + 1
// item.month = item.month < 10 ? '0' + item.month : item.month
// item.day = new Date(item.createTime).getDate()
// item.day = item.day < 10 ? '0' + item.day : item.day
// item.description = item.description.replace('<p><br></p>', '')
// })
// informationMainData.value = res.data.length ? res.data[0] : {}
// const arr = res.data.length ? res.data.slice(1, res.data.length) : []
// informationData.value = arr.length > 3 ? arr.slice(0, 3) : arr
// })
// }
function getInformation() {
informationList().then(res => {
res.data.forEach(item => {
// 筛选条件:showStatus为true的数据
const filteredData = res.data.filter(item => item.showStatus === true);
// 按创建时间降序排序(最新的在前)
const sortedData = filteredData.sort((a, b) => {
return new Date(b.createTime) - new Date(a.createTime);
});
sortedData.forEach(item => {
item.year = new Date(item.createTime).getFullYear()
item.month = new Date(item.createTime).getMonth() + 1
item.month = item.month < 10 ? '0' + item.month : item.month
item.day = new Date(item.createTime).getDate()
item.day = item.day < 10 ? '0' + item.day : item.day
item.description = item.description.replace('<p><br></p>', '')
// 使用正则表达式去除所有<p></p>标
if (item.description) {
item.description = item.description.replace(/<p>/g, '').replace(/<\/p>/g, '')
}
})
informationMainData.value = res.data.length ? res.data[0] : {}
const arr = res.data.length ? res.data.slice(1, res.data.length) : []
informationMainData.value = sortedData.length ? sortedData[0] : {}
const arr = sortedData.length ? sortedData.slice(1, sortedData.length) : []
informationData.value = arr.length > 3 ? arr.slice(0, 3) : arr
})
}
getInformation()
function openAssembly(data) {
......
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 sign in to comment