Files
2023-08-04 13:14:48 +08:00

1049 lines
24 KiB
Vue
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<template>
<view class="container">
<view class="comment-box">
<view class="comment">
<view class="item" v-for="(item,index) in list" :key="index">
<view class="avatar" @click="$push('sub_pages/member/detail/detail',{userId:item.userId})">
<view class="icon">
<image :src="item.userAvatar" mode="aspectFill"></image>
</view>
</view>
<view class="info">
<view class="head">
<view class="title">
<view class="nickname">
<text class="text">{{ item.nickname }}</text>
<text class="user-city" v-if="item.userCity">{{ getCity(item.userCity) }}</text>
</view>
<view class="label">
{{ item.age ? item.age + '岁' : '' }}
{{ item.position ? item.position : '' }}
</view>
</view>
</view>
<view class="desc">
<mp-html :content="item.content" />
<!-- <text>有没有小姐姐想今年结婚的呀我们可以私聊希望有人可以与我共黄昏有人问我粥可温...</text> -->
</view>
<view v-if="item.video" class="video">
<video id="myVideo" :src="item.video" @error="videoErrorCallback"></video>
</view>
<view v-else class="image">
<u-album :urls="item.files" keyName="thumb" :singleSize="100" singleMode="aspectFill"
multipleMode="aspectFill"></u-album>
</view>
<!-- <view class="topic" v-if="item.topic">
<text @click="onTopic(item.topic)">#{{ item.topic }}</text>
</view> -->
<view class="comment-btn">
<view class="left">
<view class="date-time">{{ new Date(item.createTime).getTime() | timeFrom }}</view>
</view>
<view class="right">
<!-- <view class="zan" v-if="item.liked == 0" @click="onLikes(item,index)">
<u-icon name="thumb-up" :size="20"></u-icon>
<text>{{ item.likes }}</text>
</view>
<view class="zan" v-else @click="onLikes(item,index)">
<u-icon name="thumb-up" color="#8b004c" :size="20"></u-icon>
<text class="active">{{ item.likes }}</text>
</view>
<view class="comment2" @click="openComment(item,index)">
<u-icon name="chat" :size="20"></u-icon>
<text>{{ item.commentNumbers }}</text>
</view> -->
</view>
</view>
</view>
</view>
<u-empty v-if="!list && list.length == 0" mode="list"
icon="http://cdn.uviewui.com/uview/empty/list.png">
</u-empty>
</view>
</view>
<view class="comment-popup">
<view class="user-list">
<u-list :scrollTop="anchor">
<view class="list">
<u-list-item v-for="(item, index) in comment" :key="index">
<u-cell :border="false">
<!-- <view slot="icon">
<view class="avatar">
<u-avatar size="50" :src="item.avatar"
customStyle="margin: -3px 5px -3px 0"
@click="$push('sub_pages/member/detail/detail',{userId: item.userId})"></u-avatar>
</view>
</view> -->
<view slot="label">
<view class="comment-box">
<view class="comment-avatar">
<u-avatar :size="45" :src="item.avatar"
customStyle="margin: 0 5px -3px 0"
@click="$push('sub_pages/member/detail/detail',{userId: item.userId})"></u-avatar>
</view>
<view class="comment-content">
<view class="nickname">
{{ item.nickname }}
</view>
<rich-text class="content" :nodes="item.content"></rich-text>
<view class="reply-box">
<view class="create-time">
{{ new Date(item.createTime).getTime() | timeFrom }} ·
{{ item.city }} <text class="reply"
@click="onReply(item,index)">回复</text>
</view>
<view class="like">
<!-- <u-icon name="heart" :size="18"></u-icon> -->
粉丝
<u-badge numberType="limit" :inverted="true" color="#999999"
:value="item.fans"></u-badge>
</view>
<!-- 粉丝{{ item.fans }} -->
</view>
<!-- 回复评论 -->
<block v-for="(reply, replyIndex) in item.children" :key="replyIndex">
<view class="reply-item">
<view class="reply-user">
<u-avatar :size="16" :src="reply.avatar"
customStyle="margin: -3px 5px -3px 0"
@click="$push('sub_pages/member/detail/detail',{userId: reply.replyUserId})"></u-avatar>
<view class="nickname">
<text class="reply-nickname1">{{ reply.nickname }}</text>
<u-icon v-if="reply.replyNickname" name="play-right-fill"
:size="12" color="#999999"></u-icon>
<text class="reply-nickname2"
v-if="reply.replyNickname">{{ reply.replyNickname }}</text>
</view>
</view>
<rich-text class="content" :nodes="reply.content"></rich-text>
<view class="reply-box">
<view class="create-time">
{{ new Date(reply.createTime).getTime() | timeFrom }}
·
{{ reply.city }} <text class="reply"
@click="onReply(reply,replyIndex)">回复</text>
</view>
<view class="like">
粉丝
<u-badge numberType="limit" :inverted="true" color="#999999"
:value="reply.fans"></u-badge>
</view>
</view>
</view>
</block>
</view>
</view>
</view>
<view slot="right-icon">
</view>
</u-cell>
</u-list-item>
<u-empty v-if="comment.length == 0" mode="message" text="暂无评论"
icon="http://cdn.uviewui.com/uview/empty/data.png">
</u-empty>
</view>
</u-list>
</view>
<view class="footer">
<view class="search">
<!-- <u-button searchIcon="chat" text="发送" v-model="form.content" @click="onSend()" :actionStyle="actionStyle" :disabled="disabled"></u-button> -->
<u-search :showAction="true" :placeholder="placeholder" searchIcon="chat" actionText="发送"
:actionStyle="actionStyle" v-model="form.content" :disabled="disabled"
@custom="$u.throttle(onSend, 500)"></u-search>
</view>
</view>
</view>
<u-loadmore :status="loading" />
<u-gap height="5"></u-gap>
<u-action-sheet :actions="gender" :show="showGender" cancelText="取消" @select="onGender"
@close="showGender = false"></u-action-sheet>
</view>
</template>
<script>
import store from '@/store/index.js'
import storage from '@/utils/storage'
import * as UserApi from '@/api/user.js'
import * as ArticleApi from '@/api/article.js'
import * as ArticleLikeApi from '@/api/article-like.js'
import * as ArticleCommentApi from '@/api/article-comment.js'
import * as UserFollowApi from '@/api/user-follow.js'
import * as Util from '@/utils/util.js'
import * as Config from '@/config.js';
const pageSize = 10
const userId = uni.getStorageSync('userId')
const loginUserId = uni.getStorageSync('userId')
const menu = [{
name: '推荐'
},
{
name: '同城'
},
{
name: '关注'
}
]
import mixin from '@/core/mixins/tabbar'
export default {
mixins: [mixin],
data() {
return {
commentId: 0,
article: {},
anchor: 0,
options: null,
list: [], // 文章列表
comment: [], // 文章评论列表
menu,
currentTab: 0,
disabled: false,
danmuList: [{
text: '好可爱嗷~~',
color: '#ff0000',
time: 1
},
{
text: 'かわゆい',
color: '#ff00ff',
time: 3
}
],
gender: [{
value: 2,
name: '只看美女'
},
{
value: 1,
name: '只看帅哥'
},
{
value: null,
name: '美女帅哥'
}
],
actionStyle: {
background: '#8b004c',
color: '#ffffff',
padding: '12rpx 16rpx',
borderRadius: '50rpx'
},
iconStyle: {
background: '#8b004c',
},
statusBarHeight: 25,
latitude: 22.766777,
longitude: 108.375152,
scale: 10,
page: 0,
// 控制onShow事件是否刷新订单列表
canReset: false,
showGender: false,
showComment: false,
countComment: 0,
where: {
categoryId: 0,
platform: 'MP-WEIXIN',
showFollow: true,
scene: 'new'
},
form: {
articleId: 0,
content: '',
replyCommentId: 0,
commentNumbers: 0
},
articleIndex: 0, // 当前评论的文章
showComment: false,
countComment: 0,
currentIndex: 0, // 当前评论ID
loading: 'loading',
replyUserId: 0,
placeholder: '善语结善缘,恶言伤人心',
isLogin: false
}
},
onLoad(options) {
const app = this
console.log("options: ",options);
app.commentId = options.commentId
app.checkLogin()
app.onRefreshList()
// app.getLocation(res => {
// if (res.latitude && res.longitude) {
// app.latitude = res.latitude
// app.longitude = res.longitude
// app.scale = 16
// }
// })
uni.getSystemInfo({
success(data) {
if (data) {
app.statusBarHeight = data.statusBarHeight
}
}
})
},
/**
* 生命周期函数--监听页面显示
*/
onShow() {
// this.page = 1
// this.list = []
// this.onRefreshList()
},
// 触底函数
onReachBottom() {
const app = this
if (app.canReset) {
console.log("触底函数1: ");
app.page = ++app.page;
app.onRefreshList()
}
},
onPullDownRefresh() {
this.page = 1
this.list = []
this.onRefreshList()
uni.stopPullDownRefresh();
},
methods: {
onTabs(e) {
const app = this
const userId = uni.getStorageSync('userId')
const index = e.index
app.currentTab = index
app.where = {}
// 最新
if (index == 0) {
app.where.scene = 'new'
}
// 同城
if (index == 1) {
app.where.scene = 'intraCity'
if (userId == 1101) {
app.$push('pages/login/index')
return false
}
}
// 关注
if (index == 2) {
app.where.scene = 'focus'
if (userId == 1101) {
app.$push('pages/login/index')
return false
}
}
app.page = 1
app.list = []
app.onRefreshList()
},
onChange(e) {
this.currentTab = e.index
},
// 刷新订单列表
onRefreshList() {
const app = this
const {
commentId
} = this
// var LoveWhere = uni.getStorageSync('LoveWhere')
// app.where.page = app.page
// app.where.loginUserId = userId
// app.where.categoryId = 0
// app.where.showFollow = true
ArticleCommentApi.getArticleComment(commentId)
.then(result => {
app.list = result.data.list
app.list.map(d => {
const imgs = JSON.parse(d.files)
if (imgs) {
var files = []
imgs.map(pic => {
// Util.thumbnail(pic.url),
files.push({
thumb: pic.url,
url: pic.url
})
})
}
d.files = files
app.getComment(d.articleId)
app.form.articleId = d.articleId
return d;
})
})
},
videoErrorCallback: function(e) {
uni.showModal({
content: e.target.errMsg,
showCancel: false
})
},
// 检查是否登录
checkLogin() {
if (!!store.getters.userId && store.getters.userId != Config.userId) {
this.isLogin = true
}
},
onGender(e) {
this.list = []
this.where.page = 1
this.where.gender = e.value
this.showGender = false
this.onRefreshList()
},
// 获取用户坐标
// 参考文档https://uniapp.dcloud.io/api/location/location?id=getlocation
getLocation(callback) {
const app = this
uni.getLocation({
success: callback,
fail() {
app.$toast('获取定位失败,请点击右下角按钮重新尝试定位')
app.isAuthor = false
}
})
},
// 跳转页面
navTo(url) {
if (!store.getters.userId || store.getters.userId == 1101) {
this.$navTo('pages/login/index')
return false
}
this.$navTo(url)
},
onRelease() {
const app = this
uni.navigateTo({
url: `/sub_pages/love/release/release`,
events: {
reload: ({
isRefresh // false
}) => {
console.log("onRelease: ", isRefresh);
if (isRefresh) {
app.page = 1
app.list = []
app.onRefreshList()
}
// const currentTab = uni.getStorageSync('currentTab')
// // 取消关注,从列表中删除
// if (!follow && currentTab == 2 && app.curQueue[index]) app.curQueue.splice(index, 1)
}
}
})
},
onFollow(shopId, index) {
const app = this
if (!app.isLogin) {
app.$push('pages/login/index')
return false
}
const status = !app.list[index].follow
app.list[index].follow = status
app.list.map((d, i) => {
if (shopId == d.userId) {
app.list[i].follow = status
}
})
UserFollowApi.addFollow({
shopId
}).then(res => {
app.$success(res.message)
})
},
onLikes(item, index) {
const app = this
const {
articleId,
likes,
liked
} = item
if (!app.isLogin) {
app.$push('pages/login/index')
return false
}
ArticleLikeApi.addArticleLike({
articleId,
likes,
liked
}).then(res => {
app.list[index].liked = res.data.liked
app.list[index].likes = res.data.likes
}).catch(err => {
app.$error(err.message)
})
},
openComment(item, index) {
const loginUserId = store.getters.userId
if (!loginUserId || loginUserId == 1101) {
this.$push('pages/login/index')
return false
}
console.log("item: ", item);
// uni.hideTabBar()
this.comment = []
this.getComment(item.articleId)
this.form.articleId = item.articleId
this.form.commentNumbers = item.commentNumbers
this.form.toUserId = item.userId
this.countComment = item.commentNumbers
this.currentIndex = index
this.showComment = true
console.log("this.form: ", this.form);
},
closeComment() {
// uni.showTabBar()
this.showComment = false
this.placeholder = '善语结善缘,恶言伤人心'
},
getComment(articleId) {
const app = this
ArticleCommentApi.pageArticleComment({
articleId
}).then(res => {
app.countComment = res.data.count
app.comment = res.data.list.map(d => {
d.children = d.children.reverse()
return d
})
})
},
// 发表评论
onSend() {
const app = this
const {
form,
countComment
} = this
const {
articleId,
content,
toUserId,
replyUserId,
replyCommentId
} = form
if (form.content == '') {
app.$error('请填写评论内容')
return false
}
form.countComment = countComment
app.disabled = true
ArticleCommentApi.addArticleComment({
articleId,
countComment,
content,
toUserId: replyUserId?replyUserId:toUserId,
replyCommentId,
replyUserId
}).then(res => {
app.form.content = ''
app.form.replyCommentId = 0
app.form.replyUserId = 0
app.placeholder = '善语结善缘,恶言伤人心'
app.getComment(form.articleId)
const currIndex = app.list.findIndex(item => item.articleId == articleId)
app.list[currIndex].commentNumbers = res.data.commentNumbers
app.anchor = app.anchor + 0.01
app.disabled = false
// app.$success(res.message)
}).catch(err => {
app.$error(err.message)
app.disabled = false
})
},
// 发表评论
// onSend() {
// const app = this
// const {
// form,
// countComment
// } = this
// const {
// articleId,
// content,
// toUserId,
// replyUserId,
// replyCommentId
// } = form
// if (form.content == '') {
// app.$error('请填写评论内容')
// return false
// }
// form.countComment = countComment
// app.disabled = true
// ArticleCommentApi.addArticleComment({
// articleId,
// countComment,
// content,
// toUserId,
// replyCommentId,
// replyUserId
// }).then(res => {
// app.form.content = ''
// app.getComment(form.articleId)
// const currIndex = app.list.findIndex(item => item.articleId == articleId)
// app.list[currIndex].commentNumbers = res.data.commentNumbers
// app.anchor = app.anchor + 0.01
// app.disabled = false
// // app.$success(res.message)
// }).catch(err => {
// app.$error(err.message)
// app.disabled = false
// })
// },
getProvince(text) {
if (text == '广西壮族自治区') {
return '广西'
}
return text;
},
getCity(text) {
return text.replace('市', '')
},
onReply(item, index) {
const app = this
if (loginUserId == 1101 || loginUserId == null) {
app.$push('pages/login/index')
return false
}
console.log("item: ", item);
app.placeholder = '回复@' + item.nickname
app.form.replyCommentId = item.replyCommentId ? item.replyCommentId : item.commentId
app.form.replyUserId = item.userId
// UserLikeApi.addLike(app.form).then(res => {
// app.likes = res.data
// app.setLikeLight(index)
// })
},
onTopic(text) {
this.list = []
this.where.page = 1
this.where.topic = text
this.onRefreshList()
}
}
}
</script>
<style lang="scss" scoped>
.container {
// background-color: #ffffff;
height: 100vh;
}
.page-bg {
width: 750rpx;
/* #ifdef MP-WEIXIN */
height: calc(100rpx + var(--status-bar-height));
/* #endif */
display: block;
background-color: #0d0119;
position: fixed;
left: 0;
top: 0;
z-index: 8888;
}
.release {
position: fixed;
bottom: 120rpx;
right: 30rpx;
z-index: 9999;
overflow: hidden;
image {
width: 72rpx;
height: 72rpx;
border-radius: 100%;
background-color: #ffffff;
}
}
.header {
width: 750rpx;
position: fixed;
z-index: 9999;
top: 0;
display: flex;
justify-content: space-around;
align-items: center;
height: 88rpx;
background-color: #0d0119;
.pair {
position: absolute;
left: 30rpx;
position: absolute;
right: 30rpx;
display: flex;
.search {
image {
padding-top: 15rpx;
width: 40rpx;
height: 40rpx;
}
}
.pair-btn {
image {
margin-left: 30rpx;
padding-top: 16rpx;
width: 36rpx;
height: 36rpx;
}
.search-wrapper {
width: 240rpx;
padding: 0 20rpx;
}
}
// .pair-btn{
// margin-left: 22rpx;
// height: 50rpx;
// line-height: 50rpx;
// margin-top: 15rpx;
// padding: 6rpx 12rpx;
// color: #ffffff;
// border-radius: 10rpx;
// background: url('data:image/svg+xml;charset=utf8,%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20xmlns%3Axlink%3D%22http%3A%2F%2Fwww.w3.org%2F1999%2Fxlink%22%20version%3D%221.1%22%3E%3Cdefs%3E%3ClinearGradient%20id%3D%221%22%20x1%3D%220%22%20x2%3D%221%22%20y1%3D%220%22%20y2%3D%220%22%20gradientTransform%3D%22matrix(6.123233995736766e-17%2C%201%2C%20-0.024693877551020406%2C%206.123233995736766e-17%2C%200.5%2C%200)%22%3E%3Cstop%20stop-color%3D%22%230a060d%22%20stop-opacity%3D%221%22%20offset%3D%220%22%3E%3C%2Fstop%3E%3Cstop%20stop-color%3D%22%23660061%22%20stop-opacity%3D%221%22%20offset%3D%220.95%22%3E%3C%2Fstop%3E%3C%2FlinearGradient%3E%3C%2Fdefs%3E%3Crect%20width%3D%22100%25%22%20height%3D%22100%25%22%20fill%3D%22url(%231)%22%3E%3C%2Frect%3E%3C%2Fsvg%3E');
// }
}
.menu {
display: flex;
justify-content: center;
// font-size: 32rpx;
// font-weight: 600;
z-index: 9999;
.link {
color: #cfd1d7;
}
.curr {
color: #ffffff;
border-bottom: 5rpx solid #ffffff;
}
}
// .search{
// position: absolute;
// right: 30rpx;
// image{
// padding-top: 20rpx;
// width: 50rpx;
// height: 50rpx;
// }
// }
}
.header-box {
height: 100rpx;
}
.comment-box {
background-color: #ffffff;
width: 750rpx;
margin: 0 auto;
overflow-x: hidden;
.comment {
width: 700rpx;
padding: 30rpx;
.item {
display: flex;
padding-bottom: 30rpx;
// margin-bottom: 30rpx;
border-bottom: 2rpx solid #f3f3f3;
.avatar {
position: relative;
display: flex;
flex-direction: column;
align-items: center;
.icon {
image {
width: 90rpx !important;
height: 90rpx !important;
border-radius: 100%;
overflow: hidden;
border: 5rpx solid #ffffff;
}
}
.add {
position: absolute;
bottom: -7rpx;
width: 40rpx;
height: 40rpx;
border-radius: 100%;
overflow: hidden;
}
}
.info {
width: 660rpx;
margin-left: 10rpx;
.head {
display: flex;
align-items: center;
justify-content: space-between;
.title {
.nickname {
display: flex;
align-items: center;
font-size: 30rpx;
font-weight: 700;
.user-city {
border: 1rpx solid #8d1a50;
border-radius: 25px;
padding: 0 8rpx !important;
font-size: 18rpx;
margin-left: 20rpx;
height: 25rpx;
color: #8d1a50;
display: flex;
align-items: center;
justify-content: center;
}
}
.label {
color: #999999;
font-size: 26rpx;
}
.date-time {
color: #9a9a9a;
font-size: 26rpx;
}
}
.follow-btn {
padding: 4rpx 20rpx;
color: #ffffff;
font-size: 26rpx;
border-radius: 50rpx;
display: flex;
margin-right: 10rpx;
background: linear-gradient(#47076b, #8d1a50);
image {
width: 24rpx;
height: 66rpx;
margin-right: 6rpx;
}
}
.unfollow-btn {
padding: 4rpx 20rpx;
color: #ffffff;
font-size: 26rpx;
border-radius: 50rpx;
margin-right: 10rpx;
background: linear-gradient(#b3b3b3, #cccccc);
image {
width: 24rpx;
height: 66rpx;
margin-right: 6rpx;
}
}
}
.topic {
margin-bottom: 20rpx;
padding: 8rpx 16rpx;
font-size: 28rpx;
color: #8d1a50;
font-weight: 700;
}
.image {
padding: 20rpx 0;
image {
width: 160rpx;
height: 160rpx;
margin-right: 8rpx;
}
}
.video {
padding: 20rpx 0;
max-width: 400rpx;
video {
max-width: 400rpx;
}
}
.comment-btn {
display: flex;
justify-content: space-between;
font-size: 26rpx;
.left {
.date-time {
color: #9a9a9a;
font-size: 26rpx;
}
}
.right {
display: flex;
.zan {
display: flex;
align-items: center;
image {
width: 36rpx;
height: 36rpx;
margin-right: 10rpx;
}
}
.comment2 {
margin-left: 50rpx;
display: flex;
image {
width: 36rpx;
margin-right: 10rpx;
}
text {
padding: 0 5rpx;
}
}
.active {
color: #681752;
}
}
}
}
}
}
}
.comment-popup {
background-color: #ffffff;
border-radius: 20rpx;
position: relative;
display: flex;
flex-direction: column;
width: 750rpx;
margin: auto;
margin-bottom: 40rpx;
font-size: 26rpx;
.head {
padding: 24rpx;
text-align: center;
border-bottom: 1rpx solid #f3f3f3;
}
.user-list {}
.footer {
background-color: #ffffff;
border-top: 1rpx solid #f3f3f3;
width: 750rpx;
height: 55rpx;
position: fixed;
left: 0;
bottom: 0rpx;
padding: 20rpx 0 40rpx 0;
.search {
width: 700rpx;
margin: auto;
}
}
.comment-box {
display: flex;
.comment-avatar {}
.comment-content {
width: 100%;
.nickname {
color: #999999;
font-size: 26rpx;
display: flex;
padding: 2rpx 0;
.reply-nickname1 {
padding-right: 10rpx;
}
.reply-nickname2 {
padding-left: 10rpx;
}
}
.content {
font-size: 30rpx;
}
.reply-box {
font-size: 26rpx;
color: #999999;
display: flex;
justify-content: space-between;
padding: 20rpx 0;
.reply {
color: #681752;
margin: 0 30rpx;
}
.like {
display: flex;
align-items: center;
color: #999999;
font-size: 26rpx;
padding-right: 50rpx;
}
}
.reply-item {
margin: 24rpx 0;
.reply-user {
display: flex;
align-items: center;
padding: 2rpx 0;
}
}
}
}
}
</style>