Procházet zdrojové kódy

自定义导航优化

xhj před 2 roky
rodič
revize
815de8b533

+ 107 - 5
pages/matchList/index.vue

@@ -1,7 +1,20 @@
 <template>
 	<view v-if="isShow">
 		<view :class="(about.greyTheme==1?' grayTheme':'')">
-			<view class="ddflex" style="margin: 0 60rpx;">
+			<view style="width: 100%;">
+				<view v-for="(item, index) in contact" :key="index">
+					<!-- 弹窗广告 -->
+					<view v-if="bannerList&&bannerList.length>0">
+						<banner v-if="item == 'ad' && bannerShow" :bannerList="bannerList" :url="site" :web="url"
+							:config="about" :couponList="[]" :officeList="[]"
+							:districtTemplate="districtTemplate"></banner>
+					</view>
+					<district v-if="item == 'king_kong_district' && districtShow" :url="site" :web="url"
+						:districtTemplate="districtTemplate"></district>
+				
+				</view>
+			</view>
+			<!-- <view class="ddflex" style="margin: 0 60rpx;">
 				<view class="fflex">
 					<image style="width: 86rpx;height: 86rpx;margin: 0 auto 20rpx;" src="/static/images/rmhd.png"></image>
 					<view style="font-size: 24rpx;color: #302222;text-align: center;">热门活动</view>
@@ -14,7 +27,7 @@
 					<image style="width: 86rpx;height: 86rpx;margin: 0 auto 20rpx;" src="/static/images/zxzq.png"></image>
 					<view style="font-size: 24rpx;color: #302222;text-align: center;">赠险专区</view>
 				</view>
-			</view>
+			</view> -->
 			<view class="act-list" v-if="pageList && pageList.length > 0">
 				<view class="li" v-for="(item, index) in pageList" :key="index" @click="toActivity(item)">
 					<view class="imgbox"><image :src="item.pic" mode="aspectFill"></image></view>
@@ -57,8 +70,14 @@ const api = require('../../utils/api.js');
 const util = require('../../utils/util.js');
 const app = getApp();
 import foot from '../../components/nav-bar/index';
+import banner from '../../template/banner/banner';
+import district from '../../template/king_kong_district/king_kong_district';
 export default {
-	components: { foot },
+	components: {
+		foot,
+		banner,
+		district
+	},
 	data() {
 		return {
 			picUrlss: req.public.picUrls,
@@ -71,10 +90,25 @@ export default {
 			},
 			isLogin: false,
 			userinfovip: {},
-			about:''
+			about:'',
+			
+			bannerShow: false,
+			bannerList: [],
+			districtShow:false,
+			districtTemplate: {},
+			homeTemplate: [],//首页栏目配置
+			templateType: {
+				module_ad: 'ad',
+				//广告
+				module_type_district: 'type_district',
+				//分类导航
+				module_king_kong_district: 'king_kong_district', //金刚区
+			},
 		};
 	},
-	onLoad() {},
+	onLoad() {
+		this.getHomeTemplateConfig()
+	},
 	async onShow() {
 		this.about = await req.getsysConfig()
 		this.isLogin = req.isAuth();
@@ -103,6 +137,74 @@ export default {
 				url: url
 			});
 		},
+		
+		// 自定义
+		getHomeTemplateConfig() {
+			let _ts = this;
+			let page = 'matchIndex';
+			req.getRequest(
+				'/api/template/getTemplate', {
+					page: page
+				},
+				data => {
+					let arr = [];
+					data.forEach(it => {
+						arr.push(it.module);
+					});
+					this.setData({
+						contact: [...new Set(arr)],
+						contactShow: false
+					});
+					this.setData({
+						homeTemplate: data
+					});
+		
+					this.getRqeDatas();
+				}
+			);
+		},
+		async getRqeDatas() {
+			let that = this; //多门店
+			// 金刚区
+			let district = that.homeTemplate.filter(it => it.module == that.templateType
+				.module_king_kong_district);
+			if (district && district.length > 0 && district[0].state == 0) {
+				let data = district[0];
+				data.content = JSON.parse(district[0].content);
+				that.districtTemplate = data;
+				that.districtShow = true;
+			}
+			//顶部banner
+			let ad = that.homeTemplate.filter(it => it.module == that.templateType.module_ad);
+			if (ad && ad.length > 0 && ad[0].state == 0) {
+				await that.getBannerList(ad[0].module, ad[0].contentId);
+			}
+		},
+		
+		getBannerList(module, contentId) {
+			//banner图
+			let that = this;
+			return new Promise((resolve, reject) => {
+				req.getRequest(
+					'/api/banner', {
+						groupId: contentId
+					},
+					data => {
+						if (module == that.templateType.module_ad) {
+							that.setData({
+								bannerList: data,
+								bannerShow: true
+							});
+						} else {
+							that.setData({
+								popAdList: data[0]
+							});
+						}
+						resolve();
+					}
+				);
+			})
+		},
 
 		getPageList(isShow) {
 			if (!this.isLoad) return false;

+ 16 - 0
template/king_kong_district/king_kong_district.css

@@ -11,3 +11,19 @@
 .nav .li button{font-size: 28rpx !important;color: #333 !important;}
 .nav .li image{width: 97rpx;height: 97rpx;margin: 0 auto 10rpx;}
 .grid{flex-wrap: wrap;}
+
+
+.cont{flex-wrap: wrap;font-size: 26rpx;}
+.cont .li{align-items: center;margin-right: 20rpx; color: #fff;margin-top: 5rpx;}
+.cont image{width: 30rpx;height: 30rpx;}
+.ss{padding-bottom:20rpx ;}
+.li3{width: 33% !important;text-align: center;font-size: 28rpx;margin-bottom: 30rpx;}
+.li3 button{font-size: 28rpx !important;color: #333 !important;}
+.li5{width: 20% !important;text-align: center;font-size: 28rpx;margin-bottom: 30rpx;}
+.li5 button{font-size: 28rpx !important;color: #333 !important;}
+.nav .li3 image{width: 140rpx;height: 140rpx;margin: 0 auto 10rpx;}
+.nav .li5 image{width: 75rpx;height: 75rpx;margin: 0 auto 10rpx;}
+.swiper2{width: 100%;height: 240rpx;}/*一行三个*/
+.swiper3{width: 100%;height: 432rpx;}/*两行三个*/
+.swiper4{width: 100%;height: 200rpx;}/*一行四个*/
+.swiper5{width: 100%;height: 160rpx;}/*一行五个*/

+ 15 - 1
template/king_kong_district/king_kong_district.vue

@@ -258,6 +258,15 @@
 				console.log('that.districtTemplate.content.lines==',that.districtTemplate.content.lines)
 				if (that.districtTemplate.content.lines == 1) {
 					that.swiperHeight = '150rpx'
+					if (that.districtTemplate.lineNumber == 3) {
+						that.swiperHeight = '200rpx'
+					}
+					if (that.districtTemplate.lineNumber == 4) {
+						that.swiperHeight = '150rpx'
+					}
+					if (that.districtTemplate.lineNumber == 5) {
+						that.swiperHeight = '130rpx'
+					}
 				}
 				if (that.districtTemplate.content.lines == 2) {
 					if (that.districtTemplate.lineNumber == 3) {
@@ -267,7 +276,12 @@
 					}
 					if (that.districtTemplate.lineNumber == 4) {
 						that.setData({
-							swiperHeight: '200px'
+							swiperHeight: '380rpx'
+						})
+					}
+					if (that.districtTemplate.lineNumber == 5) {
+						that.setData({
+							swiperHeight: '320rpx'
 						})
 					}
 				}