mirror of
https://gitee.com/beijing_hongye_huicheng/lilishop-ui.git
synced 2025-12-18 08:55:52 +08:00
feat: ✨ pc端新增专题功能
This commit is contained in:
@@ -1,5 +1,16 @@
|
||||
import request, { Method } from "@/plugins/request.js";
|
||||
|
||||
/**
|
||||
* 获取首页专题数据
|
||||
*/
|
||||
export function getTopicData(id) {
|
||||
return request({
|
||||
url: `/buyer/other/pageData/get/${id}`,
|
||||
method: Method.GET,
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
// 获取首页楼层装修数据
|
||||
export function indexData(params) {
|
||||
return request({
|
||||
|
||||
@@ -32,7 +32,7 @@
|
||||
<!-- 搜索框、logo -->
|
||||
<Search></Search>
|
||||
<!-- 商品分类 -->
|
||||
<cateNav :showAlways="true" v-if="showNav" :large="carouselLarge" :opacity="carouselOpacity"></cateNav>
|
||||
<cateNav :showAlways="true" v-if="showNav && $route.query.pageType === 'SPECIAL'" :large="carouselLarge" :opacity="carouselOpacity"></cateNav>
|
||||
<!-- 楼层装修部分 -->
|
||||
<model-form ref="modelForm" :data="modelForm"></model-form>
|
||||
<!-- 底部栏 -->
|
||||
@@ -79,6 +79,12 @@ export default {
|
||||
carouselOpacity: false // 不同轮播分类样式
|
||||
};
|
||||
},
|
||||
props:{
|
||||
pageData:{
|
||||
type:null,
|
||||
default:""
|
||||
}
|
||||
},
|
||||
// created(){
|
||||
|
||||
// },
|
||||
@@ -136,7 +142,6 @@ export default {
|
||||
return cur;
|
||||
}, []);
|
||||
if(this.autoCoupList != '' && this.autoCoupList.length > 0){
|
||||
console.log(1231232132)
|
||||
this.showCpmodel = true;
|
||||
}
|
||||
storage.setItem('getTimes',datas)//存储缓存
|
||||
@@ -147,31 +152,41 @@ export default {
|
||||
|
||||
} ,
|
||||
getIndexData () {
|
||||
// 获取首页装修数据
|
||||
indexData({ clientType: 'PC' }).then(async (res) => {
|
||||
if (res.success) {
|
||||
let dataJson = JSON.parse(res.result.pageData);
|
||||
// 秒杀活动不是装修的数据,需要调用接口判断是否有秒杀商品
|
||||
// 轮播图根据不同轮播,样式不同
|
||||
for (let i = 0; i < dataJson.list.length; i++) {
|
||||
let type = dataJson.list[i].type
|
||||
if (type === 'carousel2') {
|
||||
this.carouselLarge = true;
|
||||
} else if (type === 'carousel1') {
|
||||
this.carouselLarge = true
|
||||
this.carouselOpacity = true
|
||||
} else if (type === 'seckill') {
|
||||
let seckill = await this.getListByDay()
|
||||
dataJson.list[i].options.list = seckill
|
||||
}
|
||||
if(this.pageData){
|
||||
this.parsePageData(JSON.stringify(this.pageData))
|
||||
}
|
||||
else{
|
||||
// 获取首页装修数据
|
||||
indexData({ clientType: 'PC' }).then(async (res) => {
|
||||
if (res.success && res.result) {
|
||||
this.parsePageData(res.result.pageData)
|
||||
}
|
||||
this.modelForm = dataJson;
|
||||
storage.setItem('navList', dataJson.list[1])
|
||||
this.showNav = true
|
||||
this.topAdvert = dataJson.list[0];
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
},
|
||||
|
||||
async parsePageData(pageData){
|
||||
let dataJson = JSON.parse(pageData);
|
||||
// 秒杀活动不是装修的数据,需要调用接口判断是否有秒杀商品
|
||||
// 轮播图根据不同轮播,样式不同
|
||||
for (let i = 0; i < dataJson.list.length; i++) {
|
||||
let type = dataJson.list[i].type
|
||||
if (type === 'carousel2') {
|
||||
this.carouselLarge = true;
|
||||
} else if (type === 'carousel1') {
|
||||
this.carouselLarge = true
|
||||
this.carouselOpacity = true
|
||||
} else if (type === 'seckill') {
|
||||
let seckill = await this.getListByDay()
|
||||
dataJson.list[i].options.list = seckill
|
||||
}
|
||||
}
|
||||
this.modelForm = dataJson;
|
||||
storage.setItem('navList', dataJson.list[1])
|
||||
this.showNav = true
|
||||
this.topAdvert = dataJson.list[0];
|
||||
},
|
||||
|
||||
async getListByDay () { // 当天秒杀活动
|
||||
const res = await seckillByDay()
|
||||
if (res.success && res.result.length) {
|
||||
|
||||
37
buyer/src/pages/Topic.vue
Normal file
37
buyer/src/pages/Topic.vue
Normal file
@@ -0,0 +1,37 @@
|
||||
<template>
|
||||
<div v-if="pageData">
|
||||
<Index :page-data="pageData" />
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import Index from './Index.vue'
|
||||
import { getTopicData } from '@/api/index'
|
||||
export default {
|
||||
data() {
|
||||
return {
|
||||
pageData: ""
|
||||
}
|
||||
},
|
||||
components: { Index },
|
||||
mounted() {
|
||||
// 接收id进行查询
|
||||
const id = this.$route.query.id
|
||||
this.init(id)
|
||||
},
|
||||
methods: {
|
||||
async init(id) {
|
||||
const res = await getTopicData(id)
|
||||
if (res.success) {
|
||||
console.log(res.result)
|
||||
// 直接复用首页就行
|
||||
if (res.result.pageData) {
|
||||
this.pageData = JSON.parse(res.result.pageData)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped></style>
|
||||
@@ -88,7 +88,7 @@ const Home = (resolve) => require(["@/pages/user/Home"], resolve);
|
||||
|
||||
const Merchant = (resolve) => require(["@/pages/Merchant"], resolve);
|
||||
const UserMain = (resolve) => require(["@/pages/home/Main"], resolve);
|
||||
|
||||
const topic = (resolve) => require(["@/pages/Topic"], resolve);
|
||||
/**
|
||||
* 店铺入驻
|
||||
*/
|
||||
@@ -113,6 +113,11 @@ export default new Router({
|
||||
name: "Index",
|
||||
component: Index,
|
||||
},
|
||||
{
|
||||
path: "/topic", // 首页
|
||||
name: "topic",
|
||||
component: topic,
|
||||
},
|
||||
{
|
||||
path: "/login", // 登陆
|
||||
name: "login",
|
||||
|
||||
Reference in New Issue
Block a user