release.vue 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414
  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">
  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. return {
  166. title: util.removeHtml(item.content),
  167. imageUrl: img,
  168. path: url
  169. };
  170. },
  171. onReachBottom() {
  172. this.form.page++;
  173. this.getOfficeList();
  174. },
  175. methods: {
  176. jumpUrl(url) {
  177. uni.navigateTo({
  178. url: url
  179. });
  180. },
  181. jumpUrlPoi(item,url){
  182. this.currentPoi = item;
  183. uni.navigateTo({
  184. url: url
  185. })
  186. },
  187. removeHtml(content) {
  188. return util.removeHtml(content);
  189. },
  190. //预览图片
  191. previewImgss(picUrls, index) {
  192. //预览合同图片
  193. var src = picUrls[index];
  194. let imgs = picUrls;
  195. uni.previewImage({
  196. current: src, // 当前显示图片的http链接
  197. urls: imgs
  198. });
  199. },
  200. jumpUrlDetail(item) {
  201. //日记,不做跳转
  202. if (this.type == 3) {
  203. return;
  204. }
  205. if (item.source) {
  206. this.jumpUrl('/office/detail/detail?contentId=' + item.source);
  207. } else {
  208. this.jumpUrl('/office/detail/detail?contentId=' + item.id);
  209. }
  210. },
  211. toUserHomePage(userId) {
  212. this.jumpUrl('/topics/home/home?userId=' + userId);
  213. },
  214. //切换类型
  215. swiType(type) {
  216. if (this.type == type) return false;
  217. this.type = type;
  218. this.isLoad = true;
  219. this.form.page = 1;
  220. this.isExamine = type;
  221. this.getOfficeList();
  222. if (this.videoCurrent != null) {
  223. var videoContextPrev = uni.createVideoContext('myVideo' + this.videoCurrent)
  224. videoContextPrev.stop()
  225. this.videoCurrent = ''
  226. }
  227. if (type == 1) {
  228. uni.setNavigationBarTitle({
  229. title: '我发布的'
  230. });
  231. } else {
  232. uni.setNavigationBarTitle({
  233. title: '我收藏的'
  234. });
  235. }
  236. },
  237. sum(arr) {
  238. var s = 0;
  239. for (var i = arr.length - 1; i >= 0; i--) {
  240. if (arr[i].count) {
  241. s += Number(arr[i].count);
  242. }
  243. }
  244. return s;
  245. },
  246. getOfficeList() {
  247. let that = this;
  248. var pramData = this.form;
  249. // pramData.type = this.type;
  250. pramData.orderType = 2;
  251. pramData.userId = this.userInfo.id;
  252. let apiUrl = '';
  253. if (this.type == 1) {
  254. apiUrl = '/api/v3/moments/list';
  255. } else {
  256. apiUrl = '/api/v3/moments/collectionList';
  257. }
  258. if (!this.isLoad) return false;
  259. this.isLoad = false;
  260. uni.showLoading();
  261. req.getRequest(apiUrl, pramData, data => {
  262. if (data && data.length > 0) {
  263. data.map(it => {
  264. if (it.qyPoll && it.qyPoll.isEnd) {
  265. it.qyPoll.voteCount = that.sum(JSON.parse(it.qyPoll.optionJson));
  266. }
  267. if(it.url){
  268. let h = it.url.substring(it.url.lastIndexOf('.') + 1)
  269. if(h.indexOf('mp4')<0&&h.indexOf('MP4')<0){
  270. it.url = it.url.split(',');
  271. }else{
  272. it.isHaveVideo = true
  273. it.isControls = false
  274. it.isShowPlayBtn = true
  275. }
  276. }
  277. 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>'
  278. return it;
  279. });
  280. }
  281. if (data && data.length >= this.form.limit) {
  282. this.isLoad = true;
  283. }
  284. if (this.form.page > 1) {
  285. data = this.pageList.concat(data);
  286. }
  287. this.pageList = data;
  288. this.isShowView = true;
  289. uni.hideLoading();
  290. });
  291. },
  292. //提交点赞、取消点赞;收藏、取消收藏
  293. submitFabulous(type, id, index) {
  294. if (!req.isLogins(true)) {
  295. return;
  296. }
  297. var dataP = {};
  298. dataP.type = type; //1,观看 ,2点赞,3评论,4分享,5收藏
  299. dataP.momentsId = id;
  300. req.postRequestLoding('/api/v3/fabulous/save', dataP, data => {
  301. if (type == 2) {
  302. //动态点赞
  303. if (this.pageList[index].isPraise == 1) {
  304. //已赞
  305. this.pageList[index].isPraise = 0;
  306. this.pageList[index].count.fabulousCount--;
  307. } else {
  308. this.pageList[index].isPraise = 1;
  309. this.pageList[index].count.fabulousCount++;
  310. }
  311. }
  312. });
  313. },
  314. //提交投票
  315. submitPoll(item, pIndex, pollIndex) {
  316. if (item.qyPoll.isEnd) {
  317. this.jumpUrlDetail(item);
  318. return false;
  319. }
  320. var dataP = {};
  321. // dataP.id = item.id;
  322. dataP.pollId = item.qyPoll.id;
  323. var pollObjList = JSON.parse(item.qyPoll.optionJson);
  324. dataP.pollOptionCode = pollObjList[pollIndex].code;
  325. req.postRequest('/api/v3/poll/saveDetails', dataP, data => {
  326. req.msg('投票成功');
  327. //图片完之后要将该投票的对象返回,便于做渲染%
  328. this.pageList[pIndex].qyPoll = data;
  329. });
  330. },
  331. appToShare(item) {
  332. var img = '';
  333. if (item.url) {
  334. var imgList = item.url;
  335. img = imgList[0] + '?x-oss-process=style/w375';
  336. } else {
  337. let config = JSON.parse(req.getStorage('configRes'));
  338. img = config.share_pic;
  339. }
  340. var text = util.removeHtml(item.content);
  341. uni.share({
  342. provider: 'weixin',
  343. scene: 'WXSceneSession',
  344. type: 5,
  345. imageUrl: img,
  346. title: text,
  347. summary: text,
  348. miniProgram: {
  349. id: req.public.miniProgramGh_id,
  350. path: 'office/detail/detail?contentId=' + item.id,
  351. type: 0,
  352. webUrl: 'http://www.lemonban.com'
  353. },
  354. success: ret => {
  355. console.log(ret);
  356. },
  357. fail: ret => {
  358. console.log(ret);
  359. }
  360. });
  361. },
  362. videoPlay(index){
  363. var that = this;
  364. var curIdx = index;
  365. this.pageList[index].isControls = true
  366. this.pageList[index].isShowPlayBtn = false
  367. // 有播放时先将prev暂停,再播放当前点击的current
  368. if (that.videoCurrent != null) {
  369. var videoContextPrev = uni.createVideoContext('myVideo' + that.videoCurrent)
  370. if (that.videoCurrent != curIdx) {
  371. this.pageList[that.videoCurrent].isControls = false
  372. this.pageList[that.videoCurrent].isShowPlayBtn = true
  373. videoContextPrev.stop()
  374. }
  375. that.videoCurrent = curIdx
  376. var videoContextCurrent = uni.createVideoContext('myVideo' + curIdx)
  377. videoContextCurrent.play()
  378. } else {
  379. // 没有播放时播放视频
  380. that.videoCurrent = curIdx
  381. var videoContext = uni.createVideoContext('myVideo' + curIdx) // 对应的视频id
  382. videoContext.play()
  383. }
  384. },
  385. videoPause(index){
  386. this.pageList[index].isControls = false
  387. this.pageList[index].isShowPlayBtn = true
  388. },
  389. videoEnded(index){
  390. this.pageList[index].isControls = false
  391. this.pageList[index].isShowPlayBtn = true
  392. }
  393. }
  394. };
  395. </script>
  396. <style>
  397. @import './release.css';
  398. </style>