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