jiazhipeng 4 months ago
parent
commit
efb302de38
  1. 116
      pages/index/index.vue

116
pages/index/index.vue

@ -70,19 +70,42 @@
{{item.title}} {{item.title}}
</view> </view>
</view> </view>
<view class="hot-box"> <view class="hot-box" v-if="hotIndex==0">
<view class="hot-column" v-for="(column, index) in 2" :key="index"> <view class="hot-column" v-for="(column, index) in 2" :key="index">
<view v-for="(item,indexs) in getColumnItems(index)" :key="indexs" class="hot-item" @click="gotoHotDetail(item)"> <view v-if="indexs%2==1&&column==0" v-for="(item,indexs) in hotList" :key="indexs" class="hot-item" @click="gotoHotDetail(item)">
<view class="image-container"> <view class="image-container">
<image :src="item.src" mode="widthFix" class="hot-img" lazy-load="true"></image> <image :src="showImg(item.goods.image)" mode="widthFix" class="hot-img" lazy-load="true"></image>
<!-- <image src="https://static.ticket.sz-trip.com/cgc/images/index/plays.png" mode="widthFix" class="play-img" v-if="hotIndex && item.genre == 'video'" lazy-load="true"></image> --> </view>
<view class="hot-content">
<view class="title text-overflowRows">{{item.title || item.goods.title}}</view>
</view>
</view>
<view v-if="indexs%2==0&&column==1" v-for="(item,indexs) in hotList" :key="indexs" class="hot-item" @click="gotoHotDetail(item)">
<view class="image-container">
<image :src="showImg(item.goods.image)" mode="widthFix" class="hot-img" lazy-load="true"></image>
</view>
<view class="hot-content">
<view class="title text-overflowRows">{{item.title || item.goods.title}}</view>
</view>
</view>
</view>
</view>
<view class="hot-box" v-else>
<view class="hot-column" v-for="(column, index) in 2" :key="index">
<view v-if="indexs%2==1&&column==0" v-for="(item,indexs) in hotList1" :key="indexs" class="hot-item" @click="gotoHotDetail(item)">
<view class="image-container">
<image :src="showImg(item.goods.image)" mode="widthFix" class="hot-img" lazy-load="true"></image>
</view>
<view class="hot-content">
<view class="title text-overflowRows">{{item.title || item.goods.title}}</view>
</view>
</view>
<view v-if="indexs%2==0&&column==1" v-for="(item,indexs) in hotList1" :key="indexs" class="hot-item" @click="gotoHotDetail(item)">
<view class="image-container">
<image :src="showImg(item.goods.image)" mode="widthFix" class="hot-img" lazy-load="true"></image>
</view> </view>
<view class="hot-content"> <view class="hot-content">
<view class="title text-overflowRows">{{item.title || item.goods.title}}</view> <view class="title text-overflowRows">{{item.title || item.goods.title}}</view>
<!-- <view class="subtitle" v-if="hotIndex && item.genre == 'video'">
<image src="https://static.ticket.sz-trip.com/tongli/images/index/user.png" mode="aspectFill"></image>
{{item.author}}
</view> -->
</view> </view>
</view> </view>
</view> </view>
@ -140,8 +163,10 @@
id: '41' id: '41'
} }
], ],
hotIndex: 0, hotIndex: 0,
hotList: [], hotList: [],
hotList1: [],
isLoading: false, isLoading: false,
limit: 4, limit: 4,
} }
@ -157,12 +182,14 @@
this.initRectInfo() this.initRectInfo()
this.getList() this.getList()
this.initHotList()
this.changeType(0) this.changeType(0)
}, },
onReachBottom() { onReachBottom() {
setTimeout(() => { // setTimeout(() => {
if (!this.isLoading) this.getHotList(); // // if (!this.isLoading) this.getHotList();
}, 1000); // this.getHotList()
// }, 1000);
}, },
methods: { methods: {
viewDetail(item) { viewDetail(item) {
@ -263,30 +290,53 @@
} }
}, },
// //
getColumnItems(columnIndex) { // getColumnItems(columnIndex) {
const columnItems = []; // const columnItems = [];
this.hotList.forEach((item, index) => { // this.hotList.forEach((item, index) => {
// switch (this.hotIndex) { // // switch (this.hotIndex) {
// case 1: // // case 1:
// item.src = this.showImg(item.image); // // item.src = this.showImg(item.image);
// break; // // break;
// default: // // default:
// item.src = this.showImg(item.goods.image); // // item.src = this.showImg(item.goods.image);
// } // // }
item.src = this.showImg(item.goods.image); // item.src = this.showImg(item.goods.image);
if (index % 2 === columnIndex) { // if (index % 2 === columnIndex) {
columnItems.push(item); // columnItems.push(item);
} // }
}); // });
return columnItems; // return columnItems;
}, // },
// //
changeType(index) { changeType(index) {
this.hotIndex = index this.hotIndex = index
this.isLoading = false // this.isLoading = false
// if (index==0) {
// this.hotList = this.hotList1
// }
// this.getHotList()
},
initHotList () {
this.hotList = [] this.hotList = []
this.getHotList() this.hotList1 = []
this.Post({
tag_id: 51,
offset: this.hotList.length,
limit: 100,
},'/api/tag/getGoodsByTagId').then(res => {
if(res.data.length < this.limit) this.isLoading = true
this.hotList = this.hotList.concat(res.data)
})
this.Post({
tag_id: 52,
offset: this.hotList1.length,
limit: 100,
},'/api/tag/getGoodsByTagId').then(res => {
if(res.data.length < this.limit) this.isLoading = true
this.hotList1 = this.hotList1.concat(res.data)
})
}, },
getHotList() { getHotList() {
if(this.hotIndex == 1) { if(this.hotIndex == 1) {
@ -302,11 +352,11 @@
// }) // })
this.Post({ this.Post({
tag_id: 52, tag_id: 52,
offset: this.hotList.length, offset: this.hotList1.length,
limit: this.limit, limit: this.limit,
},'/api/tag/getGoodsByTagId').then(res => { },'/api/tag/getGoodsByTagId').then(res => {
if(res.data.length < this.limit) this.isLoading = true if(res.data.length < this.limit) this.isLoading = true
this.hotList = this.hotList.concat(res.data) this.hotList1 = this.hotList.concat(res.data)
}) })
}else { }else {
this.Post({ this.Post({

Loading…
Cancel
Save