index - 无loadrefresh版.vue 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610
  1. <template>
  2. <view class="notify">
  3. <view class="promotion-center">
  4. <view class="">
  5. <wuc-tab :tab-list="titleList" :tabCur.sync="TabCur" @change="tabChange"></wuc-tab>
  6. <!-- 轮播图1 -->
  7. <view class="swiper" style="top:90px;">
  8. <view class="swiper-box">
  9. <oa-swipe-dot :info="advList" mode="nav" :current="current" field="adv_title">
  10. <swiper @change="handleDotChange" autoplay="true">
  11. <swiper-item v-for="(item, index) in advList" :key="index" @click="navTo(item.path)">
  12. <view class="swiper-item">
  13. <image :src="item.cover" mode="aspectFill" />
  14. </view>
  15. </swiper-item>
  16. </swiper>
  17. </oa-swipe-dot>
  18. </view>
  19. </view>
  20. <view>
  21. <swiper class="contentSwiper" :current="TabCur" duration="300" :vertical="false" @change="swiperChange"
  22. @transition="swiperonmove">
  23. <swiper-item v-for="(title,i) in titleList" :key="i">
  24. <view class="notify-list">
  25. <view class="card-bg">
  26. <leo-list :list="newsList" :path="'/pages/message/content?id='"></leo-list>
  27. </view>
  28. </view>
  29. </swiper-item>
  30. </swiper>
  31. </view>
  32. </view>
  33. </view>
  34. </view>
  35. </template>
  36. <script>
  37. import moment from '@/common/moment';
  38. import listCell from '@/components/oa-list-cell';
  39. import {
  40. mapMutations
  41. } from 'vuex';
  42. import oaSwipeDot from '@/components/oa-swipe-dot';
  43. import WucTab from '@/components/wuc-tab/wuc-tab.vue';
  44. import loadRefresh from '@/components/load-refresh/load-refresh.vue'
  45. import leoList from '@/components/leo-list/leo-list.vue'
  46. export default {
  47. components: {
  48. listCell,
  49. oaSwipeDot,
  50. WucTab,
  51. loadRefresh,
  52. leoList
  53. },
  54. data() {
  55. return {
  56. page: 1,
  57. pageSize: 5,
  58. totalPages: 1,
  59. loadingType: "more",
  60. hasLogin: false,
  61. current: 0, // 轮播图index
  62. titleList: [],
  63. advList: [{
  64. "id": "1",
  65. "adv_title": "石家庄市动物园",
  66. "cover": "/static/banner1.jpg",
  67. "path": ''
  68. },
  69. {
  70. "id": "2",
  71. "adv_title": "石家庄市裕西公园",
  72. "cover": "/static/banner2.jpg",
  73. "path": ''
  74. },
  75. {
  76. "id": "3",
  77. "adv_title": "石家庄市长安公园",
  78. "cover": "/static/banner3.jpg",
  79. "path": ''
  80. },
  81. {
  82. "id": "4",
  83. "adv_title": "石家庄市植物园",
  84. "cover": "/static/banner4.jpg",
  85. "path": ''
  86. }
  87. ], // 广告图
  88. newsList: [],
  89. TabCur: 0 //顶部选项卡角标
  90. };
  91. },
  92. filters: {
  93. notifyTypeFilter(val) {
  94. return '公告';
  95. },
  96. time(val) {
  97. // 拿到当前时间戳和发布时的时间戳,然后得出时间戳差
  98. var curTime = new Date();
  99. var postTime = new Date(val);
  100. var timeDiff = curTime.getTime() - postTime.getTime();
  101. // 单位换算
  102. var min = 60 * 1000;
  103. var hour = min * 60;
  104. var day = hour * 24;
  105. var week = day * 7;
  106. // 计算发布时间距离当前时间的周、天、时、分
  107. var exceedWeek = Math.floor(timeDiff / week);
  108. var exceedDay = Math.floor(timeDiff / day);
  109. var exceedHour = Math.floor(timeDiff / hour);
  110. var exceedMin = Math.floor(timeDiff / min);
  111. // 最后判断时间差到底是属于哪个区间,然后return
  112. if (exceedWeek > 0) {
  113. if (curTime.getFullYear() == postTime.getFullYear()) {
  114. return moment(val).format('MM-DD');
  115. } else {
  116. return moment(val).format('YYYY-MM-DD');
  117. }
  118. } else {
  119. if (exceedDay < 7 && exceedDay > 0) {
  120. return exceedDay + '天前';
  121. } else {
  122. if (exceedHour < 24 && exceedHour > 0) {
  123. return exceedHour + '小时前';
  124. } else {
  125. if(exceedMin<1){
  126. exceedMin=0
  127. }
  128. return exceedMin + '分钟前';
  129. }
  130. }
  131. }
  132. }
  133. },
  134. onShow() {
  135. this.initData();
  136. },
  137. onReachBottom: function() {
  138. this.loadMore();
  139. },
  140. methods: {
  141. // 监听轮播图切换
  142. handleDotChange(e) {
  143. this.current = e.detail.current;
  144. },
  145. // 数据初始化
  146. initData() {
  147. this.hasLogin = this.$mStore.getters.hasLogin;
  148. uni.setNavigationBarColor({
  149. frontColor: '#ffffff',
  150. backgroundColor: this.themeColor.color,
  151. animation: {
  152. duration: 400,
  153. timingFunc: 'easeIn'
  154. }
  155. });
  156. this.initTablist()
  157. this.initSwiperImg()
  158. },
  159. initTablist() {
  160. if (!this.hasLogin) {
  161. uni.reLaunch({
  162. url: '../public/login'
  163. })
  164. return;
  165. }
  166. var url = this.$mConfig.baseUrl + '/system/docmenu/list';
  167. var token = this.$preToken + ' ' + this.$store.state.accessToken;
  168. this.$http.request({
  169. url: url,
  170. header: {
  171. 'content-type': 'application/json',
  172. 'Authorization': token
  173. }
  174. }).then(r => {
  175. var tablist = [];
  176. if (r.code == "200") {
  177. for (var i = 0; i < r.data.length; i++) {
  178. if (r.data[i].parentId == "100") {
  179. var title = {
  180. "name": r.data[i].deptName
  181. }
  182. tablist.push(title);
  183. }
  184. }
  185. this.titleList = tablist;
  186. this.initContentlist('load');
  187. }
  188. })
  189. .catch(() => {});
  190. },
  191. initSwiperImg() {
  192. var url = this.$mConfig.baseUrl + '/system/mes/rotatio123nImgs1123123';
  193. var token = this.$preToken + ' ' + this.$store.state.accessToken;
  194. this.$http.request({
  195. url: url,
  196. header: {
  197. 'content-type': 'application/json',
  198. 'Authorization': token
  199. }
  200. }).then(r => {
  201. var advList = [];
  202. if (r.code == "200") {
  203. for (var i = 0; i < r.data.length; i++) {
  204. var advItme = {
  205. "id": i,
  206. "adv_title": r.data[i].tatle,
  207. "cover": this.$mConfig.baseUrl + r.data[i].rotationPath,
  208. "path": '/pages/message/content?id=' + r.data[i].id
  209. }
  210. advList.push(advItme);
  211. }
  212. this.advList = advList;
  213. }
  214. })
  215. .catch(() => {});
  216. },
  217. initContentlist(type) {
  218. var that = this;
  219. var url = this.$mConfig.baseUrl + '/system/mes/listRecMe';
  220. var token = this.$preToken + ' ' + this.$store.state.accessToken;
  221. var documentType = this.titleList[this.TabCur].name;
  222. if (type == 'change') {
  223. this.page = 1;
  224. } else if (type == 'getmore') {
  225. if (this.page < this.totalPages)
  226. this.page = this.page + 1;
  227. else return false;
  228. } else if (type == 'refresh') {
  229. this.page = 1;
  230. } else {
  231. this.page = 1;
  232. }
  233. this.$http.request({
  234. url: url,
  235. header: {
  236. 'content-type': 'application/json',
  237. 'Authorization': token
  238. },
  239. data: {
  240. pageNum: this.page,
  241. pageSize: this.pageSize,
  242. orderByColumn: "createTime",
  243. isAsc: "desc",
  244. documentType: documentType
  245. }
  246. }).then(r => {
  247. that.totalPages = Math.ceil(parseInt(r.total) / parseInt(that.pageSize));
  248. if (type == 'change') {
  249. this.newsList = r.rows;
  250. } else if (type == 'getmore') {
  251. this.newsList = [...this.newsList, ...r.rows];
  252. } else if (type == 'refresh') {
  253. this.newsList = r.rows;
  254. } else {
  255. this.newsList = r.rows;
  256. }
  257. })
  258. .catch(() => {
  259. });
  260. },
  261. tabChange(index) {
  262. this.TabCur = index;
  263. this.initContentlist('change');
  264. },
  265. swiperonmove(e) {
  266. this.$refs.loadRefresh[this.TabCur].moveY = false
  267. },
  268. swiperChange(e) {
  269. let {
  270. current
  271. } = e.target;
  272. this.TabCur = current;
  273. this.initContentlist('change');
  274. },
  275. refresh() {
  276. this.initContentlist('refresh');
  277. this.$nextTick(function() {
  278. this.$refs.loadRefresh[this.TabCur].completed();
  279. })
  280. },
  281. loadMore() {
  282. this.initContentlist('getmore');
  283. // this.$nextTick(function() {
  284. // this.$refs.loadRefresh[this.TabCur].completed()
  285. // })
  286. },
  287. // 通用跳转
  288. navTo(route) {
  289. this.$mRouter.push({
  290. route
  291. });
  292. },
  293. noImg(val) {
  294. var str = val.replace('<img', '<img style="display:none;"');
  295. return str;
  296. }
  297. }
  298. };
  299. </script>
  300. <style lang="scss">
  301. page {
  302. background-color: $page-color-base;
  303. }
  304. .contentSwiper {
  305. height: calc(calc(22vw + 50upx) * 5);
  306. padding-bottom: calc(var(--window-bottom) - 40px);
  307. }
  308. /*轮播图*/
  309. .swiper {
  310. width: 100%;
  311. margin-top: 20upx;
  312. margin-bottom: 20upx;
  313. display: flex;
  314. justify-content: center;
  315. .swiper-box {
  316. width: 92%;
  317. height: 40vw;
  318. overflow: hidden;
  319. border-radius: 15upx;
  320. box-shadow: 0upx 8upx 25upx rgba(0, 0, 0, 0.2);
  321. //兼容ios,微信小程序
  322. position: relative;
  323. z-index: 1;
  324. swiper {
  325. width: 100%;
  326. height: 40vw;
  327. swiper-item {
  328. image {
  329. width: 100%;
  330. height: 40vw;
  331. }
  332. }
  333. }
  334. }
  335. }
  336. .notify {
  337. .promotion-center {
  338. background: #fff;
  339. margin-bottom: 20upx;
  340. /*分类列表*/
  341. .category-list {
  342. width: 100%;
  343. padding: 0 0 30upx 0;
  344. border-bottom: solid 2upx #f6f6f6;
  345. display: flex;
  346. flex-wrap: wrap;
  347. .category {
  348. width: 33.3%;
  349. margin-top: 50upx;
  350. display: flex;
  351. justify-content: center;
  352. flex-wrap: wrap;
  353. .img {
  354. width: 100%;
  355. display: flex;
  356. justify-content: center;
  357. .iconfont {
  358. font-size: $font-lg + 24upx;
  359. }
  360. }
  361. .text {
  362. width: 100%;
  363. display: flex;
  364. justify-content: center;
  365. font-size: 24upx;
  366. color: #3c3c3c;
  367. }
  368. .share-btn {
  369. height: 142upx;
  370. text-align: left;
  371. background: none;
  372. padding: 0;
  373. margin: 0;
  374. }
  375. .share-btn:after {
  376. border: none;
  377. border-radius: none;
  378. }
  379. }
  380. }
  381. }
  382. .header {
  383. width: 100%;
  384. padding-left: $font-lg;
  385. height: 100upx;
  386. display: flex;
  387. align-items: center;
  388. position: fixed;
  389. top: 0;
  390. z-index: 10;
  391. background-color: #fff;
  392. /* #ifdef APP-PLUS */
  393. top: var(--status-bar-height);
  394. /* #endif */
  395. .title {
  396. font-size: 36upx;
  397. }
  398. }
  399. .place {
  400. background-color: #ffffff;
  401. height: 100upx;
  402. /* #ifdef APP-PLUS */
  403. margin-top: var(--status-bar-height);
  404. /* #endif */
  405. }
  406. .notify-list {
  407. border-radius: 5px;
  408. background: $page-color-base;
  409. /* #ifdef APP-PLUS */
  410. padding-top: var(--status-bar-height);
  411. /* #endif */
  412. /* #ifndef APP-PLUS */
  413. padding-top: 1rpx;
  414. /* #endif */
  415. padding-bottom: 1rpx;
  416. .card-bg {
  417. margin: 0 24rpx;
  418. padding: 0 32rpx;
  419. background: #ffffff;
  420. border-radius: 20rpx;
  421. box-shadow: 0px 4rpx 20rpx 0rpx rgba(235, 241, 244, 0.35);
  422. }
  423. .read {
  424. text-align: right;
  425. margin-right: $spacing-base;
  426. margin-top: $spacing-base;
  427. margin-bottom: $spacing-sm;
  428. text {
  429. margin-left: $spacing-base;
  430. }
  431. }
  432. .row {
  433. border-radius: 10px;
  434. width: calc(94%);
  435. height: calc(22vw + 20upx);
  436. margin: 0 auto 1px;
  437. // border-radius: 15upx;
  438. box-shadow: 0upx 5upx 20upx rgba(0, 0, 0, 0.1);
  439. display: flex;
  440. align-items: center;
  441. position: relative;
  442. overflow: hidden;
  443. z-index: 4;
  444. border: 0;
  445. .menu {
  446. .iconfont {
  447. color: #fff;
  448. font-size: 60upx;
  449. }
  450. position: absolute;
  451. width: 29%;
  452. height: 100%;
  453. right: 0;
  454. display: flex;
  455. justify-content: center;
  456. align-items: center;
  457. color: #fff;
  458. z-index: 2;
  459. }
  460. .carrier {
  461. @keyframes showMenu {
  462. 0% {
  463. transform: translateX(0);
  464. }
  465. 100% {
  466. transform: translateX(-30%);
  467. }
  468. }
  469. @keyframes closeMenu {
  470. 0% {
  471. transform: translateX(-30%);
  472. }
  473. 100% {
  474. transform: translateX(0);
  475. }
  476. }
  477. &.open {
  478. animation: showMenu 0.25s linear both;
  479. }
  480. &.close {
  481. animation: closeMenu 0.15s linear both;
  482. }
  483. background-color: #fff;
  484. position: absolute;
  485. width: 100%;
  486. padding: 0 0;
  487. height: 100%;
  488. z-index: 3;
  489. display: flex;
  490. align-items: center;
  491. }
  492. }
  493. .notify-wrapper {
  494. background-color: $color-white;
  495. width: 100%;
  496. padding: $spacing-base $spacing-lg $spacing-base 40upx;
  497. margin: $spacing-base 0 0;
  498. border-radius: 15upx;
  499. position: relative;
  500. .title {
  501. font-size: $font-lg;
  502. color: $font-color-dark;
  503. font-weight: 500;
  504. margin: 0 0 $spacing-sm;
  505. }
  506. .content {
  507. font-size: $font-sm;
  508. color: $font-color-base;
  509. height: 75upx;
  510. line-height: 36upx;
  511. }
  512. .time {
  513. float: right;
  514. font-size: $font-base;
  515. color: $font-color-light;
  516. }
  517. .type {
  518. position: absolute;
  519. top: 26upx;
  520. left: -10upx;
  521. border: none;
  522. font-size: $font-sm;
  523. opacity: 0.8;
  524. }
  525. .un-read {
  526. display: inline-block;
  527. width: 12upx;
  528. height: 12upx;
  529. border-radius: 50%;
  530. position: absolute;
  531. top: 32upx;
  532. right: 30upx;
  533. }
  534. }
  535. }
  536. .notify-empty {
  537. position: fixed;
  538. left: 0;
  539. top: 50;
  540. width: 100%;
  541. height: 100vh;
  542. padding-bottom: 100upx;
  543. display: flex;
  544. justify-content: center;
  545. flex-direction: column;
  546. align-items: center;
  547. background: #fff;
  548. .iconfont {
  549. font-size: $font-lg + 100upx;
  550. }
  551. .empty-tips {
  552. display: flex;
  553. font-size: $font-sm + 2upx;
  554. color: $font-color-disabled;
  555. .navigator {
  556. margin-left: 16upx;
  557. }
  558. }
  559. }
  560. }
  561. </style>