Home.vue 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119
  1. <template>
  2. <div>
  3. <common @asynCallBack="asynCallBack"></common>
  4. <top-header :pageTitle="pageTitle"></top-header>
  5. <div class="mui-content">
  6. <div class="mui-content-padded">
  7. <ul class="mui-table-view openfyy-list">
  8. <li class="mui-table-view-cell mui-media" v-for="(item,index) in recordList">
  9. <router-link :to="{name:'CommonNoticeInfo',query:{id:item.messageId}}" class="mui-navigate-right">
  10. <div class="mui-media-body dian-list">
  11. <div class="mui-ellipsis">{{item.title}}</div>
  12. <p class="mui-ellipsis" v-text="item.createTime"></p>
  13. </div>
  14. </router-link>
  15. </li>
  16. </ul>
  17. </div>
  18. </div>
  19. <loading :visible="isLoading"></loading>
  20. </div>
  21. </template>
  22. <script>
  23. import * as API_Notice from '@/apis/Common/notice'
  24. import Common from '$project/components/Common.vue'
  25. import Loading from '$project/components/Loading.vue'
  26. import isReachBottom from '$project/utils/isReachBottom'
  27. import TopHeader from '$project/components/TopHeader.vue'
  28. import {
  29. mapGetters,
  30. mapMutations
  31. } from 'vuex'
  32. export default {
  33. name: 'CommonNotice',
  34. components: {
  35. Common,
  36. Loading,
  37. TopHeader
  38. },
  39. data() {
  40. return {
  41. pageTitle: '消息列表',
  42. isLoading: false,
  43. listForm: {
  44. pageIndex: 1,
  45. pageSize: 20,
  46. totalPage: 1,
  47. type: this.$route.query.type
  48. },
  49. recordList: [],
  50. }
  51. },
  52. created() {},
  53. methods: {
  54. //获取列表
  55. getList() {
  56. this.isLoading = true;
  57. API_Notice.getMessageList(this.listForm).then(response => {
  58. if (response) {
  59. if (this.listForm.pageIndex == 1) {
  60. this.recordList = response.data;
  61. this.listForm.pageIndex = response.pageNumber;
  62. this.listForm.totalPage = response.totalPage;
  63. } else {
  64. this.recordList = [
  65. ...this.recordList,
  66. ...response.data
  67. ];
  68. }
  69. }
  70. this.listForm.pageIndex++;
  71. this.isLoading = false;
  72. }).catch(error => {
  73. this.isLoading = false;
  74. mui.toast(error);
  75. })
  76. },
  77. //下拉事件
  78. handleScrool() {
  79. if (isReachBottom()) {
  80. console.log('到达底部')
  81. if (this.listForm.pageIndex <= this.listForm.totalPage && this.isLoading == false) {
  82. this.getList();
  83. } else {
  84. return;
  85. }
  86. }
  87. },
  88. asynCallBack() {
  89. },
  90. },
  91. mounted() {
  92. this.getList();
  93. //监控下拉加载事件
  94. var _this = this;
  95. window.addEventListener('scroll', _this.handleScrool);
  96. },
  97. destroyed() {
  98. //销毁监听事件
  99. var _this = this;
  100. window.removeEventListener('scroll', _this.handleScrool);
  101. },
  102. computed: {
  103. ...mapGetters({
  104. openId: 'wx_openid',
  105. token: 'token',
  106. })
  107. }
  108. }
  109. </script>
  110. <style scoped src="$project/assets/css/xpwyfyy.css"></style>
  111. <style scoped>
  112. </style>