|
@@ -20,7 +20,7 @@ import { handleShareClick, handleUpvoteClick } from '../../../core/libs/actions'
|
|
import CommentItem from '../components/comment-item.vue'
|
|
import CommentItem from '../components/comment-item.vue'
|
|
import { useUserStore } from '../../../store'
|
|
import { useUserStore } from '../../../store'
|
|
import { storeToRefs } from 'pinia'
|
|
import { storeToRefs } from 'pinia'
|
|
-import { isImageOrVideo } from '../../../core/utils/common'
|
|
|
|
|
|
+import { isImageOrVideo, requestToast } from '../../../core/utils/common'
|
|
import dayjs from 'dayjs'
|
|
import dayjs from 'dayjs'
|
|
import SectionHeading from '@/components/section-heading.vue'
|
|
import SectionHeading from '@/components/section-heading.vue'
|
|
import BottomAppBar from '@/components/bottom-app-bar.vue'
|
|
import BottomAppBar from '@/components/bottom-app-bar.vue'
|
|
@@ -38,6 +38,9 @@ const router = useRouter()
|
|
const id = ref()
|
|
const id = ref()
|
|
const isShared = ref(false)
|
|
const isShared = ref(false)
|
|
const commeentRef = ref<InstanceType<typeof WdInput>>()
|
|
const commeentRef = ref<InstanceType<typeof WdInput>>()
|
|
|
|
+const commentItemRef = ref<InstanceType<typeof CommentItem>[]>()
|
|
|
|
+const instance = getCurrentInstance()
|
|
|
|
+
|
|
const focus = ref(false)
|
|
const focus = ref(false)
|
|
const { data, run } = useRequest(() => getCircle(id.value), { initialData: {} })
|
|
const { data, run } = useRequest(() => getCircle(id.value), { initialData: {} })
|
|
const { data: reviews, run: runGetReviews } = useRequest(
|
|
const { data: reviews, run: runGetReviews } = useRequest(
|
|
@@ -56,6 +59,8 @@ const swiperSizes = ref()
|
|
const swiperStyle = ref()
|
|
const swiperStyle = ref()
|
|
const reviewContent = ref('')
|
|
const reviewContent = ref('')
|
|
const isVideo = ref(false)
|
|
const isVideo = ref(false)
|
|
|
|
+const reviewId = ref()
|
|
|
|
+const refreshIndex = ref<number>()
|
|
const handleChange = ({ detail: { current } }) => {
|
|
const handleChange = ({ detail: { current } }) => {
|
|
swiperStyle.value = {
|
|
swiperStyle.value = {
|
|
height: swiperSizes.value[current].height + 'px',
|
|
height: swiperSizes.value[current].height + 'px',
|
|
@@ -76,20 +81,52 @@ const setSwiperStyle = async () => {
|
|
}
|
|
}
|
|
}
|
|
}
|
|
const handleSend = async () => {
|
|
const handleSend = async () => {
|
|
|
|
+ if (!reviewContent.value) {
|
|
|
|
+ uni.showToast({ title: '请输入评论内容', icon: 'none' })
|
|
|
|
+ return
|
|
|
|
+ }
|
|
const { code, msg } = await createCircleReview({
|
|
const { code, msg } = await createCircleReview({
|
|
circleId: id.value,
|
|
circleId: id.value,
|
|
userId: userInfo.value.userId,
|
|
userId: userInfo.value.userId,
|
|
userName: userInfo.value.nickname,
|
|
userName: userInfo.value.nickname,
|
|
reviewContent: reviewContent.value,
|
|
reviewContent: reviewContent.value,
|
|
|
|
+ replayReviewId: reviewId.value,
|
|
})
|
|
})
|
|
if (code !== 0) {
|
|
if (code !== 0) {
|
|
uni.showToast({ title: msg, icon: 'none' })
|
|
uni.showToast({ title: msg, icon: 'none' })
|
|
} else {
|
|
} else {
|
|
reviewContent.value = ''
|
|
reviewContent.value = ''
|
|
uni.showToast({ title: '评论成功', icon: 'none' })
|
|
uni.showToast({ title: '评论成功', icon: 'none' })
|
|
|
|
+ if (refreshIndex.value) {
|
|
|
|
+ console.log(instance.refs)
|
|
|
|
+ commentItemRef.value.at(refreshIndex.value).refresh()
|
|
|
|
+ reviewId.value = undefined
|
|
|
|
+ refreshIndex.value = undefined
|
|
|
|
+ } else {
|
|
|
|
+ await runGetReviews()
|
|
|
|
+ }
|
|
|
|
+ focus.value = false
|
|
|
|
+ }
|
|
|
|
+}
|
|
|
|
+const handleReplay = async (options) => {
|
|
|
|
+ reviewId.value = options.reviewId
|
|
|
|
+ refreshIndex.value = options.index
|
|
|
|
+ focus.value = true
|
|
|
|
+}
|
|
|
|
+const handleDelete = async (index?: number) => {
|
|
|
|
+ if (index !== undefined) {
|
|
|
|
+ commentItemRef.value.at(index).refresh()
|
|
|
|
+ } else {
|
|
await runGetReviews()
|
|
await runGetReviews()
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
+const handleUpvote = async (index?: number) => {
|
|
|
|
+ if (index !== undefined) {
|
|
|
|
+ commentItemRef.value.at(index).refresh()
|
|
|
|
+ } else {
|
|
|
|
+ await run()
|
|
|
|
+ }
|
|
|
|
+}
|
|
onMounted(async () => {})
|
|
onMounted(async () => {})
|
|
onLoad(async (query: { id: string; isShared?: boolean }) => {
|
|
onLoad(async (query: { id: string; isShared?: boolean }) => {
|
|
id.value = query.id
|
|
id.value = query.id
|
|
@@ -106,9 +143,9 @@ onLoad(async (query: { id: string; isShared?: boolean }) => {
|
|
onShareAppMessage(async ({ from, target }) => {
|
|
onShareAppMessage(async ({ from, target }) => {
|
|
console.log('from', from)
|
|
console.log('from', from)
|
|
console.log('target', target)
|
|
console.log('target', target)
|
|
- if (!features.value.shareMoment) {
|
|
|
|
- return handleShareClick()
|
|
|
|
- }
|
|
|
|
|
|
+ // if (!features.value.shareMoment) {
|
|
|
|
+ // return handleShareClick()
|
|
|
|
+ // }
|
|
const res: Page.CustomShareContent = {}
|
|
const res: Page.CustomShareContent = {}
|
|
await shareCircle(id.value)
|
|
await shareCircle(id.value)
|
|
res.path = `/pages/home/moment/index?id=${id.value}&isShared=true`
|
|
res.path = `/pages/home/moment/index?id=${id.value}&isShared=true`
|
|
@@ -212,12 +249,15 @@ onShareAppMessage(async ({ from, target }) => {
|
|
|
|
|
|
<view clas="mt-8.25">
|
|
<view clas="mt-8.25">
|
|
<template v-if="reviews?.list.length">
|
|
<template v-if="reviews?.list.length">
|
|
- <template v-for="it of reviews?.list" :key="it.id">
|
|
|
|
|
|
+ <template v-for="(it, i) in reviews?.list" :key="it.id">
|
|
<CommentItem
|
|
<CommentItem
|
|
|
|
+ ref="commentItemRef"
|
|
:options="it"
|
|
:options="it"
|
|
:isChild="false"
|
|
:isChild="false"
|
|
- @upvote="runGetReviews()"
|
|
|
|
- @delete="runGetReviews()"
|
|
|
|
|
|
+ :index="i"
|
|
|
|
+ @upvote="handleUpvote"
|
|
|
|
+ @delete="handleDelete"
|
|
|
|
+ @replay="handleReplay"
|
|
></CommentItem>
|
|
></CommentItem>
|
|
<!-- <template v-for="child of it.childrens" :key="child.id">
|
|
<!-- <template v-for="child of it.childrens" :key="child.id">
|
|
<CommentItem :options="child" :isChild="true"></CommentItem>
|
|
<CommentItem :options="child" :isChild="true"></CommentItem>
|