120 lines
2.4 KiB
Vue
120 lines
2.4 KiB
Vue
<template>
|
|
<div @click="goDetails(data._id)" class="c-list-item">
|
|
<div class="hd">
|
|
<div class="title">{{data.title}}</div>
|
|
<div class="num">{{data.view}}人玩过</div>
|
|
</div>
|
|
<div class="desc">{{data.desc}}</div>
|
|
<div class="tags">
|
|
<tag :key="index" :text="item" v-for="(item, index) in tags"></tag>
|
|
</div>
|
|
</div>
|
|
</template>
|
|
|
|
<script>
|
|
import tag from '@/components/tag'
|
|
import requestUtil from '@/utils/request'
|
|
import sdkManage from '@/utils/jcfw/SDKManage'
|
|
|
|
export default {
|
|
props: ['data'],
|
|
components: {
|
|
tag
|
|
},
|
|
data() {
|
|
return {
|
|
tags: []
|
|
}
|
|
},
|
|
async onLoad(options) {
|
|
sdkManage.init(options)
|
|
},
|
|
watch: {
|
|
data: {
|
|
handler: function(val) {
|
|
this.tags = this.data.tags !== '' ? this.data.tags.split(',') : []
|
|
},
|
|
immediate: true,
|
|
deep: true
|
|
}
|
|
},
|
|
|
|
methods: {
|
|
goDetails(id) {
|
|
setTimeout(() => {
|
|
sdkManage.uploadLog('click_test', {
|
|
id: id,
|
|
title: this.data.title,
|
|
tags: this.data.tags
|
|
})
|
|
}, 0)
|
|
this.$emit('clickItem', { _id: id })
|
|
requestUtil.postData('/view', { _id: id })
|
|
let objs = getCurrentPages();
|
|
console.log('wx.getCurrentPages');
|
|
console.log(objs);
|
|
let n = 0;
|
|
let bfind = false;
|
|
for(let i = objs.length - 1; i >=0; i--){
|
|
let obj = objs[i];
|
|
if(obj.route != 'pages/details/main'){
|
|
n++;
|
|
continue;
|
|
}
|
|
if(obj.options && obj.options._id == id){
|
|
bfind = true;
|
|
break;
|
|
}
|
|
n++;
|
|
}
|
|
if(bfind){
|
|
if(n == 0){
|
|
wx.pageScrollTo({scrollTop: 0});
|
|
}else{
|
|
wx.navigateBack({
|
|
delta: n
|
|
})
|
|
}
|
|
|
|
}else{
|
|
wx.navigateTo({
|
|
url: `/pages/details/main?_id=${id}`
|
|
})
|
|
}
|
|
}
|
|
}
|
|
}
|
|
</script>
|
|
|
|
<style scoped lang="less">
|
|
.c-list-item {
|
|
padding: 24rpx 16rpx;
|
|
border-bottom: 1px solid #f0f0f0;
|
|
background-color: #fff;
|
|
.hd {
|
|
display: flex;
|
|
justify-content: space-between;
|
|
align-items: center;
|
|
.title {
|
|
max-width: 460rpx;
|
|
text-overflow: ellipsis;
|
|
white-space: nowrap;
|
|
overflow: hidden;
|
|
font-weight: 700;
|
|
font-size: 36rpx;
|
|
}
|
|
.num {
|
|
font-size: 24rpx;
|
|
color: #ffdc34;
|
|
}
|
|
}
|
|
.desc {
|
|
max-height: 48px;
|
|
margin: 8rpx 0;
|
|
color: #999;
|
|
font-size: 32rpx;
|
|
line-height: 1.5;
|
|
overflow: hidden;
|
|
}
|
|
}
|
|
</style> |