index.vue 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486
  1. <template>
  2. <view>
  3. <view class="top-fixed" :style="'height:' + systems.barHeight + 'rpx;'">
  4. <navigator open-type="navigateBack" hover-class="none" class="back ddflex" :style="'top:' + systems.ktxStatusHeight + 'rpx;height:' + systems.navigationHeight + 'rpx;'">
  5. <image :src="picUrlss+'lezhan/back_black.png'"></image>
  6. </navigator>
  7. </view>
  8. <view class="top" :style="'padding-top:' + systems.barHeight + 'rpx;'">
  9. <view class="info ddflex">
  10. <image :src="teamInfo.url?teamInfo.url:picUrlss+'office_images/team_default.png'" mode="aspectFill" class="team-pic"></image>
  11. <view class="fflex">
  12. <view class="title">{{teamInfo.title}}</view>
  13. <view class="sta ddflex">
  14. <view class="ddflex fflex">
  15. <view><text>{{teamInfo.memberNum?teamInfo.memberNum:0}}</text>成员</view>
  16. <view class="sta-line">|</view>
  17. <view><text>{{totalNum}}</text>帖子</view>
  18. </view>
  19. <view class="sta-datas">今日互动{{teamInfo.dayMomentsNum}}</view>
  20. </view>
  21. </view>
  22. </view>
  23. <view class="bri ddflex" @click="jumpUrl('/office/teamInfo/index?id='+teamInfo.id)">
  24. <view class="fflex tovers">{{teamInfo.description}}</view>
  25. <image src="../../static/pages/images/more.png" class="rico"></image>
  26. </view>
  27. <view class="leader ddflex">
  28. <text>队长</text>
  29. <image :src="teamInfo.teamUserDTO.avatar?teamInfo.teamUserDTO.avatar:'../../static/images/userimg.png'" mode="aspectFill"></image>
  30. <view>{{teamInfo.teamUserDTO.realName?teamInfo.teamUserDTO.realName:teamInfo.teamUserDTO.nickName}}</view>
  31. </view>
  32. <view class="join ddflex" v-if="userInfo&&teamInfo.isJoin != 1">
  33. <view class="fflex">
  34. <view>hi,{{userInfo.name?userInfo.name:userInfo.nickName}}~</view>
  35. <text>欢迎关注{{teamInfo.title}}</text>
  36. </view>
  37. <view class="join-btn" @click="joinTeam">加入</view>
  38. </view>
  39. </view>
  40. <view class="tab ddflex">
  41. <!-- <view :class="'li ' + (pType == 1 ? 'active' : '')" @click="swiPType(1)">综合</view> -->
  42. <view :class="'li ' + (pType == 12 ? 'active' : '')" @click="swiPType(12)">最新</view>
  43. <view :class="'li ' + (pType == 5 ? 'active' : '')" @click="swiPType(5)">热门</view>
  44. </view>
  45. <view class="cons-b">
  46. <view class="list" v-if="officeList && officeList.length > 0">
  47. <view class="li" v-for="(item, index) in officeList" :key="index">
  48. <view class="user ddflex" @click="jumpUrl('/topics/home/home?userId=' + item.userDTO.id)">
  49. <image :src="item.userDTO.avatar" mode="aspectFill" class="userimg"></image>
  50. <view class="fflex">
  51. <view class="namea ddflex">
  52. <view class="name fflex ddflex">{{ item.userDTO.nickName }}<image src="../../static/images/vip_tag.png" class="vip-tag" v-if="item.userDTO.levelGrade > 0"></image></view>
  53. <view class="time">{{ item.time }}</view>
  54. </view>
  55. <view class="area" v-if="item.userDTO.cityName">{{ item.userDTO.provinceName }} {{ item.userDTO.cityName }}</view>
  56. </view>
  57. </view>
  58. <view class="des" @click="jumpUrlDetail(item)"><rich-text :nodes="item.content"></rich-text></view>
  59. <!-- //如果有投票,就不显示图片 -->
  60. <block v-if="!item.qyPoll">
  61. <view class="video" v-if="item.isHaveVideo && config.open_community_video == 1">
  62. <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>
  63. <view class="video-play ddflex" @click="videoPlay(index)" v-if="item.isShowPlayBtn"><image src="../../static/images/play.png"></image></view>
  64. </view>
  65. <view class="imgbox ddflex" @click="jumpUrlDetail(item)" v-if="!item.isHaveVideo"><!-- @click="previewImgss(item.url, idx)" -->
  66. <block v-if="item.url&&item.url.length>0">
  67. <image mode="aspectFill" v-for="(it, idx) in item.url" :src="it" :key="idx"></image>
  68. </block>
  69. </view>
  70. </block>
  71. <!-- 话题 -->
  72. <view class="ddflex" v-if="item.qyDialogu">
  73. <view class="topic ddflex" @click="jumpUrl('/topics/detail/detail?topicId=' + item.qyDialogu.id)">
  74. <image src="../../static/images/topic.png"></image>
  75. {{ item.qyDialogu.title }}
  76. </view>
  77. </view>
  78. <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>
  79. <!-- 投票 -->
  80. <view :class="'vote-box' + (item.qyPoll.isEnd ? ' ends' : '')" v-if="item.qyPoll">
  81. <view class="vote-tit">{{ item.qyPoll.title }}</view>
  82. <block v-if="item.qyPoll.isVote == 1">
  83. <view class="vote-list end" @click="jumpUrlDetail(item)">
  84. <view :class="'lis ddflex ' + (itpy.isVote == 1 ? 'active' : '')" v-for="(itpy, idex) in JSON.parse(item.qyPoll.optionJson)" :key="idex">
  85. <view class="percent" :style="'width:' + parseFloat(itpy.proportion) + '%;'"></view>
  86. <view class="fflex">{{ itpy.name }}</view>
  87. <view>{{ parseFloat(itpy.proportion) + '%' }}</view>
  88. </view>
  89. </view>
  90. </block>
  91. <block v-else>
  92. <view class="vote-list">
  93. <view class="lis" v-for="(itpy, idex) in JSON.parse(item.qyPoll.optionJson)" :key="idex" @click="submitPoll(item, index, idex)">
  94. {{ itpy.name }}
  95. </view>
  96. </view>
  97. </block>
  98. <view class="vote-can" v-if="item.qyPoll.isEnd"><text>{{item.qyPoll.voteCount}}人参与</text>投票已结束</view>
  99. </view>
  100. <view class="product" v-if="item.products && item.products.length > 0">
  101. <view scroll-x="true" class="pro-view pro-view1" v-if="item.products.length == 1">
  102. <view class="lis" v-for="(it, idx) in item.products" :key="idx" @click="toProductDetail(it)">
  103. <view class="ddflex">
  104. <image :src="it.pic + '?x-oss-process=style/w375'" mode="aspectFill" class="pic"></image>
  105. <view class="fflex">
  106. <view class="title tover">{{ it.title }}</view>
  107. <view class="opts ddflex">
  108. <view class="money"><text>¥</text>{{ it.salePrice }}</view>
  109. <view class="pro-btn"><image src="../../static/pages/images/n_cart.png"></image></view>
  110. </view>
  111. </view>
  112. </view>
  113. </view>
  114. </view>
  115. <scroll-view scroll-x="true" class="pro-view" v-else>
  116. <view class="lis" v-for="(it, idx) in item.products" :key="idx" @click="toProductDetail(it)">
  117. <view class="ddflex">
  118. <image :src="it.pic + '?x-oss-process=style/w375'" mode="aspectFill" class="pic"></image>
  119. <view class="fflex">
  120. <view class="title tover">{{ it.title }}</view>
  121. <view class="opts ddflex">
  122. <view class="money"><text>¥</text>{{ it.salePrice }}</view>
  123. <view class="pro-btn"><image src="../../static/pages/images/n_cart.png"></image></view>
  124. </view>
  125. </view>
  126. </view>
  127. </view>
  128. </scroll-view>
  129. </view>
  130. <view class="opt ddflex" v-if="!item.source">
  131. <view class="fflex" @click="jumpUrlDetail(item)">{{fomatNumbers(item.count.browseCount)}}次浏览</view>
  132. <view class="ddflex" @click="submitFabulous(2, item.id, index)">
  133. <image :src="'../../static/images/' + (item.isPraise == 1 ? 'like_h' : 'like') + '.png'"></image>
  134. {{fomatNumbers(item.count.fabulousCount)}}
  135. </view>
  136. <view class="ddflex" @click="jumpUrlDetail(item)" v-if="config.is_show_create_btn == 1">
  137. <image src="../../static/images/comment.png"></image>
  138. {{fomatNumbers(item.count.commentCount)}}
  139. </view>
  140. <button open-type="share" hover-class="none" class="opt-share ddflex">
  141. <image src="../../static/images/share.png"></image>
  142. 分享
  143. </button>
  144. </view>
  145. </view>
  146. </view>
  147. <view class="nodata" v-else>
  148. <image :src="picUrlss + 'empty_jl.png'"></image>
  149. <text>暂无动态</text>
  150. </view>
  151. </view>
  152. <view class="create" @click="createJump('/office/news/news?newsType=1&userGroupId='+opt.id)" v-if="config.is_show_create_btn == 1&&userInfo&&teamInfo.isJoin == 1"><image src="../../static/images/create.png"></image>发布</view>
  153. </view>
  154. </template>
  155. <script>
  156. const app = getApp();
  157. const api = require('../../utils/api.js');
  158. const req = require('../../utils/request.js');
  159. const util = require('../../utils/util.js');
  160. export default {
  161. components: {
  162. },
  163. data() {
  164. return {
  165. systems: {},
  166. picUrlss: req.public.picUrls,
  167. opt: {},
  168. isRefresh: false,
  169. isShowbtn: false,
  170. isShowPage: false,
  171. isLoad: true,
  172. form: {
  173. page: 1,
  174. limit: 10
  175. },
  176. pType: 12, //排序: 1综合, 2最新,3浏览最多,4评论最多,5热门
  177. officeList: [], //聊一聊
  178. config: {},
  179. videoCurrent: null,
  180. videoContext: '',
  181. teamInfo: {},
  182. userInfo: {},
  183. totalNum: 0,
  184. currentPoi: {}
  185. }
  186. },
  187. onLoad(options) {
  188. this.opt = options;
  189. this.getTeamInfo();
  190. this.getOfficeList();
  191. },
  192. onShow() {
  193. if(this.isRefresh){
  194. this.form.page = 1;
  195. this.isLoad = true;
  196. this.getOfficeList();
  197. this.isRefresh = false;
  198. }
  199. this.config = JSON.parse(req.getStorage('configRes'))
  200. this.userInfo = req.getStorage('userInfo');
  201. },
  202. onHide() {
  203. this.isShowbtn = false;
  204. },
  205. onReachBottom() {
  206. this.form.page++;
  207. this.getOfficeList();
  208. },
  209. methods: {
  210. getTeamInfo(){
  211. req.getRequest(api.user_team_info+this.opt.id,{},data=>{
  212. this.teamInfo = data;
  213. })
  214. },
  215. joinTeam(item,index){
  216. req.postRequest(api.user_team_follow,{userGroupId: this.teamInfo.id},data=>{
  217. req.msg('加入团队成功');
  218. })
  219. },
  220. //聊一聊切换排序类型
  221. swiPType(type) {
  222. this.isLoad = true;
  223. this.form.page = 1;
  224. this.pType = type;
  225. this.getOfficeList();
  226. },
  227. //预览图片
  228. previewImgss(picUrls, index) {
  229. //预览合同图片
  230. var src = picUrls[index];
  231. let imgs = picUrls;
  232. uni.previewImage({
  233. current: src, // 当前显示图片的http链接
  234. urls: imgs
  235. });
  236. },
  237. showBtn() {
  238. if (!req.isLogins(true)) {
  239. return;
  240. }
  241. this.isShowbtn = true;
  242. },
  243. hideBtn() {
  244. this.isShowbtn = false;
  245. },
  246. removeHtml(content) {
  247. return util.removeHtml(content);
  248. },
  249. createJump(url) {
  250. if (!req.isLogins(true)) {
  251. return;
  252. }
  253. this.jumpUrl(url);
  254. },
  255. jumpUrl(url){
  256. uni.navigateTo({
  257. url: url
  258. })
  259. },
  260. jumpUrlPoi(item,url){
  261. this.currentPoi = item;
  262. uni.navigateTo({
  263. url: url
  264. })
  265. },
  266. jumpToPractice(item,url){
  267. let checkCategory = {
  268. id: item.question.cateId,
  269. name: item.question.cateName
  270. }
  271. req.setStorage('checkCategory',checkCategory)
  272. this.jumpUrl(url);
  273. },
  274. jumpUrlDetail(item) {
  275. this.jumpUrl('/office/detail/detail?contentId=' + item.id);
  276. },
  277. toProductDetail(item) {
  278. this.jumpUrl('/product/detail/detail?id=' + item.id);
  279. },
  280. getHotTopic() {
  281. var dataPram = {
  282. page: 1,
  283. limit: 4,
  284. attr: 2
  285. };
  286. req.getRequest('/api/v3/dialogue/list', dataPram, data => {
  287. this.hotTopicList = data;
  288. });
  289. },
  290. getHotPoll() {
  291. var dataPram = {
  292. page: 1,
  293. limit: 4,
  294. attr: 2,
  295. attrType: 0
  296. };
  297. req.getRequest('/api/v3/poll/pollList', dataPram, data => {
  298. this.hotPollList = data;
  299. });
  300. },
  301. getCategory(){
  302. req.getRequest('/api/v3/unified/tree/list',{type: 1},data=>{
  303. this.category = data;
  304. })
  305. },
  306. swiTree(item,index){
  307. if(this.cateIndex == index) return false;
  308. this.cateIndex = index;
  309. this.pType = -1;
  310. this.treeId = item.id;
  311. this.form.page = 1;
  312. this.isLoad = true;
  313. this.getOfficeList()
  314. },
  315. sum(arr) {
  316. var s = 0;
  317. for (var i=arr.length-1; i>=0; i--) {
  318. if(arr[i].count){
  319. s += Number(arr[i].count);
  320. }
  321. }
  322. return s;
  323. },
  324. fomatNumbers(num){
  325. return util.formatNumbers(num)
  326. },
  327. getOfficeList() {
  328. let that = this;
  329. var pramData = {};
  330. pramData.page = this.form.page;
  331. pramData.limit = this.form.limit;
  332. // pramData.type = 4;
  333. if (this.pType == 5) {
  334. //热门
  335. pramData.isEssence = 2;
  336. pramData.orderType = 1;
  337. } else {
  338. pramData.orderType = this.pType;
  339. }
  340. if(this.treeId) {
  341. pramData.treeId = this.treeId
  342. pramData.orderType = 1
  343. }else delete pramData.treeId
  344. pramData.userGroupId = this.opt.id;
  345. if (!this.isLoad) return false;
  346. this.isLoad = false;
  347. req.getRequest('/api/v3/moments/page', pramData, data => {
  348. if(data.list&&data.list.length > 0){
  349. data.list.map(it=>{
  350. if(it.qyPoll && it.qyPoll.isEnd){
  351. it.qyPoll.voteCount = that.sum(JSON.parse(it.qyPoll.optionJson))
  352. }
  353. if(it.url){
  354. let h = it.url.substring(it.url.lastIndexOf('.') + 1)
  355. if(h.indexOf('mp4')<0&&h.indexOf('MP4')<0){
  356. it.url = it.url.split(',');
  357. }else{
  358. it.isHaveVideo = true
  359. it.isControls = false
  360. it.isShowPlayBtn = true
  361. }
  362. }
  363. 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>'
  364. return it;
  365. })
  366. }
  367. if (data.list && data.list.length >= 10) {
  368. this.isLoad = true;
  369. }
  370. if (this.form.page > 1) {
  371. data.list = this.officeList.concat(data.list);
  372. } else {
  373. this.officeList = [];
  374. }
  375. this.officeList = data.list;
  376. if(this.pType == 12) this.totalNum = data.total;
  377. this.isShowPage = true;
  378. });
  379. },
  380. //提交点赞、取消点赞;收藏、取消收藏
  381. submitFabulous(type, id, index) {
  382. if (!req.isLogins(true)) {
  383. return;
  384. }
  385. var dataP = {};
  386. dataP.type = type; //1,观看 ,2点赞,3评论,4分享,5收藏
  387. dataP.momentsId = id;
  388. req.postRequestLoding('/api/v3/fabulous/save', dataP, data => {
  389. if (type == 2) {
  390. //动态点赞
  391. if (this.officeList[index].isPraise == 1) {
  392. //已赞
  393. this.officeList[index].isPraise = 0;
  394. this.officeList[index].count.fabulousCount--;
  395. } else {
  396. this.officeList[index].isPraise = 1;
  397. this.officeList[index].count.fabulousCount++;
  398. }
  399. }
  400. });
  401. },
  402. //提交投票
  403. submitPoll(item, pIndex, pollIndex) {
  404. if(item.qyPoll.isEnd){
  405. this.jumpUrlDetail(item)
  406. return false;
  407. }
  408. var dataP = {};
  409. // dataP.id = item.id;
  410. dataP.pollId = item.qyPoll.id;
  411. var pollObjList = JSON.parse(item.qyPoll.optionJson);
  412. dataP.pollOptionCode = pollObjList[pollIndex].code;
  413. req.postRequest('/api/v3/poll/saveDetails', dataP, data => {
  414. req.msg('投票成功');
  415. //图片完之后要将该投票的对象返回,便于做渲染%
  416. this.officeList[pIndex].qyPoll = data;
  417. });
  418. },
  419. goTop: function(e) {
  420. // 一键回到顶部
  421. if (uni.pageScrollTo) {
  422. uni.pageScrollTo({
  423. scrollTop: 0
  424. });
  425. } else {
  426. uni.showModal({
  427. title: '提示',
  428. content: '当前微信版本过低,无法使用该功能,请升级到最新微信版本后重试。'
  429. });
  430. }
  431. },
  432. videoPlay(index){
  433. var that = this;
  434. var curIdx = index;
  435. this.officeList[index].isControls = true
  436. this.officeList[index].isShowPlayBtn = false
  437. // 有播放时先将prev暂停,再播放当前点击的current
  438. if (that.videoCurrent != null) {
  439. var videoContextPrev = uni.createVideoContext('myVideo' + that.videoCurrent)
  440. if (that.videoCurrent != curIdx) {
  441. this.officeList[that.videoCurrent].isControls = false
  442. this.officeList[that.videoCurrent].isShowPlayBtn = true
  443. videoContextPrev.stop()
  444. }
  445. that.videoCurrent = curIdx
  446. var videoContextCurrent = uni.createVideoContext('myVideo' + curIdx)
  447. videoContextCurrent.play()
  448. } else {
  449. // 没有播放时播放视频
  450. that.videoCurrent = curIdx
  451. var videoContext = uni.createVideoContext('myVideo' + curIdx) // 对应的视频id
  452. videoContext.play()
  453. }
  454. },
  455. videoPause(index){
  456. this.officeList[index].isControls = false
  457. this.officeList[index].isShowPlayBtn = true
  458. },
  459. videoEnded(index){
  460. this.officeList[index].isControls = false
  461. this.officeList[index].isShowPlayBtn = true
  462. }
  463. },
  464. created() {
  465. const systemInfo = uni.getSystemInfoSync();
  466. // px转换到rpx的比例
  467. let pxToRpxScale = 750 / systemInfo.windowWidth;
  468. let systems = {
  469. ktxStatusHeight: systemInfo.statusBarHeight * pxToRpxScale, // 状态栏的高度
  470. navigationHeight: 44 * pxToRpxScale // 导航栏的高度
  471. };
  472. systems.barHeight = systems.ktxStatusHeight + systems.navigationHeight;
  473. this.systems = systems;
  474. },
  475. }
  476. </script>
  477. <style>
  478. @import "./index.css";
  479. </style>