release.vue 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418
  1. <template>
  2. <view>
  3. <view class="tab ddflex">
  4. <view :class="'li ' + (type == 1 ? 'active' : '')" @click="swiType(1)">我发布的</view>
  5. <view :class="'li ' + (type == 2 ? 'active' : '')" @click="swiType(2)">我收藏的</view>
  6. <!-- <view :class="'li ' + (type == 3 ? 'active' : '')" @click="swiType(3)">日记</view> -->
  7. </view>
  8. <view class="placeholder-view"></view>
  9. <view class="list" v-if="pageList && pageList.length > 0">
  10. <view class="li" v-for="(item, index) in pageList" :key="index">
  11. <view class="user ddflex" @click="toUserHomePage(item.userDTO.id)">
  12. <image :src="item.userDTO.avatar" mode="aspectFill" class="userimg"></image>
  13. <view class="fflex">
  14. <view class="namea ddflex">
  15. <view class="name fflex ddflex">
  16. {{ item.userDTO.nickName }}
  17. <image v-if="item.userDTO.levelGrade > 0" src="../../static/images/vip_tag.png" class="vip-tag"></image>
  18. </view>
  19. <view class="time">{{ item.time }}</view>
  20. </view>
  21. <view class="area" v-if="item.userDTO.cityName">{{ item.userDTO.provinceName }} {{ item.userDTO.cityName }}</view>
  22. </view>
  23. </view>
  24. <!-- 分享的动态 -->
  25. <block v-if="item.source">
  26. <view class="link ddflex" @click="jumpUrlDetail(item)">
  27. <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>
  28. <view class="fflex tover"><rich-text :nodes="item.content"></rich-text></view>
  29. </view>
  30. </block>
  31. <!-- 非分享的动态 -->
  32. <block v-else>
  33. <view v-if="item.type == 2" class="des tovers" @click="jumpUrlDetail(item)">
  34. <view class="wen">提问</view>
  35. {{ removeHtml(item.content) }}
  36. </view>
  37. <view class="des" v-else @click="jumpUrlDetail(item)"><rich-text :nodes="item.content"></rich-text></view>
  38. <!-- //如果有投票,就不显示图片 -->
  39. <block v-if="!item.qyPoll">
  40. <view class="video" v-if="item.isHaveVideo && config.open_community_video == 1">
  41. <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>
  42. <view class="video-play ddflex" @click="videoPlay(index)" v-if="item.isShowPlayBtn"><image src="../../static/images/play.png"></image></view>
  43. </view>
  44. <view class="imgbox ddflex" @click="jumpUrlDetail(item)" v-if="!item.isHaveVideo"><!-- @click="previewImgss(item.url, idx)" -->
  45. <block v-if="item.url&&item.url.length>0">
  46. <image mode="aspectFill" v-for="(it, idx) in item.url" :src="it" :key="idx"></image>
  47. </block>
  48. </view>
  49. </block>
  50. <!-- 话题 -->
  51. <view class="ddflex" v-if="item.qyDialogu&&item.qyDialogu.isExamine==1">
  52. <view class="topic ddflex" @click="jumpUrl('/topics/detail/detail?topicId=' + item.qyDialogu.id)">
  53. <image src="../../static/images/topic.png"></image>
  54. {{ item.qyDialogu.title }}
  55. </view>
  56. </view>
  57. <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>
  58. <!-- 投票 -->
  59. <view :class="'vote-box' + (item.qyPoll && item.qyPoll.isEnd ? ' ends' : '')" v-if="item.qyPoll">
  60. <view class="vote-tit">{{ item.qyPoll.title }}</view>
  61. <block v-if="item.qyPoll.isVote == 1">
  62. <view class="vote-list end" @click="jumpUrlDetail(item)">
  63. <view :class="'lis ddflex ' + (itpy.isVote == 1 ? 'active' : '')" v-for="(itpy, idex) in JSON.parse(item.qyPoll.optionJson)" :key="idex">
  64. <view class="percent" :style="'width:' + parseFloat(itpy.proportion) + '%;'"></view>
  65. <view class="fflex">{{ itpy.name }}</view>
  66. <view>{{ parseFloat(itpy.proportion) + '%' }}</view>
  67. </view>
  68. </view>
  69. </block>
  70. <block v-else>
  71. <view class="vote-list">
  72. <view class="lis" v-for="(itpy, idex) in JSON.parse(item.qyPoll.optionJson)" :key="idex" @click="submitPoll(item, index, idex)">
  73. {{ itpy.name }}
  74. </view>
  75. </view>
  76. </block>
  77. <view class="vote-can" v-if="item.qyPoll.isEnd">
  78. <text>{{ item.qyPoll.voteCount }}人参与</text>
  79. 投票已结束
  80. </view>
  81. </view>
  82. </block>
  83. <view class="que ddflex" v-if="item.question" @click="jumpUrl('/learn/topic/index?questId=' + item.question.id)">
  84. <!-- <image src="../../static/images/ht_ico1.png" class="st-ico"></image> -->
  85. <view class="fflex"><rich-text :nodes="item.question.title" class="tovers"></rich-text></view>
  86. <!-- <image src="../../static/images/ht_ico2.png" class="st-rico"></image> -->
  87. </view>
  88. <view class="cates ddflex" v-if="item.question && item.question.cateName">
  89. <text>{{ item.question.cateName }}</text>
  90. <!-- <text>自动化测试</text> -->
  91. </view>
  92. <view class="opt ddflex" v-if="!item.source && type != 3">
  93. <view class="fflex" @click="jumpUrlDetail(item)">{{ item.count.browseCount }}次浏览</view>
  94. <view class="ddflex" @click="submitFabulous(2, item.id, index)">
  95. <image :src="'../../static/images/' + (item.isPraise == 1 ? 'like_h' : 'like') + '.png'"></image>
  96. {{ item.count.fabulousCount < 99 ? item.count.fabulousCount : '99+' }}
  97. </view>
  98. <view class="ddflex" @click="jumpUrlDetail(item)">
  99. <image src="../../static/images/comment.png"></image>
  100. {{ item.count.commentCount < 99 ? item.count.commentCount : '99+' }}
  101. </view>
  102. <!-- #ifdef MP-WEIXIN -->
  103. <button open-type="share" class="opt-share ddflex" :data-item="item">
  104. <image src="../../static/images/share.png"></image>
  105. 分享
  106. </button>
  107. <!-- #endif -->
  108. <!-- #ifdef APP-PLUS -->
  109. <view class="opt-share ddflex" @click="appToShare(item)">
  110. <image src="../../static/images/share.png"></image>
  111. 分享
  112. </view>
  113. <!-- #endif -->
  114. </view>
  115. </view>
  116. </view>
  117. <view class="nodata" v-else>
  118. <image :src="picUrlss + 'empty_jl.png'"></image>
  119. <text>{{ type == 1 ? '暂无动态' : type == 2 ? '暂无提问' : type == 3 ? '暂无日记' : '' }}</text>
  120. </view>
  121. </view>
  122. </template>
  123. <script>
  124. const app = getApp();
  125. const req = require('../../utils/request.js');
  126. const api = require('../../utils/api.js');
  127. const util = require('../../utils/util.js');
  128. export default {
  129. data() {
  130. return {
  131. picUrlss: req.public.picUrls,
  132. userInfo: '',
  133. isLoad: true,
  134. form: {
  135. page: 1,
  136. limit: 10
  137. },
  138. type: 1, //1 聊一聊,2提问 3日记
  139. isExamine: 1,
  140. pageList: [],
  141. isShowView: false,
  142. videoCurrent: null,
  143. videoContext: '',
  144. config: {},
  145. currentPoi: {}
  146. };
  147. },
  148. onLoad() {
  149. this.userInfo = req.getStorage('userInfo');
  150. this.getOfficeList();
  151. },
  152. onShow() {
  153. this.config = JSON.parse(req.getStorage('configRes'))
  154. },
  155. onShareAppMessage(option) {
  156. let item = option.target.dataset.item; //取到传入的参数
  157. console.log('==', item);
  158. var url = '/office/detail/detail?contentId=' + item.id;
  159. var img = '';
  160. if (item.url) {
  161. var imgList = item.url;
  162. img = imgList[0];
  163. } else {
  164. }
  165. req.saveBehaviorNew(item.id, item.pollId?10:11,6)
  166. return {
  167. title: util.removeHtml(item.content),
  168. imageUrl: img,
  169. path: url
  170. };
  171. },
  172. onReachBottom() {
  173. this.form.page++;
  174. this.getOfficeList();
  175. },
  176. methods: {
  177. jumpUrl(url) {
  178. uni.navigateTo({
  179. url: url
  180. });
  181. },
  182. jumpUrlPoi(item,url){
  183. this.currentPoi = item;
  184. uni.navigateTo({
  185. url: url
  186. })
  187. },
  188. removeHtml(content) {
  189. return util.removeHtml(content);
  190. },
  191. //预览图片
  192. previewImgss(picUrls, index) {
  193. //预览合同图片
  194. var src = picUrls[index];
  195. let imgs = picUrls;
  196. uni.previewImage({
  197. current: src, // 当前显示图片的http链接
  198. urls: imgs
  199. });
  200. },
  201. jumpUrlDetail(item) {
  202. //日记,不做跳转
  203. if (this.type == 3) {
  204. return;
  205. }
  206. if (item.source) {
  207. this.jumpUrl('/office/detail/detail?contentId=' + item.source);
  208. } else {
  209. this.jumpUrl('/office/detail/detail?contentId=' + item.id);
  210. }
  211. },
  212. toUserHomePage(userId) {
  213. this.jumpUrl('/topics/home/home?userId=' + userId);
  214. },
  215. //切换类型
  216. swiType(type) {
  217. if (this.type == type) return false;
  218. this.type = type;
  219. this.isLoad = true;
  220. this.form.page = 1;
  221. this.isExamine = type;
  222. this.getOfficeList();
  223. if (this.videoCurrent != null) {
  224. var videoContextPrev = uni.createVideoContext('myVideo' + this.videoCurrent)
  225. videoContextPrev.stop()
  226. this.videoCurrent = ''
  227. }
  228. if (type == 1) {
  229. uni.setNavigationBarTitle({
  230. title: '我发布的'
  231. });
  232. } else {
  233. uni.setNavigationBarTitle({
  234. title: '我收藏的'
  235. });
  236. }
  237. },
  238. sum(arr) {
  239. var s = 0;
  240. for (var i = arr.length - 1; i >= 0; i--) {
  241. if (arr[i].count) {
  242. s += Number(arr[i].count);
  243. }
  244. }
  245. return s;
  246. },
  247. getOfficeList() {
  248. let that = this;
  249. var pramData = this.form;
  250. // pramData.type = this.type;
  251. pramData.orderType = 2;
  252. pramData.userId = this.userInfo.id;
  253. let apiUrl = '';
  254. if (this.type == 1) {
  255. apiUrl = '/api/v3/moments/list';
  256. } else {
  257. apiUrl = '/api/v3/moments/collectionList';
  258. }
  259. if (!this.isLoad) return false;
  260. this.isLoad = false;
  261. uni.showLoading();
  262. req.getRequest(apiUrl, pramData, data => {
  263. if (data && data.length > 0) {
  264. data.map(it => {
  265. if (it.qyPoll && it.qyPoll.isEnd) {
  266. it.qyPoll.voteCount = that.sum(JSON.parse(it.qyPoll.optionJson));
  267. }
  268. if(it.url){
  269. let h = it.url.substring(it.url.lastIndexOf('.') + 1)
  270. if(h.indexOf('mp4')<0&&h.indexOf('MP4')<0){
  271. it.url = it.url.split(',');
  272. }else{
  273. it.isHaveVideo = true
  274. it.isControls = false
  275. it.isShowPlayBtn = true
  276. }
  277. }
  278. 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>'
  279. return it;
  280. });
  281. }
  282. if (data && data.length >= this.form.limit) {
  283. this.isLoad = true;
  284. }
  285. if (this.form.page > 1) {
  286. data = this.pageList.concat(data);
  287. }
  288. this.pageList = data;
  289. this.isShowView = true;
  290. uni.hideLoading();
  291. });
  292. },
  293. //提交点赞、取消点赞;收藏、取消收藏
  294. submitFabulous(type, id, index) {
  295. if (!req.isLogins(true)) {
  296. return;
  297. }
  298. var dataP = {};
  299. dataP.type = type; //1,观看 ,2点赞,3评论,4分享,5收藏
  300. dataP.momentsId = id;
  301. req.postRequestLoding('/api/v3/fabulous/save', dataP, data => {
  302. if (type == 2) {
  303. //动态点赞
  304. if (this.pageList[index].isPraise == 1) {
  305. //已赞
  306. this.pageList[index].isPraise = 0;
  307. this.pageList[index].count.fabulousCount--;
  308. req.saveBehaviorNew(id, this.pageList[index].pollId?10:11,11)
  309. } else {
  310. this.pageList[index].isPraise = 1;
  311. this.pageList[index].count.fabulousCount++;
  312. req.saveBehaviorNew(id, this.pageList[index].pollId?10:11,3)
  313. }
  314. }
  315. });
  316. },
  317. //提交投票
  318. submitPoll(item, pIndex, pollIndex) {
  319. if (item.qyPoll.isEnd) {
  320. this.jumpUrlDetail(item);
  321. return false;
  322. }
  323. var dataP = {};
  324. // dataP.id = item.id;
  325. dataP.pollId = item.qyPoll.id;
  326. var pollObjList = JSON.parse(item.qyPoll.optionJson);
  327. dataP.pollOptionCode = pollObjList[pollIndex].code;
  328. req.postRequest('/api/v3/poll/saveDetails', dataP, data => {
  329. req.msg('投票成功');
  330. //图片完之后要将该投票的对象返回,便于做渲染%
  331. this.pageList[pIndex].qyPoll = data;
  332. req.saveBehaviorNew(item.id,10,5)
  333. });
  334. },
  335. appToShare(item) {
  336. var img = '';
  337. if (item.url) {
  338. var imgList = item.url;
  339. img = imgList[0];
  340. } else {
  341. let config = JSON.parse(req.getStorage('configRes'));
  342. img = config.share_pic;
  343. }
  344. var text = util.removeHtml(item.content);
  345. uni.share({
  346. provider: 'weixin',
  347. scene: 'WXSceneSession',
  348. type: 5,
  349. imageUrl: img,
  350. title: text,
  351. summary: text,
  352. miniProgram: {
  353. id: req.public.miniProgramGh_id,
  354. path: 'office/detail/detail?contentId=' + item.id,
  355. type: 0,
  356. webUrl: 'http://www.lemonban.com'
  357. },
  358. success: ret => {
  359. console.log(ret);
  360. },
  361. fail: ret => {
  362. console.log(ret);
  363. }
  364. });
  365. },
  366. videoPlay(index){
  367. var that = this;
  368. var curIdx = index;
  369. this.pageList[index].isControls = true
  370. this.pageList[index].isShowPlayBtn = false
  371. // 有播放时先将prev暂停,再播放当前点击的current
  372. if (that.videoCurrent != null) {
  373. var videoContextPrev = uni.createVideoContext('myVideo' + that.videoCurrent)
  374. if (that.videoCurrent != curIdx) {
  375. this.pageList[that.videoCurrent].isControls = false
  376. this.pageList[that.videoCurrent].isShowPlayBtn = true
  377. videoContextPrev.stop()
  378. }
  379. that.videoCurrent = curIdx
  380. var videoContextCurrent = uni.createVideoContext('myVideo' + curIdx)
  381. videoContextCurrent.play()
  382. } else {
  383. // 没有播放时播放视频
  384. that.videoCurrent = curIdx
  385. var videoContext = uni.createVideoContext('myVideo' + curIdx) // 对应的视频id
  386. videoContext.play()
  387. }
  388. },
  389. videoPause(index){
  390. this.pageList[index].isControls = false
  391. this.pageList[index].isShowPlayBtn = true
  392. },
  393. videoEnded(index){
  394. this.pageList[index].isControls = false
  395. this.pageList[index].isShowPlayBtn = true
  396. }
  397. }
  398. };
  399. </script>
  400. <style>
  401. @import './release.css';
  402. </style>