index.vue 18 KB

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