detail.vue 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477
  1. <template>
  2. <view v-if="isShowView">
  3. <view class="top" :style="'height:' + systems.barHeight + 'rpx;'">
  4. <navigator open-type="navigateBack" hover-class="none" class="back" :style="'height:' + systems.navigationHeight + 'rpx;top:' + systems.ktxStatusHeight + 'rpx;'">
  5. <image src="../static/images/back.png"></image>
  6. </navigator>
  7. </view>
  8. <image :src="topicDetail.posterUrl ? topicDetail.posterUrl : '../static/images/topsimg.png'" class="pic"></image>
  9. <view class="con">
  10. <view class="title ddflex">
  11. <view class="fflex"># {{ topicDetail.title }}</view>
  12. <!-- <view class="gzbtn">+关注</view> -->
  13. </view>
  14. <view class="bri" v-if="topicDetail.subtitle">{{ topicDetail.subtitle }}</view>
  15. <view class="cy">{{ topicDetail.participantsNO }}人参与</view>
  16. </view>
  17. <view class="tab ddflex">
  18. <view :class="'li ' + (pType == 1 ? 'active' : '')" @click="swiPType(1)">综合</view>
  19. <view :class="'li ' + (pType == 2 ? 'active' : '')" @click="swiPType(2)">最新</view>
  20. <view :class="'li ' + (pType == 3 ? 'active' : '')" @click="swiPType(3)">浏览最多</view>
  21. <view :class="'li ' + (pType == 4 ? 'active' : '')" @click="swiPType(4)">评论最多</view>
  22. </view>
  23. <view class="list" v-if="officeList && officeList.length > 0">
  24. <view class="li" v-for="(item, index) in officeList" :key="index">
  25. <view class="user ddflex" @click="toUserHomePage(item.userDTO.id)">
  26. <image :src="item.userDTO.avatar" mode="aspectFill" class="userimg"></image>
  27. <view class="fflex">
  28. <view class="namea ddflex">
  29. <view class="name fflex ddflex">{{ item.userDTO.nickName }}
  30. <!-- <image src="../../static/images/vip_tag.png" class="vip-tag" v-if="item.userDTO.levelGrade > 0"></image> -->
  31. <image v-if="item.userDTO.isOpenWeRunData" style="width:15rpx;height:20rpx;margin-left: 10rpx;" src="../../static/images/yd.png"></image>
  32. </view>
  33. <view class="time">{{ item.time }}</view>
  34. </view>
  35. <view class="area" v-if="item.userDTO.cityName">{{ item.userDTO.provinceName }} {{ item.userDTO.cityName }}</view>
  36. </view>
  37. </view>
  38. <!-- 分享的动态 -->
  39. <block v-if="item.source">
  40. <view class="link ddflex" @click="jumpUrlDetail(item)">
  41. <block v-if="item.url && item.url.length > 0"><image mode="aspectFill" v-if="idx == 0" v-for="(it, idx) in item.url" :src="it" :key="idx"></image></block>
  42. <view class="fflex tover"><rich-text :nodes="item.content"></rich-text></view>
  43. </view>
  44. </block>
  45. <!-- 非分享的动态 -->
  46. <block v-else>
  47. <view v-if="item.type == 2" class="des tovers" @click="jumpUrlDetail(item)">
  48. <view class="wen">提问</view>
  49. {{ removeHtml(item.content) }}
  50. </view>
  51. <view class="des" v-else @click="jumpUrlDetail(item)"><rich-text :nodes="item.content"></rich-text></view>
  52. <!-- //如果有投票,就不显示图片 -->
  53. <block v-if="!item.qyPoll">
  54. <view class="video" v-if="item.isHaveVideo && config.open_community_video == 1">
  55. <video :src="item.url" :show-center-play-btn="false" :controls="item.isControls" :autoplay="item.isControls" :id="'myVideo'+index" @pause="videoPause(index)" @ended="videoEnded(index)"></video>
  56. <view class="video-play ddflex" @click="videoPlay(index)" v-if="item.isShowPlayBtn"><image src="../../static/images/play.png"></image></view>
  57. </view>
  58. <view class="imgbox ddflex" @click="jumpUrlDetail(item)" v-if="!item.isHaveVideo"><!-- @click="previewImgss(item.url, idx)" -->
  59. <block v-if="item.url&&item.url.length>0">
  60. <image mode="aspectFill" v-for="(it, idx) in item.url" :src="it" :key="idx"></image>
  61. </block>
  62. </view>
  63. </block>
  64. <!-- 话题 -->
  65. <view class="ddflex" v-if="item.qyDialogu&&item.qyDialogu.isExamine==1">
  66. <view class="topic ddflex" @click="jumpUrl('/topics/detail/detail?topicId=' + item.qyDialogu.id)">
  67. <image src="../../static/images/topic.png"></image>
  68. {{ item.qyDialogu.title }}
  69. </view>
  70. </view>
  71. <view class="loca ddflex" @click="jumpUrlPoi(item,'/office/poi/index')" v-if="item.poiName"><image :src="picUrlss+'office_images/loca.png'"></image><text v-if="item.poiDistance > 0">{{item.poiDistance ? item.poiDistance < 1000 ? item.poiDistance+'m' : (item.poiDistance/1000).toFixed(1)+'km' : ''}}</text>{{item.poiName}}</view>
  72. <!-- 投票 -->
  73. <view :class="'vote-box' + (item.qyPoll.isEnd ? ' ends' : '')" v-if="item.qyPoll">
  74. <view class="vote-tit">{{ item.qyPoll.title }}</view>
  75. <block v-if="item.qyPoll.isVote == 1">
  76. <view class="vote-list end" @click="jumpUrlDetail(item)">
  77. <view :class="'lis ddflex ' + (itpy.isVote == 1 ? 'active' : '')" v-for="(itpy, idex) in JSON.parse(item.qyPoll.optionJson)" :key="idex">
  78. <view class="percent" :style="'width:' + parseFloat(itpy.proportion) + '%;'"></view>
  79. <view class="fflex">{{ itpy.name }}</view>
  80. <view>{{ parseFloat(itpy.proportion) + '%' }}</view>
  81. </view>
  82. </view>
  83. </block>
  84. <block v-else>
  85. <view class="vote-list">
  86. <view class="lis" v-for="(itpy, idex) in JSON.parse(item.qyPoll.optionJson)" :key="idex" @click="submitPoll(item, index, idex)">
  87. {{ itpy.name }}
  88. </view>
  89. </view>
  90. </block>
  91. <view class="vote-can" v-if="item.qyPoll.isEnd">
  92. <text>{{ item.qyPoll.voteCount }}人参与</text>
  93. 投票已结束
  94. </view>
  95. </view>
  96. <block v-if="item.type==10||item.type==11">
  97. <view v-if="item.type==10" class="ddflex step-box" style="justify-content: space-between;" @click="jumpUrl('/exercise/record/record?userId=' + item.userId)">
  98. <view>
  99. <view class="step-date">{{item.wxRun.step}}</view>
  100. <view class="step-label">步数</view>
  101. </view>
  102. <view>
  103. <view class="step-date">{{item.wxRun.index}}</view>
  104. <view class="step-label" style="text-align: right;">名次</view>
  105. </view>
  106. </view>
  107. <view v-if="item.type==11" class="ddflex step-box" style="justify-content: space-between;" @click="jumpUrl('/match/activityDetail/activityDetail?id=' + item.matchContent.id)">
  108. <image class="step-pic" :src="item.matchContent.pic" mode="aspectFill"></image>
  109. <view class="fflex">
  110. <view class="step-title tovers">{{item.matchContent.title}}</view>
  111. <view class="ddflex" style="justify-content: space-between;margin-top: 10rpx;">
  112. <view class="step-price">{{item.matchContent.endTime}}</view>
  113. <view class="step-btn">查看</view>
  114. </view>
  115. </view>
  116. </view>
  117. </block>
  118. <view v-if="item.userGroupId" class="ddflex step-box" style="padding: 25rpx 21rpx;" @click="jumpUrl('/office/team/index?id=' + item.userGroupId)">
  119. <image style="width: 24rpx;height: 24rpx;margin-right: 13rpx;" src="../../static/images/link.png"></image>
  120. <view style="font-weight: 500;color: #999999;">Team:</view>
  121. <view>{{item.userGroupTitle}}</view>
  122. </view>
  123. </block>
  124. <view class="opt ddflex" v-if="!item.source">
  125. <view class="fflex" @click="jumpUrlDetail(item)">{{ item.count.browseCount }}次浏览</view>
  126. <view class="ddflex" @click="submitFabulous(2, item.id, index)">
  127. <image :src="'../../static/images/' + (item.isPraise == 1 ? 'like_h' : 'like') + '.png'"></image>
  128. {{ item.count.fabulousCount < 99 ? item.count.fabulousCount : '99+' }}
  129. </view>
  130. <view class="ddflex" @click="jumpUrlDetail(item)">
  131. <image src="../../static/images/comment.png"></image>
  132. {{ item.count.commentCount < 99 ? item.count.commentCount : '99+' }}
  133. </view>
  134. <!-- #ifdef MP-WEIXIN -->
  135. <button open-type="share" class="opt-share ddflex" :data-item="item">
  136. <image src="../../static/images/share.png"></image>
  137. 分享
  138. </button>
  139. <!-- #endif -->
  140. <!-- #ifdef APP-PLUS -->
  141. <view class="opt-share ddflex" @click="appToShare(item)">
  142. <image src="../../static/images/share.png"></image>
  143. 分享
  144. </view>
  145. <!-- #endif -->
  146. </view>
  147. </view>
  148. </view>
  149. <view class="nodata" v-else>
  150. <image :src="picUrlss + 'empty_jl.png'"></image>
  151. <text>暂无动态</text>
  152. </view>
  153. <view class="create" v-if="config.is_show_create_btn == 1 && havePermission" @click="createJump('/office/news/news?topicId=' + topicId)">
  154. <image style="display: block;" src="../../static/images/create.png"></image>
  155. 发帖
  156. </view>
  157. <!-- <view class="create" @click="showBtn"><image src="../../static/images/create.png"></image>发布</view> -->
  158. <!-- <view class="ceng" v-if="isShowbtn" @click="hideBtn"></view>
  159. <view class="side ddflex" v-if="isShowbtn">
  160. <view class="li" @click="createJump('/office/diary/diary')">
  161. <image src="../../static/images/quanzi.png"></image>
  162. <view>创建话题</view>
  163. </view>
  164. <view class="li" @click="createJump('/office/news/news?topicId=' + topicId)">
  165. <image src="../../static/images/tiezi.png"></image>
  166. <view>发帖</view>
  167. </view>
  168. </view> -->
  169. </view>
  170. </template>
  171. <script>
  172. const app = getApp();
  173. const req = require('../../utils/request.js');
  174. const util = require('../../utils/util.js');
  175. export default {
  176. data() {
  177. return {
  178. picUrlss: req.public.picUrls,
  179. systems: {},
  180. isShowbtn: false,
  181. topicId: '', //话题ID
  182. isLoad: true,
  183. form: {
  184. page: 1,
  185. limit: 10
  186. },
  187. pType: 1, //排序: 1综合, 2最新,3浏览最多,4评论最多,5热门
  188. officeList: [],
  189. isShowView: false,
  190. topicDetail: '',
  191. videoCurrent: null,
  192. videoContext: '',
  193. config: {},
  194. currentPoi: {},
  195. havePermission:false//当前用户是否有发帖权限
  196. };
  197. },
  198. onLoad(opt) {
  199. this.topicId = opt.topicId;
  200. req.saveBehaviorNew(this.topicId,21,4)
  201. // 获取是否有发帖权限
  202. this.getUserPermission()
  203. },
  204. onShow() {
  205. this.getTopicsInfo();
  206. this.swiPType(1);
  207. this.config = JSON.parse(req.getStorage('configRes'))
  208. },
  209. onShareAppMessage(option) {
  210. let item = option.target.dataset.item; //取到传入的参数
  211. console.log('==', item);
  212. var url = '/office/detail/detail?contentId=' + item.id;
  213. var img = '';
  214. if (item.url) {
  215. var imgList = item.url;
  216. img = imgList[0];
  217. } else {
  218. }
  219. req.saveBehaviorNew(item.id, item.pollId?10:11,6)
  220. return {
  221. title: util.removeHtml(item.content),
  222. imageUrl: img,
  223. path: url
  224. };
  225. },
  226. onReachBottom() {
  227. this.form.page++;
  228. this.getOfficeList();
  229. },
  230. onHide() {
  231. this.isShowbtn = false;
  232. },
  233. methods: {
  234. getUserPermission(){
  235. req.getRequest('/api/user/getUserPermission',{},res=>{
  236. if(res){
  237. this.havePermission = res.map(item=>item.permissions).indexOf('sys:post')>-1?true:false
  238. }
  239. })
  240. },
  241. showBtn() {
  242. this.isShowbtn = true;
  243. },
  244. hideBtn() {
  245. this.isShowbtn = false;
  246. },
  247. removeHtml(content) {
  248. return util.removeHtml(content);
  249. },
  250. createJump(url) {
  251. if (!req.isLogins(true)) {
  252. return;
  253. }
  254. this.jumpUrl(url);
  255. },
  256. jumpUrl(url) {
  257. uni.navigateTo({
  258. url: url
  259. });
  260. },
  261. jumpUrlPoi(item,url){
  262. this.currentPoi = item;
  263. uni.navigateTo({
  264. url: url
  265. })
  266. },
  267. //预览图片
  268. previewImgss(picUrls, index) {
  269. //预览合同图片
  270. var src = picUrls[index];
  271. let imgs = picUrls;
  272. uni.previewImage({
  273. current: src, // 当前显示图片的http链接
  274. urls: imgs
  275. });
  276. },
  277. jumpUrlDetail(item) {
  278. if (item.source) {
  279. this.jumpUrl('/office/detail/detail?contentId=' + item.source);
  280. } else {
  281. this.jumpUrl('/office/detail/detail?contentId=' + item.id);
  282. }
  283. },
  284. //切换类型
  285. swiPType(type) {
  286. this.isLoad = true;
  287. this.form.page = 1;
  288. this.pType = type;
  289. this.getOfficeList();
  290. },
  291. toUserHomePage(userId) {
  292. this.jumpUrl('/topics/home/home?userId=' + userId);
  293. },
  294. getTopicsInfo() {
  295. req.getRequest('/api/v3/dialogue/info', { id: this.topicId }, data => {
  296. this.topicDetail = data;
  297. this.isShowView = true;
  298. });
  299. },
  300. sum(arr) {
  301. var s = 0;
  302. for (var i = arr.length - 1; i >= 0; i--) {
  303. if (arr[i].count) {
  304. s += Number(arr[i].count);
  305. }
  306. }
  307. return s;
  308. },
  309. getOfficeList() {
  310. let that = this;
  311. var pramData = this.form;
  312. pramData.dialogueId = this.topicId;
  313. pramData.orderType = this.pType;
  314. if (!this.isLoad) return false;
  315. this.isLoad = false;
  316. req.getRequest('/api/v3/moments/list', pramData, data => {
  317. if (data && data.length > 0) {
  318. data.map(it => {
  319. if (it.qyPoll && it.qyPoll.isEnd) {
  320. it.qyPoll.voteCount = that.sum(JSON.parse(it.qyPoll.optionJson));
  321. }
  322. if(it.url){
  323. let h = it.url.substring(it.url.lastIndexOf('.') + 1)
  324. if(h.indexOf('mp4')<0&&h.indexOf('MP4')<0){
  325. it.url = it.url.split(',');
  326. }else{
  327. it.isHaveVideo = true
  328. it.isControls = false
  329. it.isShowPlayBtn = true
  330. }
  331. }
  332. it.content = '<div style="overflow: hidden;text-overflow: ellipsis;display: -webkit-box;-webkit-line-clamp: 5;-webkit-box-orient: vertical;word-break: break-all;">' + it.content + '</div>'
  333. return it;
  334. });
  335. }
  336. if (data && data.length >= this.form.limit) {
  337. this.isLoad = true;
  338. }
  339. if (this.form.page > 1) {
  340. data = this.officeList.concat(data);
  341. }
  342. this.officeList = data;
  343. this.isShowView = true;
  344. });
  345. },
  346. //提交点赞、取消点赞;收藏、取消收藏
  347. submitFabulous(type, id, index) {
  348. if (!req.isLogins(true)) {
  349. return;
  350. }
  351. var dataP = {};
  352. dataP.type = type; //1,观看 ,2点赞,3评论,4分享,5收藏
  353. dataP.momentsId = id;
  354. req.postRequestLoding('/api/v3/fabulous/save', dataP, data => {
  355. if (type == 2) {
  356. //动态点赞
  357. if (this.officeList[index].isPraise == 1) {
  358. //已赞
  359. this.officeList[index].isPraise = 0;
  360. this.officeList[index].count.fabulousCount--;
  361. req.saveBehaviorNew(id, this.officeList[index].pollId?10:11,11)
  362. } else {
  363. this.officeList[index].isPraise = 1;
  364. this.officeList[index].count.fabulousCount++;
  365. req.saveBehaviorNew(id, this.officeList[index].pollId?10:11,3)
  366. }
  367. }
  368. });
  369. },
  370. //提交投票
  371. submitPoll(item, pIndex, pollIndex) {
  372. if (item.qyPoll.isEnd) return req.msg('投票已结束');
  373. var dataP = {};
  374. // dataP.id = item.id;
  375. dataP.pollId = item.qyPoll.id;
  376. var pollObjList = JSON.parse(item.qyPoll.optionJson);
  377. dataP.pollOptionCode = pollObjList[pollIndex].code;
  378. req.postRequest('/api/v3/poll/saveDetails', dataP, data => {
  379. req.msg('投票成功');
  380. //图片完之后要将该投票的对象返回,便于做渲染%
  381. this.officeList[pIndex].qyPoll = data;
  382. req.saveBehaviorNew(item.id,10,5)
  383. });
  384. },
  385. appToShare(item) {
  386. console.log('数据>>>>', item);
  387. var img = '';
  388. if (item.url) {
  389. var imgList = item.url;
  390. img = imgList[0];
  391. } else {
  392. let config = JSON.parse(req.getStorage('configRes'));
  393. img = config.share_pic;
  394. }
  395. console.log('数据>>>>2222', img);
  396. var text = util.removeHtml(item.content);
  397. uni.share({
  398. provider: 'weixin',
  399. scene: 'WXSceneSession',
  400. type: 5,
  401. imageUrl: img,
  402. title: text,
  403. summary: text,
  404. miniProgram: {
  405. id: req.public.miniProgramGh_id,
  406. path: 'office/detail/detail?contentId=' + item.id,
  407. type: 0,
  408. webUrl: 'http://www.lemonban.com'
  409. },
  410. success: ret => {
  411. console.log(ret);
  412. },
  413. fail: ret => {
  414. console.log(ret);
  415. }
  416. });
  417. },
  418. videoPlay(index){
  419. var that = this;
  420. var curIdx = index;
  421. this.officeList[index].isControls = true
  422. this.officeList[index].isShowPlayBtn = false
  423. // 有播放时先将prev暂停,再播放当前点击的current
  424. if (that.videoCurrent != null) {
  425. var videoContextPrev = uni.createVideoContext('myVideo' + that.videoCurrent)
  426. if (that.videoCurrent != curIdx) {
  427. this.officeList[that.videoCurrent].isControls = false
  428. this.officeList[that.videoCurrent].isShowPlayBtn = true
  429. videoContextPrev.stop()
  430. }
  431. that.videoCurrent = curIdx
  432. var videoContextCurrent = uni.createVideoContext('myVideo' + curIdx)
  433. videoContextCurrent.play()
  434. } else {
  435. // 没有播放时播放视频
  436. that.videoCurrent = curIdx
  437. var videoContext = uni.createVideoContext('myVideo' + curIdx) // 对应的视频id
  438. videoContext.play()
  439. }
  440. },
  441. videoPause(index){
  442. this.officeList[index].isControls = false
  443. this.officeList[index].isShowPlayBtn = true
  444. },
  445. videoEnded(index){
  446. this.officeList[index].isControls = false
  447. this.officeList[index].isShowPlayBtn = true
  448. }
  449. },
  450. created() {
  451. const systemInfo = uni.getSystemInfoSync();
  452. // px转换到rpx的比例
  453. let pxToRpxScale = 750 / systemInfo.windowWidth;
  454. let systems = {
  455. ktxStatusHeight: systemInfo.statusBarHeight * pxToRpxScale, // 状态栏的高度
  456. navigationHeight: 44 * pxToRpxScale // 导航栏的高度
  457. };
  458. systems.barHeight = systems.ktxStatusHeight + systems.navigationHeight;
  459. this.systems = systems;
  460. }
  461. };
  462. </script>
  463. <style>
  464. @import './detail.css';
  465. </style>