Browse Source

封面与轮播图

qinhouyu 1 year ago
parent
commit
34e200f5e5
2 changed files with 36 additions and 7 deletions
  1. 17 0
      api/index/index.js
  2. 19 7
      pages/index/index.vue

+ 17 - 0
api/index/index.js

@@ -32,4 +32,21 @@ export function getList(query){
 		method: 'get',
 		data: query
 	})
+}
+
+//查询封面
+export function getCovers(){
+	return request({
+		url: '/my/img/getCover',
+		method: 'get'
+	})
+}
+
+
+//查询封面
+export function getCarousel(){
+	return request({
+		url: '/my/img/getCarousel',
+		method: 'get'
+	})
 }

+ 19 - 7
pages/index/index.vue

@@ -2,7 +2,7 @@
 	<view>
 		<!-- index.wxml -->
 		<view class="topBj">
-			<image :src="'https://tse1-mm.cn.bing.net/th/id/OIP-C.JsghMT_u8V52I4PSHow2hAHaEG?w=332&h=186&c=7&r=0&o=5&pid=1.7'"></image>
+			<image :src="loadImgSrc(bigImg)"></image>
 		</view>
 		<view class="container">
 			<!-- 主导航 -->
@@ -86,7 +86,7 @@
 				:circular="circular" class="banner">
 				<block v-for="(item, index) in banners" :key="index">
 					<swiper-item>
-						<image :src="item.src" mode="aspectFill"></image>
+						<image :src="loadImgSrc(item)" mode="aspectFill"></image>
 					</swiper-item>
 				</block>
 			</swiper>
@@ -219,7 +219,7 @@
 
 <script>
 	import {
-		getListToAnnouncement
+		getListToAnnouncement,getCovers,getCarousel
 	} from '@/api/index/index.js';
 	import {
 		governmentListData
@@ -233,11 +233,11 @@
 	export default {
 		data() {
 			return {
+				bigImg:'https://tse1-mm.cn.bing.net/th/id/OIP-C.JsghMT_u8V52I4PSHow2hAHaEG?w=332&h=186&c=7&r=0&o=5&pid=1.7',
 				// 图片轮播
-				banners: [{
-						src: 'https://tse1-mm.cn.bing.net/th/id/OIP-C.JsghMT_u8V52I4PSHow2hAHaEG?w=332&h=186&c=7&r=0&o=5&pid=1.7'
-					}
-				],
+				banners: [
+						'https://tse1-mm.cn.bing.net/th/id/OIP-C.JsghMT_u8V52I4PSHow2hAHaEG?w=332&h=186&c=7&r=0&o=5&pid=1.7'
+					],
 				announcementList: [{
 						id: '3',
 						announcementTitle: '关于高质量推进土地整治工作赋能乡村振兴的通知'
@@ -358,6 +358,7 @@
 		},
 		created() {
 			this.getList()
+			this.getCovers()
 		},
 		onReachBottom() {
 			let pageNum = this.knowledgeParams.pageNum
@@ -374,6 +375,15 @@
 			}
 		},
 		methods: {
+			//封面与轮播图
+			getCovers(){
+				getCovers().then(res=>{
+					this.bigImg = res.data
+				})
+				getCarousel().then(res=>{
+					this.banners = res.data
+				})	
+			},
 			// 热门知识获取数据
 			getList(pageNum) {
 				let params = {
@@ -393,11 +403,13 @@
 					url: '/pages/toLegal/toLegal'
 				});
 			},
+			//政策推荐
 			toGovernmentList() {
 				uni.navigateTo({
 					url: '/pages/toGovernmentList/toGovernmentList'
 				});
 			},
+			//惠民通
 			toGovernmentList1() {
 				uni.navigateTo({
 					url: '/pages/toGovernmentList/toGovernmentList?type=10'