comments.vue 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180
  1. <template>
  2. <view v-if="isShow">
  3. <view class="con">
  4. <view class="cons">
  5. <view class="c-user ddflex">
  6. <image :src="params.userDTO.avatar ? params.userDTO.avatar : '../../static/images/userImg.png'" mode="scaleToFill" class="userimg" @click="toUserHomePage(params.userDTO)"></image>
  7. <view class="fflex" @click="toUserHomePage(params.userDTO)">
  8. <view class="name fflex ddflex">{{ params.userDTO.nickName }}</view>
  9. <view class="area" v-if="params.userDTO.cityName">{{ params.userDTO.provinceName }} {{ params.userDTO.cityName }}</view>
  10. </view>
  11. <view class="zan ddflex" @click="submitFabulous(2, params.id)">
  12. <image :src="'../../static/images/' + (params.isPraise == 1 ? 'like_h' : 'like') + '.png'"></image>
  13. {{ params.praiseNO }}
  14. </view>
  15. </view>
  16. <view class="c-des">{{ params.content }}</view>
  17. <view class="sta ddflex">
  18. <view class="time">{{ params.time }}</view>
  19. <view class="yuan" @click="jumpUrl('/office/detail/detail?contentId=' + params.momentsDto.id)">查看原动态</view>
  20. </view>
  21. <view class="replys" v-if="params.plist && params.plist.length > 0">
  22. <view class="lis" @click="showReply(params, itm, index)" v-for="(itm, idx) in params.plist">
  23. <text>{{ itm.userDTO.nickName }}</text>
  24. <text class="lz" v-if="itm.userDTO.isLandlord == 1">楼主</text>
  25. <block v-if="itm.toUserDTO && itm.toUserDTO.nickName">
  26. 回复
  27. <text>{{ itm.toUserDTO.nickName }}</text>
  28. <text class="lz" v-if="itm.toUserDTO.isLandlord == 1">楼主</text>
  29. </block>
  30. : {{ itm.content }}
  31. </view>
  32. </view>
  33. </view>
  34. </view>
  35. <view class="ceng" v-if="isShowReplys" @click="hideReply()"></view>
  36. <view class="bot1 ddflex" v-if="isShowReply">
  37. <view class="reply-sr ddflex fflex">
  38. <input
  39. v-model="commentContent"
  40. :placeholder="checkUserDTO ? '回复' + checkUserDTO.nickName : '输入的内容'"
  41. placeholder-class="placeholder"
  42. class="ipt fflex"
  43. />
  44. <view class="submit" @click="submitComment()">提交</view>
  45. </view>
  46. </view>
  47. </view>
  48. </template>
  49. <script>
  50. //获取应用实例
  51. const app = getApp();
  52. const req = require('../../utils/request.js');
  53. const api = require('../../utils/api.js');
  54. const utils = require('../../utils/util.js');
  55. export default {
  56. data() {
  57. return {
  58. isShow: false,
  59. commentId: '',
  60. isShowReply: true,
  61. isShowReplys: false,
  62. params: {},
  63. commentContent: '',
  64. commentType: 2, //1评论动态,2回复外层评论,3回复二级评论
  65. checkConmmentItem: '',
  66. checkUserDTO: '',
  67. checkPositionIndex: '' ,//选中的下标
  68. checkItm: '',
  69. commentIds: '',//二级评论id
  70. };
  71. },
  72. onLoad(opt) {
  73. this.commentId = opt.commentId
  74. if(opt.isSecond){
  75. this.commentIds = opt.commentIds
  76. }
  77. this.getComments()
  78. this.getUpdateIsSee();
  79. },
  80. onShow() {
  81. },
  82. methods: {
  83. getUpdateIsSee(){
  84. let params = {
  85. id: this.commentId
  86. }
  87. if(this.commentIds){
  88. params.id = this.commentIds
  89. }
  90. req.postRequest('/api/v3/fabulous/updateIsSee',params,res=>{})
  91. },
  92. getComments(){
  93. req.getRequest('/api/v3/fabulous/seeFabulousInfo',{id: this.commentId},res=>{
  94. this.params = res;
  95. this.checkConmmentItem = res;
  96. this.isShow = true;
  97. })
  98. },
  99. toUserHomePage(userObj) {
  100. if (userObj.isApiUser != 1) {
  101. //不是后台用户,则可跳转
  102. this.jumpUrl('/topics/home/home?userId=' + userObj.id);
  103. }
  104. },
  105. //提交点赞、取消点赞;收藏、取消收藏
  106. submitFabulous(type, pid) {
  107. if (!req.isLogins(true)) {
  108. return;
  109. }
  110. var dataP = {};
  111. dataP.type = type; //1,观看 ,2点赞,3评论,4分享,5收藏
  112. dataP.pid = pid;
  113. dataP.momentsId = this.params.momentsId;
  114. req.postRequestLoding('/api/v3/fabulous/save', dataP, data => {
  115. this.params.isPraise = 1
  116. });
  117. },
  118. showReply(conmmentItem, itm, position) {
  119. if (!req.isLogins(true)) {
  120. return;
  121. }
  122. this.commentContent = '';
  123. this.isShowReplys = true;
  124. this.checkConmmentItem = conmmentItem;
  125. this.checkItm = itm;//二级评论
  126. this.checkUserDTO = itm.userDTO;
  127. this.checkPositionIndex = position;
  128. if (!conmmentItem) {
  129. this.commentType = 1;
  130. } else {
  131. if (!itm.userDTO) {
  132. this.commentType = 2;
  133. } else {
  134. this.commentType = 3;
  135. }
  136. }
  137. },
  138. hideReply() {
  139. this.isShowReplys = false;
  140. },
  141. //提交评论
  142. submitComment() {
  143. var dataP = {};
  144. dataP.type = 3;
  145. if (this.commentContent) {
  146. dataP.content = this.commentContent;
  147. } else {
  148. req.msg('请输入评论内容');
  149. return;
  150. }
  151. //1评论动态,2回复外层评论,3回复二级评论
  152. if (this.commentType == 2) {
  153. dataP.pid = this.checkConmmentItem.id;
  154. } else if (this.commentType == 3) {
  155. dataP.pid = this.checkConmmentItem.id;
  156. dataP.replyId = this.checkItm.id;
  157. dataP.toUserId = this.checkUserDTO.id;
  158. }
  159. dataP.momentsId = this.params.momentsId;
  160. req.postRequestLoding('/api/v3/fabulous/save', dataP, data => {
  161. req.msg('评论成功');
  162. this.hideReply();
  163. this.params.plist.push(data);
  164. });
  165. },
  166. jumpUrl(url){
  167. uni.navigateTo({
  168. url: url
  169. })
  170. }
  171. }
  172. };
  173. </script>
  174. <style>
  175. @import './comments.css';
  176. </style>