You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

142 lines
2.9 KiB

4 years ago
<template>
<view class="dabang-share-box" v-else>
3 years ago
<view class="dabang-share-item" v-for="(item,index) in studyList" :key="index">
4 years ago
<view class="user-info-box acea-row row-middle">
<view class="header-img">
3 years ago
<image :src="item.avatar" mode="aspectFill"></image>
4 years ago
</view>
<view class="acea-row row-column row-center">
3 years ago
<view class="name">{{item.realName}}</view>
<view class="create-time">{{item.recordTime}}</view>
4 years ago
</view>
</view>
3 years ago
<view class="share-word">{{item.content}}</view>
<view class="img-box acea-row row-left">
<image :src="imgUrl" v-for="(imgUrl,index) in item.imgPaths" mode="aspectFill"></image>
4 years ago
</view>
3 years ago
<view class="zan-box acea-row row-middle row-right" @click="voteClick(item)">
<image src="../../static/zan.png" v-if="!item.isVote"></image>
<image src="../../static/like.png" v-else></image>
<text class="zan-conunt">{{item.voteNum}}</text>
4 years ago
</view>
</view>
</view>
</template>
<script>
3 years ago
import { myStudylist , studyListVote } from "@/api/knowledge"
export default{
data(){
return {
id:'',
studyList:[]
}
},
onLoad() {
console.log(this.$yroute.query.id)
this.id = this.$yroute.query.id;
this.getMyStudyList()
},
methods:{
voteClick(item){
let id = item.id,
voteNum = item.voteNum,
isVote = !item.isVote;
this.studyList.map((item)=>{
if(item.id == id){
if(item.isVote){
item.voteNum = item.voteNum - 1
} else{
item.voteNum = item.voteNum + 1
}
item.isVote = !item.isVote
}
})
let data = {
"studylistRecordId": id,
"type": isVote ? '1' : '0'
}
studyListVote(data).then((res)=>{
if(res.success){
uni.showToast({
title: '操作成功!'
})
} else{
uni.showToast({
title: res.msg,
icon:'none'
})
}
})
},
getMyStudyList(){
uni.showLoading({
title:'正在加载中...'
})
myStudylist(this.id).then((res)=>{
uni.hideLoading()
this.studyList = res.data
})
}
}
}
4 years ago
</script>
<style lang="less" scoped>
.dabang-share-box{
width: 100%;
padding: 30rpx;
background-color: #fff;
.dabang-share-item{
color: #222;
padding:20rpx 0;
border-bottom: 1px solid #ececec;
.header-img{
width: 76rpx;
height: 76rpx;
border-radius: 50%;
overflow: hidden;
margin-right: 10rpx;
3 years ago
image{
width: 100%;
height: 100%;
}
4 years ago
}
.name{
font-size: 28rpx;
line-height: 40rpx;
}
.create-time{
font-size: 24rpx;
color: #999;
line-height: 34rpx;
}
.share-word{
font-size: 28rpx;
line-height: 46rpx;
margin: 22rpx 0 30rpx;
}
.img-box{
image{
3 years ago
width: 222rpx;
4 years ago
height: 206rpx;
3 years ago
margin-right: 10rpx;
margin-bottom: 10rpx;
border-radius: 10rpx;
}
image:nth-child(3n){
margin-right: 0;
4 years ago
}
}
.zan-box{
margin-top: 20rpx;
image{
width: 30rpx;
height: 32rpx;
3 years ago
margin-right: 10rpx;
4 years ago
}
}
}
}
</style>