index.vue 13 KB

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