reply.vue 3.6 KB
<template>
  <u-navbar title="0" :autoBack="true" bgColor="#ffffff" placeholder safeAreaInsetTop :titleStyle="{ color: '#fff' }">
    <template #right>
      <view style="width: 126rpx">
        <up-button color="#05B8D2" shape="circle" text="提交" throttleTime="1500" size="small" @click="submitCommentHandler"></up-button>
      </view>
    </template>
  </u-navbar>

  <view class="reply graybg">
    <view class="reply-topbg">
      <view class="title">回复评论</view>
      <view class="graybg1">
        <view class="flexJ" style="margin-bottom: 50rpx">
          <view class="flexA">
            <image :src="proxy.$h.downFile(commmentDetail?.user?.avatar)" class="reply-avatar" mode="aspectFill" />
            <view class="reply-username">{{ commmentDetail?.user?.nickname }}</view>
            <view class="reply-toptag" v-if="commmentDetail?.consultationWay">{{ proxy.$h.optObjectValue('consultationWay', commmentDetail?.consultationWay) || '' }}</view>
          </view>
        </view>
        <view class="reply-time">{{ commmentDetail?.time }}</view>
        <view class="flexA" style="margin-bottom: 16rpx">
          <view class="reply-text">评分:</view>
          <view style="margin-right: 6rpx; color: #ffc525">{{ commmentDetail?.star }}分</view>
          <u-rate :count="5" v-model="value" allowHalf activeColor="#ffc525" readonly></u-rate>
        </view>
        <view class="reply-text">评价:{{ commmentDetail?.content || '' }}</view>
      </view>
    </view>
    <view class="main">
      <u-textarea v-model="commentText" placeholder="请输入内容" count maxlength="200"></u-textarea>
    </view>
  </view>
</template>

<script setup lang="ts">
import { ref, getCurrentInstance, ComponentPublicInstance } from 'vue'
import { onLoad } from '@dcloudio/uni-app'
import { updateComment_receive } from '../../api'
import { CommentListItemType } from '../../types'

const { proxy } = getCurrentInstance() as { proxy: ComponentPublicInstance }

const value = ref(4.5)

const commentText = ref<string>('')

const submitCommentHandler = async () => {
  if (commentText.value.length === 0) return uni.$u.toast('回复内容不能为空')

  await updateComment_receive({ id: commentId.value, content: commentText.value })

  proxy.$h.timeCallBack('回复成功')
}

const commentId = ref<string>('')

const commmentDetail = ref<CommentListItemType>()

onLoad((e: { id: string; detailData: string }) => {
  commentId.value = e.id

  commmentDetail.value = JSON.parse(e.detailData)

  value.value = Number(commmentDetail.value?.star)
})
</script>

<style lang="scss" scoped>
.reply {
  .main {
    box-sizing: border-box;
    padding: 0 24rpx;
    border-radius: 24rpx;
  }
  &-text {
    color: #323233;
    font-size: 26rpx;
  }
  &-avatar {
    width: 92rpx;
    height: 92rpx;
    min-width: 92rpx;
    min-height: 92rpx;
    border-radius: 50%;
  }
  &-username {
    margin: 0 16rpx;
    color: #323233;
    font-size: 30rpx;
    font-weight: 700;
  }
  &-time {
    color: #999999;
    font-size: 26rpx;
  }
  &-toptag {
    color: #05b8d2;
    font-size: 22rpx;
    font-weight: 700;
    box-sizing: border-box;
    padding: 2rpx 10rpx;
    border: 1rpx solid #05b8d2;
    border-radius: 8rpx;
  }
  &-topbg {
    box-sizing: border-box;
    padding: 40rpx 24rpx;
    background: #fff;
    border-radius: 0 0 32rpx 32rpx;
    margin-bottom: 24rpx;
    .title {
      color: #323233;
      font-size: 32rpx;
      font-weight: 700;
      margin-bottom: 52rpx;
    }
    .graybg1 {
      box-sizing: border-box;
      padding: 28rpx 24rpx;
      background: #f8f8fa;
      border-radius: 24rpx;
    }
  }
}
</style>