commentNew.vue 8.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312
  1. <template>
  2. <view class="content">
  3. <!-- 点击评论弹出层 -->
  4. <u-popup :closeable='true' :round="10" :show="popupShow" @close="close" @open="open">
  5. <view class="popupTitle">回复评论</view>
  6. <view class="popupView">
  7. <view class="scrollview">
  8. <!-- 弹出层中意见详情 -->
  9. <view class="one_comment_box">
  10. <view class="comment">
  11. <view class="photo">
  12. <u--image shape="circle" width="48rpx" height="48rpx" :src="popupData.authorLogo" ></u--image>
  13. </view>
  14. <view class="rc_1" >{{popupData.authorName || '未知用户'}}</view>
  15. </view>
  16. <view class="comment">
  17. <view class="rc_3" >{{popupData.content}}</view>
  18. </view>
  19. <view class="comment_foot">
  20. <view class="rc_2" @click="toReply(popupData,2)">{{popupData.createTime + ' 回复 '}}</view>
  21. </view>
  22. </view>
  23. <u-line margin='10rpx 0' color="#e4e7ed" />
  24. <view v-for="(item2,index) in popupData.floorList" :key="index">
  25. <view :class="item2.citeAuthorName?'one_recomment_box':'one_comment_box'">
  26. <view class="comment">
  27. <view class="photo">
  28. <u--image shape="circle" width="48rpx" height="48rpx" :src="item2.authorLogo" ></u--image>
  29. </view>
  30. <view class="rc_1">{{item2.authorName || '未知用户'}}</view>
  31. </view>
  32. <view class="comment">
  33. <view class="rc_3" >
  34. <text v-if="item2.citeAuthorName">{{ '@'+ item2.citeAuthorName + '回复:' }}</text>
  35. {{item2.content}}
  36. </view>
  37. </view>
  38. <view class="comment_foot">
  39. <view class="rc_2" @click="toReply(item2,3)">{{item2.createTime + ' 回复 '}}</view>
  40. <view class="flex" @click="setQalike(item2)" style="align-items: center;">
  41. <u--image v-if="item2.isLike == '1'" shape="circle" width="48rpx" height="48rpx" src="/static/myinfo/icomx_dianzan1.png" ></u--image>
  42. <u--image v-else shape="circle" width="48rpx" height="48rpx" src="/static/myinfo/icomx_dianzan.png" ></u--image>
  43. <text style="margin-left: 8rpx;color: #666666;">{{ item2.likesCount }}</text>
  44. </view>
  45. </view>
  46. </view>
  47. </view>
  48. </view>
  49. </view>
  50. <view class="btnflex">
  51. <view class="commentInput" >
  52. <u-input :placeholder="popupPlaceholder" v-model="inputValue2" :auto-height="true" type="text" />
  53. </view>
  54. <view class="btn" @click="submit2">
  55. 提交
  56. </view>
  57. </view>
  58. </u-popup>
  59. </view>
  60. </template>
  61. <script>
  62. import {Qalike,QareplyPage,Qareplybyid} from '@/http/api/common.js'
  63. import * as util from '@/pages/util/util.js'
  64. export default {
  65. options: { styleIsolation: 'shared' },
  66. props: {
  67. showComment: {
  68. type: Boolean,
  69. default: false,
  70. },
  71. CommentData: {
  72. type: Object,
  73. default: null,
  74. },
  75. },
  76. watch:{
  77. showComment: {
  78. immediate: true,
  79. handler(val) {
  80. //是否展示意见弹窗
  81. this.popupShow = val
  82. },
  83. },
  84. CommentData: {
  85. immediate: true,
  86. handler(val) {
  87. //意见列表数据
  88. this.popupData = val
  89. },
  90. },
  91. },
  92. data() {
  93. return {
  94. popupShow:false,
  95. show:false,
  96. inputValue:'',
  97. inputValue2:'',
  98. num:999,
  99. popupData:{
  100. authorName:'',
  101. createTime:'',
  102. content:'',
  103. authorLogo:'',
  104. floorList:[]
  105. },
  106. dataList:[],
  107. curNow:0,
  108. popupPlaceholder:'点击输入评论',
  109. pageNum:1,
  110. pageSize:2,//初始为2
  111. jiazaitext:'加载更多',
  112. replyType:2,//回复类型 1:回复主题 2:回复楼层 3:回复楼层内的评论
  113. replyId:''
  114. }
  115. },
  116. onReachBottom() {
  117. },
  118. methods: {
  119. async setQalike(item){
  120. let res = await Qalike(item.id)
  121. if (item.isLike == '1') {
  122. item.isLike = '2'
  123. item.likesCount = item.likesCount - 1
  124. }else{
  125. item.isLike = '1'
  126. item.likesCount = item.likesCount + 1
  127. }
  128. },
  129. async getTopicReply(){
  130. let res = await QareplyPage({
  131. pageNum:1,
  132. pageSize:100,
  133. floorId:item.id,
  134. topicId:item.topicId,
  135. })
  136. this.CommentData = {
  137. ...item,
  138. floorList:res.data.data.rows || []
  139. }
  140. },
  141. async submit2(){
  142. //对子级回复
  143. let res = await Qareplybyid({
  144. floorId:this.popupData.id,
  145. content:this.inputValue2,
  146. replyId:this.replyId,
  147. replyType:this.replyType, //回复类型 1:回复主题 2:回复楼层 3:回复楼层内的评论
  148. },this.popupData.topicId)
  149. if (res.data.code == 200) {
  150. util.toastFunc('回复成功')
  151. this.inputValue2 = ''
  152. //初始化请求页签
  153. this.pageNum = 1
  154. this.dataList = []
  155. //获取评论列表
  156. this.getTopicReply()
  157. this.$emit('initDatalist')
  158. }
  159. },
  160. open() {
  161. // console.log('open');
  162. },
  163. close() {
  164. // this.popupShow = false
  165. this.$emit('closeComment')
  166. },
  167. toReply(item,type){
  168. //获取对谁回复
  169. console.log(item);
  170. this.replyType = type
  171. if (type == 3) {
  172. this.replyId = item.id
  173. }else{
  174. this.replyId = ''
  175. }
  176. this.popupPlaceholder = `对${item.authorName}回复`
  177. }
  178. }
  179. }
  180. </script>
  181. <style lang="scss" scoped>
  182. .content{
  183. width: 750rpx;
  184. position: fixed;
  185. bottom: 0;
  186. z-index: 100;
  187. }
  188. .comment{
  189. display: flex;
  190. width: 700rpx;
  191. margin-top: 10rpx;
  192. }
  193. .right_content{
  194. width: 598rpx;
  195. margin-left: 26rpx;
  196. }
  197. .rc_1{
  198. width: 500rpx;
  199. height: 50rpx;
  200. font-size: 28rpx;
  201. font-weight: 400;
  202. color: #666666;
  203. word-break: break-all;
  204. text-overflow: ellipsis;
  205. overflow: hidden;
  206. line-height: 50rpx;
  207. margin-left: 16rpx;
  208. }
  209. .rc_2{
  210. width: 500rpx;
  211. height: 50rpx;
  212. font-size: 28rpx;
  213. font-weight: 400;
  214. color: #999999;
  215. line-height: 40rpx;
  216. }
  217. .rc_3{
  218. max-width: 660rpx;
  219. font-size: 32rpx;
  220. font-weight: 500;
  221. color: #333333;
  222. line-height: 48rpx;
  223. margin-bottom: 24rpx;
  224. }
  225. .btn{
  226. width: 150rpx;
  227. height: 70rpx;
  228. margin-left: 20rpx;
  229. border-radius: 40rpx;
  230. background: #46a6ff;
  231. text-align: center;
  232. line-height: 70rpx;
  233. font-size: 28rpx;
  234. color: #fff;
  235. }
  236. .popupTitle{
  237. width: 140rpx;
  238. height: 45rpx;
  239. line-height: 45rpx;
  240. font-size: 32rpx;
  241. font-family: PingFang SC, PingFang SC-Bold;
  242. font-weight: 700;
  243. text-align: left;
  244. color: #333333;
  245. margin: 30rpx;
  246. }
  247. .popupView{
  248. height: 1000rpx;
  249. display: flex;
  250. padding-top: 10rpx;
  251. flex-direction: column;
  252. align-items: center;
  253. }
  254. .scrollview{
  255. height: 900rpx;
  256. overflow: auto;
  257. }
  258. .btnflex{
  259. display: flex;
  260. flex-direction: row;
  261. align-items: center;
  262. position: fixed;
  263. bottom: 0;
  264. left: 0;
  265. width: 750rpx;
  266. height: 100rpx;
  267. background: #ffffff;
  268. }
  269. .commentInput{
  270. width: 520rpx;
  271. background: #EEEEEE;
  272. border-radius: 40rpx 40rpx 40rpx 40rpx;
  273. margin-left: 30rpx;
  274. }
  275. .loadmore{
  276. height:200rpx;
  277. text-align: center;
  278. font-size: 28rpx;
  279. font-weight: 400;
  280. color: #999;
  281. padding-top: 24rpx;
  282. }
  283. .commentInput{
  284. background: #EEEEEE;
  285. border-radius: 40rpx 40rpx 40rpx 40rpx;
  286. }
  287. .one_recomment_box{
  288. width: 660rpx;
  289. background: #f6f6f6;
  290. margin: 0 auto;
  291. padding: 20rpx;
  292. }
  293. .one_comment_box{
  294. margin: 0 auto;
  295. padding: 10rpx;
  296. }
  297. .comment_foot{
  298. display: flex;
  299. justify-content: space-between;
  300. }
  301. </style>