discovery.vue 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544
  1. <template>
  2. <view class="">
  3. <navbar :config="config" backColor="#999999"></navbar>
  4. <view class="itemBox">
  5. <view class="itemBox_title">
  6. <image src="/static/czd/discovery_tag.png" mode=""></image>
  7. 身边人
  8. </view>
  9. <image class="itemBox_banner" :src="banner.moduleImage" mode="" @click="$openPage(banner)"></image>
  10. </view>
  11. <view class="itemBox" v-if="liveList.length>0">
  12. <view class="itemBox_title">
  13. <image src="/static/czd/discovery_tag.png" mode=""></image>
  14. 身边景
  15. </view>
  16. <view class="itemBox_videos">
  17. <view v-for="(v,i) in liveList" :key="i" @click="goLive(v)">
  18. <image class="itemBox_videos_img" :src="v.livePicture" mode=""></image>
  19. <image class="itemBox_videos_switch" src="/static/czd/discovery_switch.png" mode=""></image>
  20. <view class="itemBox_videos_title">{{v.liveTitle}}</view>
  21. </view>
  22. </view>
  23. </view>
  24. <view class="itemBox">
  25. <view class="itemBox_title">
  26. <image src="/static/czd/discovery_tag.png" mode=""></image>
  27. 身边剧
  28. </view>
  29. <view class="itemBox_videos">
  30. <view v-for="(v,i) in 6" :key="i">
  31. <image class="itemBox_videos_img" src="/static/czd/banner_tc.png" mode=""></image>
  32. <view class="itemBox_videos_type">独播</view>
  33. <view class="itemBox_videos_title1">大唐狄公案大唐狄公案大唐狄公案</view>
  34. <view class="itemBox_videos_tig">周一围寻真相破...</view>
  35. </view>
  36. </view>
  37. </view>
  38. <!-- :style="{'top':navHeight + 'px' , 'height':tabsHeight+'rpx','paddingBottom':'30rpx'}" -->
  39. <u-sticky :offset-top="navHeight">
  40. <view class="tabs-box">
  41. <!-- <view class="tab-item" v-for="item in tabs" @click.stop="onChange(item)">
  42. {{ item}}
  43. </view> -->
  44. <view class="tabs-box_title">
  45. <image src="/static/czd/discovery_tag.png" mode=""></image>
  46. <text>身边事</text>
  47. </view>
  48. <u-tabs class="utabs" :list="tabs" active-color="#3CBACF" bar-width="60" bg-color="transparent"
  49. height="80" is-scroll :current="tabIndex" @change="onChange"></u-tabs>
  50. </view>
  51. </u-sticky>
  52. <!-- <view class="" :style="{'width':'100%', 'height': tabsHeight + 'rpx' }" /> -->
  53. <view class="fx-kong-kim" v-if="tabIndex === 0 && KongKim && KongKim.length > 0">
  54. <block v-for="(item , index) in KongKim">
  55. <view class="kong-kim" :style="{backgroundImage: `url(${item.icon})` }" :key="`fx_KongKim_${index}`"
  56. @click.stop=" $openPage(item)">
  57. {{item.name}}
  58. </view>
  59. </block>
  60. </view>
  61. <view class="card-box">
  62. <!-- <zw-waterfall :list="tabs[0].list || []"></zw-waterfall> -->
  63. <template v-if="tabs && tabs.length > 0">
  64. <block v-for="(t , i ) in tabs">
  65. <u-waterfall v-show="tabIndex === i" v-model="tabs[i].list">
  66. <template v-slot:left="{leftList}">
  67. <view class="card-left-item" v-for="(item, index) in leftList" :key="`left_${index}`">
  68. <discovery :data-val="item" />
  69. </view>
  70. </template>
  71. <template v-slot:right="{rightList}">
  72. <view class="card-right-item" v-for="(item, index) in rightList" :key="`right_${index}`">
  73. <discovery :data-val="item" />
  74. </view>
  75. </template>
  76. </u-waterfall>
  77. </block>
  78. </template>
  79. </view>
  80. <loadMore v-if="tabs[tabIndex].list.length > 0 || tabs[tabIndex].loadingStatus === 'loading' "
  81. :status="tabs[tabIndex].loadingStatus">
  82. </loadMore>
  83. <view class="empty-data"
  84. v-if="(!tabs[tabIndex].list || tabs[tabIndex].list.length===0) && tabs[tabIndex].loadingStatus=== 'noMore' ">
  85. <EmptyDate />
  86. </view>
  87. </view>
  88. </template>
  89. <script>
  90. import {
  91. getAPPList,
  92. getDiscover,
  93. newsClassify,
  94. getInformationFindPage,
  95. getThemeModule
  96. } from "@/api/government.js";
  97. import {
  98. getYiChangNews,
  99. openYiChangNews
  100. } from "../government/conmon.js"
  101. let app = getApp();
  102. export default {
  103. data() {
  104. return {
  105. tabsHeight: 100,
  106. config: {
  107. back: false,
  108. title: '发现',
  109. color: '#fff',
  110. // backgroundColor: [1, '#fff'],
  111. backgroundColor: 'transparent',
  112. statusBarFontColor: '#fff'
  113. },
  114. tabs: [{
  115. list: []
  116. }],
  117. KongKim: [],
  118. allLoading: false,
  119. tabIndex: 0,
  120. dataList: [],
  121. pageSize: 10,
  122. waterfallKey: 1,
  123. banner:{},
  124. liveList:[],
  125. navHeight:0
  126. }
  127. },
  128. onLoad() {
  129. const {
  130. statusBarHeight,
  131. navHeight
  132. } = app.globalData;
  133. // #ifdef APP
  134. this.navHeight = 2*(statusBarHeight + navHeight-10);
  135. // #endif
  136. // let data = uni.getStorageSync('discoveryPage');
  137. // if (data) {
  138. // this.tabs[0].list = data.rows
  139. // }
  140. this.init();
  141. this.getTheme();
  142. },
  143. onShow() {
  144. },
  145. onReachBottom() {
  146. if (this.tabs[this.tabIndex].loadingStatus === "more") {
  147. this.getPage(this.tabIndex);
  148. }
  149. },
  150. onPullDownRefresh() {
  151. this.init();
  152. },
  153. methods: {
  154. setKeys() {
  155. return new Date().getTime() + Math.random();
  156. },
  157. init(tag) {
  158. this.pageNum = 0;
  159. this.tabs = [{
  160. name: '推荐',
  161. list: this.tabs[0].list,
  162. pageNum: 0,
  163. key: this.setKeys(),
  164. loadingStatus: '', //more|loading|noMore
  165. }];
  166. this.tabIndex = 0;
  167. this.getKongKim();
  168. this.getLabel(tag);
  169. this.getLiveList();
  170. },
  171. getLiveList(){
  172. this.$yghttp.get('/live/liveInfo/list').then(res => {
  173. this.liveList = res.data;
  174. })
  175. },
  176. goLive(item){
  177. uni.navigateTo({
  178. url:"/pages/government/live?liveId="+item.liveId
  179. })
  180. },
  181. getKongKim() {
  182. getAPPList(this.$keys.FX_KONGKIM).then(res => {
  183. this.KongKim = res.data || []
  184. }).catch(() => {})
  185. },
  186. getLabel(tag) {
  187. newsClassify({
  188. informationChannel: this.$keys.information_discover
  189. }).then(res => {
  190. const data = res.data || [];
  191. const tabs = data.map((el, index) => {
  192. el.name = el.informationTypeName;
  193. el.list = index == 0 ? this.tabs[0].list : [];
  194. el.pageNum = 0;
  195. el.loadingStatus = '';
  196. el.key = this.setKeys()
  197. return el;
  198. });
  199. this.tabs = this.tabs.concat(tabs);
  200. let obj = {
  201. name: '宜昌发布',
  202. list: [],
  203. pageNum: 0,
  204. loadingStatus: ""
  205. }
  206. this.tabs.splice(1, 0, obj);
  207. this.tabs.forEach((el, index) => {
  208. this.getPage(index)
  209. })
  210. })
  211. },
  212. getTheme() {
  213. getThemeModule('discovery_Page').then(res => {
  214. this.banner = res.data.themeModuleVoList&&res.data.themeModuleVoList.length>0?res.data.themeModuleVoList[0]:{};
  215. });
  216. },
  217. getPage(tabIndex) {
  218. if (this.tabs[tabIndex].pageNum <= 0) {
  219. this.tabs[tabIndex].pageNum = 0;
  220. // this.tabs[tabIndex].list = [];
  221. this.tabs[tabIndex].loadingStatus = '';
  222. }
  223. if (this.tabs[tabIndex].loadingStatus === 'noMore' || this.tabs[tabIndex].loadingStatus === 'loading') {
  224. return
  225. };
  226. this.allLoading = true;
  227. this.$nextTick(() => {
  228. this.tabs[tabIndex].loadingStatus = 'loading';
  229. this.tabs[tabIndex].pageNum++;
  230. const parms = {
  231. pageNum: this.tabs[tabIndex].pageNum,
  232. pageSize: this.pageSize
  233. }
  234. if (this.tabs[tabIndex].hasOwnProperty('informationTypeId')) {
  235. parms.informationTypeId = this.tabs[tabIndex].informationTypeId
  236. }
  237. setTimeout(() => {
  238. // let apiFun=tabIndex==1?getYiChangNews:getInformationFindPage
  239. if (tabIndex != 1) {
  240. getInformationFindPage(parms).then(res => {
  241. try {
  242. if (res.code === 200) {
  243. if (this.tabs[tabIndex].pageNum <= 0) {
  244. this.tabs[tabIndex].list = [];
  245. }
  246. const arr = this.tabs[tabIndex].list.concat(res.rows ||
  247. []);
  248. this.$set(this.tabs[tabIndex], 'list', arr)
  249. };
  250. } catch (e) {}
  251. this.$forceUpdate()
  252. this.tabs[tabIndex].loadingStatus = this.$mUtil.pagination(res
  253. .total,
  254. this.tabs[tabIndex].pageNum, this.pageSize)
  255. }).catch(err => {
  256. this.tabs[tabIndex].pageNum--;
  257. this.tabs[tabIndex].loadingStatus = 'noMore';
  258. }).finally(() => {
  259. // this.status = 'noMore'
  260. this.allLoading = false;
  261. uni.stopPullDownRefresh();
  262. })
  263. } else {
  264. getYiChangNews(this.pageSize, this.tabs[1].pageNum, true).then(res => {
  265. try {
  266. if (this.tabs[tabIndex].pageNum <= 0) {
  267. this.tabs[tabIndex].list = [];
  268. }
  269. const arr = this.tabs[tabIndex].list.concat(res.data || []);
  270. this.$set(this.tabs[tabIndex], 'list', arr)
  271. } catch (e) {}
  272. this.$forceUpdate()
  273. this.tabs[tabIndex].loadingStatus = this.$mUtil.pagination(res
  274. .total,
  275. this.tabs[tabIndex].pageNum, this.pageSize)
  276. }).catch(err => {
  277. this.tabs[tabIndex].pageNum--;
  278. this.tabs[tabIndex].loadingStatus = 'noMore';
  279. }).finally(() => {
  280. // this.status = 'noMore'
  281. this.allLoading = false;
  282. uni.stopPullDownRefresh();
  283. })
  284. }
  285. }, 500)
  286. })
  287. },
  288. onChange(e) {
  289. this.tabIndex = e;
  290. if (this.tabs[e].pageNum >= 1) return;
  291. this.getPage(this.tabIndex);
  292. }
  293. }
  294. }
  295. </script>
  296. <style>
  297. page {
  298. /* background-color: #F9F9F9; */
  299. background: #fff;
  300. padding-bottom: 30rpx;
  301. }
  302. </style>
  303. <style lang="scss" scoped>
  304. /deep/.hx-navbar__fixed {
  305. background: linear-gradient(180deg, #68d1be, #41b8cd);
  306. }
  307. .itemBox {
  308. padding: 40rpx 30rpx 0rpx;
  309. .itemBox_title {
  310. display: flex;
  311. font-size: 34rpx;
  312. font-weight: 600;
  313. color: #1A1A1A;
  314. >image {
  315. width: 16rpx;
  316. height: 50rpx;
  317. margin-right: 10rpx;
  318. }
  319. }
  320. .itemBox_banner {
  321. width: 690rpx;
  322. height: 200rpx;
  323. margin-top: 20rpx;
  324. border-radius: 16rpx;
  325. }
  326. .itemBox_videos {
  327. display: flex;
  328. flex-wrap: wrap;
  329. margin-top: 20rpx;
  330. border-radius: 16rpx;
  331. overflow: hidden;
  332. >view {
  333. position: relative;
  334. margin-right: 20rpx;
  335. margin-bottom: 10rpx;
  336. &:nth-child(3n) {
  337. margin-right: 0 !important;
  338. }
  339. .itemBox_videos_img {
  340. width: 217rpx;
  341. height: 316rpx;
  342. border-radius: 16rpx;
  343. }
  344. .itemBox_videos_switch {
  345. width: 98rpx;
  346. height: 98rpx;
  347. position: absolute;
  348. top: 50%;
  349. left: 50%;
  350. margin-left: -22.5%;
  351. margin-top: -22.5%;
  352. }
  353. .itemBox_videos_title {
  354. width: 100%;
  355. font-size: 28rpx;
  356. color: #FFFFFF;
  357. text-align: center;
  358. position: absolute;
  359. bottom: 30rpx;
  360. left: 0;
  361. }
  362. .itemBox_videos_type {
  363. width: 82rpx;
  364. height: 41rpx;
  365. opacity: 0.9;
  366. background: #20c24a;
  367. border-radius: 0rpx 16rpx 0rpx 16rpx;
  368. font-size: 22rpx;
  369. color: #FFFFFF;
  370. text-align: center;
  371. line-height: 41rpx;
  372. position: absolute;
  373. top: 0;
  374. right: 0;
  375. }
  376. .itemBox_videos_title1 {
  377. width: 217rpx;
  378. font-size: 28rpx;
  379. color: #141414;
  380. font-weight: 500;
  381. overflow: hidden;
  382. white-space: nowrap;
  383. text-overflow: ellipsis;
  384. }
  385. .itemBox_videos_tig {
  386. width: 217rpx;
  387. font-size: 26rpx;
  388. color: #808080;
  389. overflow: hidden;
  390. white-space: nowrap;
  391. text-overflow: ellipsis;
  392. }
  393. }
  394. }
  395. }
  396. .tabs-box {
  397. width: 100%;
  398. // position: fixed;
  399. // left: 0;
  400. // right: 0;
  401. // z-index: 1;
  402. display: flex;
  403. flex-direction: row;
  404. // padding: 0 30rpx;
  405. background-color: #fff;
  406. border-bottom: 1px solid #e6e6e6;
  407. font-size: 0;
  408. align-items: center;
  409. padding: 0 30rpx;
  410. .tabs-box_title{
  411. display: flex;
  412. align-items: center;
  413. padding-right: 20rpx;
  414. >image {
  415. width: 16rpx;
  416. height: 50rpx;
  417. margin-right: 10px;
  418. }
  419. >text {
  420. font-size: 17px;
  421. font-weight: 600;
  422. color: #52C3C6;
  423. }
  424. }
  425. .utabs {
  426. width: calc(100% - 170rpx);
  427. }
  428. .tab-item {
  429. // width: 104rpx;
  430. padding: 0 22rpx;
  431. height: 100%;
  432. display: flex;
  433. align-items: center;
  434. font-size: 36rpx;
  435. margin-left: 40rpx;
  436. font-size: 30rpx;
  437. font-family: Microsoft YaHei, Microsoft YaHei-Regular;
  438. font-weight: 400;
  439. color: #999999;
  440. &:first-child {
  441. margin-left: 0;
  442. position: relative;
  443. color: #3CBACF;
  444. font-family: Microsoft YaHei, Microsoft YaHei-Bold;
  445. font-weight: 700;
  446. &::before {
  447. content: '';
  448. position: absolute;
  449. left: 50%;
  450. transform: translateX(-50%);
  451. bottom: 0;
  452. right: 0;
  453. width: 50%;
  454. height: 6rpx;
  455. border-radius: 3rpx;
  456. background-color: #3CBACF;
  457. }
  458. }
  459. }
  460. }
  461. .card-box {
  462. padding: 0 20rpx;
  463. background: linear-gradient(180deg,#ffffff, #f5f5f5);
  464. margin-top: 10rpx;
  465. /deep/ .u-column {
  466. width: 50%;
  467. }
  468. // display: flex;
  469. // flex-direction: row;
  470. // justify-content: space-between;
  471. // align-items: stretch;
  472. // flex-wrap: wrap;
  473. .card-left-item {
  474. padding-right: 10rpx;
  475. }
  476. .card-right-item {
  477. padding-left: 10rpx;
  478. }
  479. }
  480. .fx-kong-kim {
  481. width: 100%;
  482. display: flex;
  483. align-items: stretch;
  484. flex-wrap: wrap;
  485. padding: 20rpx;
  486. .kong-kim {
  487. flex-shrink: 0;
  488. width: calc((100% - 40rpx) / 3);
  489. height: 106rpx;
  490. background-repeat: no-repeat;
  491. background-size: 100% 100%;
  492. margin: 0 20rpx 10rpx 0;
  493. display: flex;
  494. justify-content: center;
  495. align-items: center;
  496. &:nth-child(3n) {
  497. margin-right: 0;
  498. }
  499. }
  500. }
  501. /deep/ .u-tab-bar {
  502. bottom: -6rpx;
  503. }
  504. /deep/ .u-tab-item{
  505. margin-top: 10rpx;
  506. }
  507. </style>