comments.vue 7.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246
  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. location: {},
  71. poiIndex: -1,
  72. poiList: [],
  73. };
  74. },
  75. onLoad(opt) {
  76. this.commentId = opt.commentId
  77. if(opt.isSecond){
  78. this.commentIds = opt.commentIds
  79. }
  80. this.getComments()
  81. this.getUpdateIsSee();
  82. QQMapWX.initMap();
  83. let location = {
  84. latitude: req.getStorage('loctionAddressMap').location.lat,
  85. longitude: req.getStorage('loctionAddressMap').location.lng
  86. }
  87. QQMapWX.reverseGeocoder(location, data => {
  88. this.poiList = data.pois;
  89. this.checkLocation(this.poiList[0],0)
  90. });
  91. },
  92. onShow() {
  93. },
  94. methods: {
  95. chooseLocation(){
  96. let that = this;
  97. uni.chooseLocation({//choosePoi不返回经纬度
  98. success: function (res) {
  99. console.log('位置名称:' , res);
  100. that.location = {
  101. poiName: res.name,
  102. poiAddress: res.address,
  103. poiLongitude: res.longitude,
  104. poiLatitude: res.latitude
  105. }
  106. that.reverseGeocoder(res);
  107. }
  108. });
  109. },
  110. reverseGeocoder(location) {
  111. QQMapWX.initMap();
  112. QQMapWX.reverseGeocoder(location, data => {
  113. this.location.poiRegionalism = data.ad_info.adcode.substring(0, 2) + "0000," + data.ad_info.adcode.substring(0, 4) +"00," + data.ad_info.adcode
  114. console.log('解析后的地址地址数据:', data,this.location.poiRegionalism);
  115. });
  116. },
  117. checkLocation(item,index){
  118. if(this.poiIndex == index) return false;
  119. this.poiIndex = index;
  120. this.location = {
  121. poiName: item.title,
  122. poiAddress: item.address,
  123. poiLongitude: item.location.lng,
  124. poiLatitude: item.location.lat,
  125. poiRegionalism: item.ad_info.adcode.substring(0, 2) + "0000," + item.ad_info.adcode.substring(0, 4) +"00," + item.ad_info.adcode
  126. }
  127. },
  128. getUpdateIsSee(){
  129. let params = {
  130. id: this.commentId
  131. }
  132. if(this.commentIds){
  133. params.id = this.commentIds
  134. }
  135. req.postRequest('/api/v3/fabulous/updateIsSee',params,res=>{})
  136. },
  137. getComments(){
  138. req.getRequest('/api/v3/fabulous/seeFabulousInfo',{id: this.commentId},res=>{
  139. this.params = res;
  140. this.checkConmmentItem = res;
  141. this.isShow = true;
  142. })
  143. },
  144. toUserHomePage(userObj) {
  145. if (userObj.isApiUser != 1) {
  146. //不是后台用户,则可跳转
  147. this.jumpUrl('/topics/home/home?userId=' + userObj.id);
  148. }
  149. },
  150. //提交点赞、取消点赞;收藏、取消收藏
  151. submitFabulous(type, pid) {
  152. if (!req.isLogins(true)) {
  153. return;
  154. }
  155. var dataP = {};
  156. dataP.type = type; //1,观看 ,2点赞,3评论,4分享,5收藏
  157. dataP.pid = pid;
  158. dataP.momentsId = this.params.momentsId;
  159. // 位置
  160. if(this.location&&this.location.poiName){
  161. dataP.poiName = this.location.poiName;
  162. dataP.poiAddress = this.location.poiAddress;
  163. dataP.poiLongitude = this.location.poiLongitude;
  164. dataP.poiLatitude = this.location.poiLatitude;
  165. dataP.poiRegionalism = this.location.poiRegionalism
  166. }
  167. req.postRequestLoding('/api/v3/fabulous/save', dataP, data => {
  168. this.params.isPraise = 1
  169. });
  170. },
  171. showReply(conmmentItem, itm, position) {
  172. if (!req.isLogins(true)) {
  173. return;
  174. }
  175. this.commentContent = '';
  176. this.isShowReplys = true;
  177. this.checkConmmentItem = conmmentItem;
  178. this.checkItm = itm;//二级评论
  179. this.checkUserDTO = itm.userDTO;
  180. this.checkPositionIndex = position;
  181. if (!conmmentItem) {
  182. this.commentType = 1;
  183. } else {
  184. if (!itm.userDTO) {
  185. this.commentType = 2;
  186. } else {
  187. this.commentType = 3;
  188. }
  189. }
  190. },
  191. hideReply() {
  192. this.isShowReplys = false;
  193. },
  194. //提交评论
  195. submitComment() {
  196. var dataP = {};
  197. dataP.type = 3;
  198. if (this.commentContent) {
  199. dataP.content = this.commentContent;
  200. } else {
  201. req.msg('请输入评论内容');
  202. return;
  203. }
  204. //1评论动态,2回复外层评论,3回复二级评论
  205. if (this.commentType == 2) {
  206. dataP.pid = this.checkConmmentItem.id;
  207. } else if (this.commentType == 3) {
  208. dataP.pid = this.checkConmmentItem.id;
  209. dataP.replyId = this.checkItm.id;
  210. dataP.toUserId = this.checkUserDTO.id;
  211. }
  212. dataP.momentsId = this.params.momentsId;
  213. // 位置
  214. if(this.location&&this.location.poiName){
  215. dataP.poiName = this.location.poiName;
  216. dataP.poiAddress = this.location.poiAddress;
  217. dataP.poiLongitude = this.location.poiLongitude;
  218. dataP.poiLatitude = this.location.poiLatitude;
  219. dataP.poiRegionalism = this.location.poiRegionalism
  220. }
  221. req.postRequestLoding('/api/v3/fabulous/save', dataP, data => {
  222. req.msg('评论成功');
  223. this.hideReply();
  224. this.params.plist.push(data);
  225. });
  226. },
  227. jumpUrl(url){
  228. uni.navigateTo({
  229. url: url
  230. })
  231. }
  232. }
  233. };
  234. </script>
  235. <style>
  236. @import './comments.css';
  237. </style>