123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182 |
- <template>
- <view class="">
- <view class="bg">
-
- </view>
- <view class="new_list position">
- <view class="search">
- <image src="../../static/images/search.png" mode=""></image>
- <input type="text" v-model="search" placeholder="请输入搜索内容" placeholder-style="font-size:14px;color:#D9D0C8;"
- @change='Search' @confirm="Search" />
- </view>
- <view class="empty" v-if="news_list== undefined||news_list.length == 0">
- <u-empty text="没有内容哦!" mode="list"></u-empty>
- </view>
- <view class="news_item" v-for="(item,index) in news_list" :key="index" @click="to_new_detail(item.id)">
- <view class="item_left">
- <image :src="item.cover_resource?item.cover_resource.url:url" mode="aspectFill"></image>
- </view>
- <view class="item_right">
- <view class="item_title">
- {{item.title}}
- </view>
- <view class="item_num">
- <text>{{item.created_at}}</text>
- <text>阅读 {{item.view_count}}</text>
- </view>
- </view>
- </view>
- </view>
- </view>
- </template>
- <script>
- export default{
- data(){
- return{
- news_list: [
-
- ],
- page:1,
- last:false,
- search: '',
- category_id:''
- }
- },
- onShow() {
-
- },
- onLoad(options) {
- this.category_id=options.category_id
- this.getNew()
- },
- // 触底加载更多
- onReachBottom() {
- if (!this.last) {
- this.page++
- }
- console.log(this.page)
- this.getNew()
- },
- methods:{
-
-
- getNew() {
- this.$u.get('/page/news', {
- title: this.search,
- page: this.page,
- category_id:this.category_id
- }).then(res => {
- console.log(res, '新闻详情')
- let data = res.data.data
- if (this.page > 1 && data.length == 0) {
- uni.showToast({
- title: '暂无更多',
- icon: 'none'
- })
- this.last = true
- } else {
- this.news_list = this.news_list.concat(data)
- }
- })
- },
- //搜索
- Search() {
- console.log('pppp')
- this.page = 1
- this.news_list = []
- this.getNew()
- },
- to_new_detail(id) {
- uni.navigateTo({
- url: 'news_detail?id=' + id
- })
- },
- }
- }
- </script>
- <style lang="scss" scoped>
- .new_list{
- padding: 20px 16px 20px;
- // background-color: #F9F9FB;
- .empty{
- margin-top: 45%;
- }
- .search {
- display: flex;
- align-items: center;
- height: 52px;
- box-shadow: 0px 8px 16px rgba(12, 20, 61, 0.06);
- border-radius: 10px;
- // padding-top: 20px;
- background-color: #fff;
-
- image {
- width: 16px;
- height: 16px;
- margin-left: 20px;
- margin-right: 20px;
- }
- }
- .news_item {
- background-color: #fff;
- display: flex;
- align-items: center;
- padding: 10px 8px;
- margin-top: 20px;
- box-shadow: 0px 8px 12px rgba(12, 20, 61, 0.06);
- border-radius: 4px;
- .item_left {
- width: 92px;
- height: 76px;
- overflow: hidden;
- flex-shrink: 0;
- margin-right: 8px;
- border-radius: 4px;
-
- image {
- width: 92px;
- height: 76px;
- }
- }
-
- .item_right {
- width: 100%;
- .item_title {
- height: 40px;
- overflow: hidden;
- -webkit-line-clamp: 2;
- text-overflow: ellipsis;
- display: -webkit-box;
- -webkit-box-orient: vertical;
- font-size: 15px;
- font-family: Graphit;
- font-weight: 500;
- line-height: 20px;
- color: #282828;
- }
-
- .item_num {
- margin-top: 10px;
- font-size: 10px;
- font-family: PingFang HK;
- font-weight: 400;
- color: #B2B2B2;
-
- text {
- display: inline-block;
- width: 50%;
- overflow: hidden;
-
- &:last-child {
- text-align: right;
- }
- }
-
-
- }
- }
- }
- }
- </style>
|