Commit e77ec803 by yangchen

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

parent 5055cb78
...@@ -10,13 +10,16 @@ import request from '@/utils/request' ...@@ -10,13 +10,16 @@ import request from '@/utils/request'
// } // }
export function banner() { 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) { export function assemblyList (query) {
return request({ return request({
url: '/api/v1/assemblyList', url: '/biz/assembly/assemblyList',
method: 'get', method: 'get',
params: query params: query
}) })
...@@ -33,7 +36,7 @@ export function assemblyType (query) { ...@@ -33,7 +36,7 @@ export function assemblyType (query) {
// 获取活动资讯列表数据 // 获取活动资讯列表数据
export function informationList (query) { export function informationList (query) {
return request({ return request({
url: '/api/v1/information', url: '/biz/information/informationList',
method: 'get', method: 'get',
params: query params: query
}) })
...@@ -61,7 +64,7 @@ export function partnerList (query) { ...@@ -61,7 +64,7 @@ export function partnerList (query) {
// 获取计算资源相关 // 获取计算资源相关
export function informationResourceList(query){ export function informationResourceList(query){
return request({ return request({
url:'/biz/computility-information/list', url:'/biz/computility-information/computilityList',
method: 'get' method: 'get'
}) })
} }
...@@ -35,7 +35,7 @@ ...@@ -35,7 +35,7 @@
@click="i.id === 1? $router.push('/computingResource/resourceList?type=' + x.category):openAssembly(x)" @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%;"--> <!-- 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="title">{{ x.title }}</div>
<div class="introduce">{{ index === 0 ? x.information : x.description }}</div> <div class="introduce">{{ index === 0 ? x.information : x.description }}</div>
</div> </div>
...@@ -74,7 +74,7 @@ ...@@ -74,7 +74,7 @@
<div class="content" v-html="informationMainData.remark"></div> <div class="content" v-html="informationMainData.remark"></div>
</div> </div>
</div> </div>
<img :src="baseUrl + informationMainData.image" alt=""> <img :src="informationMainData.image" alt="">
</div> </div>
</div> </div>
</el-col> </el-col>
...@@ -190,35 +190,71 @@ const dialogTitle = ref('') ...@@ -190,35 +190,71 @@ const dialogTitle = ref('')
const iframeSrc = ref('') const iframeSrc = ref('')
const iframeShow = ref(false) const iframeShow = ref(false)
// function getBanner() {
// banner().then(res => {
// bannerImgList.value = res.data.sort(function (a, b) {
// return a.orderNum - b.orderNum
// })
// })
// }
function getBanner() { function getBanner() {
banner().then(res => { 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 return a.orderNum - b.orderNum
}) })
}) })
} }
// function getBanner() {
// banner().then(res => { getBanner()
// // 筛选条件:showStatus为1且image字段存在且不为空
// const validData = res.data.filter(item => // function getAssemblyList() {
// item.showStatus === 1 && // assemblyList({type: 0}).then(res => {
// item.image && // const data = res.data.sort(function (a, b) {
// item.image.trim() !== ''
// );
//
// // 对筛选后的数据进行排序
// bannerImgList.value = validData.sort(function (a, b) {
// return a.orderNum - b.orderNum // 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
// }) // })
// } // }
// function getAssemblyList() {
getBanner() // assemblyList({type: 0}).then(res => {
// const data = res.data.sort(function (a, b) {
function getAassemblyList() { // 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 => { 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 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 assemblyData.value = data.length > 3 ? data.slice(0, 3) : data
list.value[1].assemblyData = 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() { ...@@ -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() { function getResource() {
informationResourceList().then(res => { informationResourceList().then(res => {
list.value[0].assemblyData = res.data.length > 3 ? res.data.slice(0, 3) : res.data // 筛选条件:showStatus为true的数据
console.log(list.value[0].assemblyData, 'list.value[0].assemblyData') 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() getResource()
const informationData = ref([]) const informationData = ref([])
const informationMainData = 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() { function getInformation() {
informationList().then(res => { 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.year = new Date(item.createTime).getFullYear()
item.month = new Date(item.createTime).getMonth() + 1 item.month = new Date(item.createTime).getMonth() + 1
item.month = item.month < 10 ? '0' + item.month : item.month item.month = item.month < 10 ? '0' + item.month : item.month
item.day = new Date(item.createTime).getDate() item.day = new Date(item.createTime).getDate()
item.day = item.day < 10 ? '0' + item.day : item.day 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] : {} informationMainData.value = sortedData.length ? sortedData[0] : {}
const arr = res.data.length ? res.data.slice(1, res.data.length) : [] const arr = sortedData.length ? sortedData.slice(1, sortedData.length) : []
informationData.value = arr.length > 3 ? arr.slice(0, 3) : arr informationData.value = arr.length > 3 ? arr.slice(0, 3) : arr
}) })
} }
getInformation() getInformation()
function openAssembly(data) { 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