detail.vue 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467
  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">
  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" @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. };
  196. },
  197. onLoad(opt) {
  198. this.topicId = opt.topicId;
  199. req.saveBehaviorNew(this.topicId,21,4)
  200. },
  201. onShow() {
  202. this.getTopicsInfo();
  203. this.swiPType(1);
  204. this.config = JSON.parse(req.getStorage('configRes'))
  205. },
  206. onShareAppMessage(option) {
  207. let item = option.target.dataset.item; //取到传入的参数
  208. console.log('==', item);
  209. var url = '/office/detail/detail?contentId=' + item.id;
  210. var img = '';
  211. if (item.url) {
  212. var imgList = item.url;
  213. img = imgList[0];
  214. } else {
  215. }
  216. req.saveBehaviorNew(item.id, item.pollId?10:11,6)
  217. return {
  218. title: util.removeHtml(item.content),
  219. imageUrl: img,
  220. path: url
  221. };
  222. },
  223. onReachBottom() {
  224. this.form.page++;
  225. this.getOfficeList();
  226. },
  227. onHide() {
  228. this.isShowbtn = false;
  229. },
  230. methods: {
  231. showBtn() {
  232. this.isShowbtn = true;
  233. },
  234. hideBtn() {
  235. this.isShowbtn = false;
  236. },
  237. removeHtml(content) {
  238. return util.removeHtml(content);
  239. },
  240. createJump(url) {
  241. if (!req.isLogins(true)) {
  242. return;
  243. }
  244. this.jumpUrl(url);
  245. },
  246. jumpUrl(url) {
  247. uni.navigateTo({
  248. url: url
  249. });
  250. },
  251. jumpUrlPoi(item,url){
  252. this.currentPoi = item;
  253. uni.navigateTo({
  254. url: url
  255. })
  256. },
  257. //预览图片
  258. previewImgss(picUrls, index) {
  259. //预览合同图片
  260. var src = picUrls[index];
  261. let imgs = picUrls;
  262. uni.previewImage({
  263. current: src, // 当前显示图片的http链接
  264. urls: imgs
  265. });
  266. },
  267. jumpUrlDetail(item) {
  268. if (item.source) {
  269. this.jumpUrl('/office/detail/detail?contentId=' + item.source);
  270. } else {
  271. this.jumpUrl('/office/detail/detail?contentId=' + item.id);
  272. }
  273. },
  274. //切换类型
  275. swiPType(type) {
  276. this.isLoad = true;
  277. this.form.page = 1;
  278. this.pType = type;
  279. this.getOfficeList();
  280. },
  281. toUserHomePage(userId) {
  282. this.jumpUrl('/topics/home/home?userId=' + userId);
  283. },
  284. getTopicsInfo() {
  285. req.getRequest('/api/v3/dialogue/info', { id: this.topicId }, data => {
  286. this.topicDetail = data;
  287. this.isShowView = true;
  288. });
  289. },
  290. sum(arr) {
  291. var s = 0;
  292. for (var i = arr.length - 1; i >= 0; i--) {
  293. if (arr[i].count) {
  294. s += Number(arr[i].count);
  295. }
  296. }
  297. return s;
  298. },
  299. getOfficeList() {
  300. let that = this;
  301. var pramData = this.form;
  302. pramData.dialogueId = this.topicId;
  303. pramData.orderType = this.pType;
  304. if (!this.isLoad) return false;
  305. this.isLoad = false;
  306. req.getRequest('/api/v3/moments/list', pramData, data => {
  307. if (data && data.length > 0) {
  308. data.map(it => {
  309. if (it.qyPoll && it.qyPoll.isEnd) {
  310. it.qyPoll.voteCount = that.sum(JSON.parse(it.qyPoll.optionJson));
  311. }
  312. if(it.url){
  313. let h = it.url.substring(it.url.lastIndexOf('.') + 1)
  314. if(h.indexOf('mp4')<0&&h.indexOf('MP4')<0){
  315. it.url = it.url.split(',');
  316. }else{
  317. it.isHaveVideo = true
  318. it.isControls = false
  319. it.isShowPlayBtn = true
  320. }
  321. }
  322. 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>'
  323. return it;
  324. });
  325. }
  326. if (data && data.length >= this.form.limit) {
  327. this.isLoad = true;
  328. }
  329. if (this.form.page > 1) {
  330. data = this.officeList.concat(data);
  331. }
  332. this.officeList = data;
  333. this.isShowView = true;
  334. });
  335. },
  336. //提交点赞、取消点赞;收藏、取消收藏
  337. submitFabulous(type, id, index) {
  338. if (!req.isLogins(true)) {
  339. return;
  340. }
  341. var dataP = {};
  342. dataP.type = type; //1,观看 ,2点赞,3评论,4分享,5收藏
  343. dataP.momentsId = id;
  344. req.postRequestLoding('/api/v3/fabulous/save', dataP, data => {
  345. if (type == 2) {
  346. //动态点赞
  347. if (this.officeList[index].isPraise == 1) {
  348. //已赞
  349. this.officeList[index].isPraise = 0;
  350. this.officeList[index].count.fabulousCount--;
  351. req.saveBehaviorNew(id, this.officeList[index].pollId?10:11,11)
  352. } else {
  353. this.officeList[index].isPraise = 1;
  354. this.officeList[index].count.fabulousCount++;
  355. req.saveBehaviorNew(id, this.officeList[index].pollId?10:11,3)
  356. }
  357. }
  358. });
  359. },
  360. //提交投票
  361. submitPoll(item, pIndex, pollIndex) {
  362. if (item.qyPoll.isEnd) return req.msg('投票已结束');
  363. var dataP = {};
  364. // dataP.id = item.id;
  365. dataP.pollId = item.qyPoll.id;
  366. var pollObjList = JSON.parse(item.qyPoll.optionJson);
  367. dataP.pollOptionCode = pollObjList[pollIndex].code;
  368. req.postRequest('/api/v3/poll/saveDetails', dataP, data => {
  369. req.msg('投票成功');
  370. //图片完之后要将该投票的对象返回,便于做渲染%
  371. this.officeList[pIndex].qyPoll = data;
  372. req.saveBehaviorNew(item.id,10,5)
  373. });
  374. },
  375. appToShare(item) {
  376. console.log('数据>>>>', item);
  377. var img = '';
  378. if (item.url) {
  379. var imgList = item.url;
  380. img = imgList[0];
  381. } else {
  382. let config = JSON.parse(req.getStorage('configRes'));
  383. img = config.share_pic;
  384. }
  385. console.log('数据>>>>2222', img);
  386. var text = util.removeHtml(item.content);
  387. uni.share({
  388. provider: 'weixin',
  389. scene: 'WXSceneSession',
  390. type: 5,
  391. imageUrl: img,
  392. title: text,
  393. summary: text,
  394. miniProgram: {
  395. id: req.public.miniProgramGh_id,
  396. path: 'office/detail/detail?contentId=' + item.id,
  397. type: 0,
  398. webUrl: 'http://www.lemonban.com'
  399. },
  400. success: ret => {
  401. console.log(ret);
  402. },
  403. fail: ret => {
  404. console.log(ret);
  405. }
  406. });
  407. },
  408. videoPlay(index){
  409. var that = this;
  410. var curIdx = index;
  411. this.officeList[index].isControls = true
  412. this.officeList[index].isShowPlayBtn = false
  413. // 有播放时先将prev暂停,再播放当前点击的current
  414. if (that.videoCurrent != null) {
  415. var videoContextPrev = uni.createVideoContext('myVideo' + that.videoCurrent)
  416. if (that.videoCurrent != curIdx) {
  417. this.officeList[that.videoCurrent].isControls = false
  418. this.officeList[that.videoCurrent].isShowPlayBtn = true
  419. videoContextPrev.stop()
  420. }
  421. that.videoCurrent = curIdx
  422. var videoContextCurrent = uni.createVideoContext('myVideo' + curIdx)
  423. videoContextCurrent.play()
  424. } else {
  425. // 没有播放时播放视频
  426. that.videoCurrent = curIdx
  427. var videoContext = uni.createVideoContext('myVideo' + curIdx) // 对应的视频id
  428. videoContext.play()
  429. }
  430. },
  431. videoPause(index){
  432. this.officeList[index].isControls = false
  433. this.officeList[index].isShowPlayBtn = true
  434. },
  435. videoEnded(index){
  436. this.officeList[index].isControls = false
  437. this.officeList[index].isShowPlayBtn = true
  438. }
  439. },
  440. created() {
  441. const systemInfo = uni.getSystemInfoSync();
  442. // px转换到rpx的比例
  443. let pxToRpxScale = 750 / systemInfo.windowWidth;
  444. let systems = {
  445. ktxStatusHeight: systemInfo.statusBarHeight * pxToRpxScale, // 状态栏的高度
  446. navigationHeight: 44 * pxToRpxScale // 导航栏的高度
  447. };
  448. systems.barHeight = systems.ktxStatusHeight + systems.navigationHeight;
  449. this.systems = systems;
  450. }
  451. };
  452. </script>
  453. <style>
  454. @import './detail.css';
  455. </style>