上传文件至 '新闻小程序/pages/home'
This commit is contained in:
parent
dad31fa4ee
commit
23849c1847
|
@ -15,7 +15,7 @@ Page({
|
||||||
},
|
},
|
||||||
onLoad: function (options) {
|
onLoad: function (options) {
|
||||||
// 获取轮播图数据
|
// 获取轮播图数据
|
||||||
wx.cloud.database().collection('homepage').get()
|
wx.cloud.database().collection('lunbotu-news').get()
|
||||||
.then(res => {
|
.then(res => {
|
||||||
// console.log('轮播图数据:', res)
|
// console.log('轮播图数据:', res)
|
||||||
this.setData({
|
this.setData({
|
||||||
|
@ -25,6 +25,7 @@ Page({
|
||||||
.catch(res => {
|
.catch(res => {
|
||||||
console.log('获取失败', res)
|
console.log('获取失败', res)
|
||||||
})
|
})
|
||||||
|
// 获取新闻列表数据
|
||||||
this.getList(0)
|
this.getList(0)
|
||||||
},
|
},
|
||||||
// 获取新闻列表数据
|
// 获取新闻列表数据
|
||||||
|
@ -161,10 +162,10 @@ Page({
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
handleItemTap(e) {
|
|
||||||
// 1获取被点击的标题身上的索引
|
// 1获取被点击的标题身上的索引
|
||||||
// 2给data中的currentIndex赋值就可以了
|
// 2给data中的currentIndex赋值就可以了
|
||||||
// 3根据不同的索引来渲染右侧的商品内容
|
// 3根据不同的索引来渲染右侧的商品内容
|
||||||
|
handleItemTap(e) {
|
||||||
this.setData({
|
this.setData({
|
||||||
news_list: []
|
news_list: []
|
||||||
})
|
})
|
||||||
|
@ -175,9 +176,13 @@ Page({
|
||||||
selectIndex: index
|
selectIndex: index
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
|
lunboDetail(event) {
|
||||||
|
wx.navigateTo({
|
||||||
|
url: '/pages/news-detail/news-detail?id=' + event.currentTarget.dataset.id + '¤tIndex=' + 5,
|
||||||
|
})
|
||||||
|
},
|
||||||
// 点击事件-去往详情页
|
// 点击事件-去往详情页
|
||||||
gotoDetail(event) {
|
gotoDetail(event) {
|
||||||
// console.log('用户点击的新闻id:', event.currentTarget.dataset.id)
|
|
||||||
wx.navigateTo({
|
wx.navigateTo({
|
||||||
url: '/pages/news-detail/news-detail?id=' + event.currentTarget.dataset.id + '¤tIndex=' + currentIndex,
|
url: '/pages/news-detail/news-detail?id=' + event.currentTarget.dataset.id + '¤tIndex=' + currentIndex,
|
||||||
})
|
})
|
||||||
|
|
|
@ -2,14 +2,17 @@
|
||||||
<view class="cates">
|
<view class="cates">
|
||||||
<view class="cates_container">
|
<view class="cates_container">
|
||||||
<scroll-view class="top_menu" scroll-x="true">
|
<scroll-view class="top_menu" scroll-x="true">
|
||||||
<view class="top_menu_item {{index===selectIndex?'active':''}}" wx:for="{{topMenuList}}" wx:key="*this" bindtap="handleItemTap" data-index="{{index}}">{{item}}</view>
|
<view class="top_menu_item {{index===selectIndex?'active':''}}"
|
||||||
|
wx:for="{{topMenuList}}" wx:key="*this" bindtap="handleItemTap"
|
||||||
|
data-index="{{index}}">{{item}}</view>
|
||||||
</scroll-view>
|
</scroll-view>
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
|
|
||||||
<!-- 轮播公告 -->
|
<!-- 轮播公告 -->
|
||||||
<view class="swiper-view">
|
<view class="swiper-view">
|
||||||
<swiper class="swiper_container" vertical="true" autoplay="true" circular="true" interval="3000">
|
<swiper class="swiper_container" vertical="true"
|
||||||
|
autoplay="true" circular="true" interval="3000">
|
||||||
<block wx:for="{{msgList}}" wx:key="index">
|
<block wx:for="{{msgList}}" wx:key="index">
|
||||||
<swiper-item>
|
<swiper-item>
|
||||||
<view class="swiper-title">{{item.title}}</view>
|
<view class="swiper-title">{{item.title}}</view>
|
||||||
|
@ -21,9 +24,13 @@
|
||||||
|
|
||||||
<!-- 轮播图 -->
|
<!-- 轮播图 -->
|
||||||
<view class="lunbotuBlock">
|
<view class="lunbotuBlock">
|
||||||
<swiper indicator-dots indicator-color="gray" indicator-active-color="white" circular autoplay interval="5000">
|
<swiper indicator-dots
|
||||||
<swiper-item wx:for="{{lunboList}}" wx:key="id" class="lunbotuItem">
|
indicator-color="gray"
|
||||||
<image src="{{item.lunbotu_img}}"></image>
|
indicator-active-color="white"
|
||||||
|
circular autoplay interval="5000">
|
||||||
|
<swiper-item wx:for="{{lunboList}}" wx:key="_id" class="lunbotuItem">
|
||||||
|
<image src="{{item.news_img}}" bindtap="lunboDetail"
|
||||||
|
data-id="{{item._id}}"></image>
|
||||||
</swiper-item>
|
</swiper-item>
|
||||||
</swiper>
|
</swiper>
|
||||||
</view>
|
</view>
|
||||||
|
@ -34,11 +41,11 @@
|
||||||
<view class="news_list">
|
<view class="news_list">
|
||||||
<view wx:for="{{news_list}}" wx:key="_id">
|
<view wx:for="{{news_list}}" wx:key="_id">
|
||||||
<!-- 标题框(图片和文字) -->
|
<!-- 标题框(图片和文字) -->
|
||||||
<view class="pic-words">
|
<view class="pic-words" bindtap="gotoDetail" data-id="{{item._id}}">
|
||||||
<view wx:if="{{item.news_img != 'None'}}">
|
<view wx:if="{{item.news_img != 'None'}}">
|
||||||
<image class="news_image" src="{{item.news_img}}"></image>
|
<image class="news_image" src="{{item.news_img}}"></image>
|
||||||
</view>
|
</view>
|
||||||
<view class="news_title title-words" bindtap="gotoDetail" data-id="{{item._id}}">{{item.news_title}}</view>
|
<view class="news_title title-words">{{item.news_title}}</view>
|
||||||
</view>
|
</view>
|
||||||
<!-- 发布单位与发布时间 -->
|
<!-- 发布单位与发布时间 -->
|
||||||
<view class="publish">
|
<view class="publish">
|
||||||
|
|
|
@ -7,14 +7,12 @@
|
||||||
border-bottom-color: black;
|
border-bottom-color: black;
|
||||||
background-color: snow;
|
background-color: snow;
|
||||||
}
|
}
|
||||||
|
|
||||||
.top_menu_item {
|
.top_menu_item {
|
||||||
font-size: 18px;
|
font-size: 18px;
|
||||||
width: rpx;
|
width: rpx;
|
||||||
display: inline-block;
|
display: inline-block;
|
||||||
margin: 10rpx 20rpx;
|
margin: 10rpx 20rpx;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* 导航栏被选中后的样式 */
|
/* 导航栏被选中后的样式 */
|
||||||
.active {
|
.active {
|
||||||
color: #2b4b6b;
|
color: #2b4b6b;
|
||||||
|
|
Loading…
Reference in New Issue