index.vue 2.7KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  1. <template>
  2. <view class="page YeZhuZiXun">
  3. <ScrollY :IsRefreshing="IsRefreshing" @Refresh="Refresh" @ScrollBottom="ScrollBottom">
  4. <view class="Container">
  5. <!-- 标题 -->
  6. <view class="Title">
  7. <image mode="heightFix" src="https://cjgw.oss-cn-hangzhou.aliyuncs.com/ygcxxfb/image/yezhuzixun.png"></image>
  8. </view>
  9. <!-- 列表 -->
  10. <view class="List" v-if="YeZhuZiXunList.length">
  11. <navigator url="./NewsDetail/index" hover-class="other-navigator-hover" v-for="(item, index) in YeZhuZiXunList" :key="index" class="Item flex-h">
  12. <view class="flex-item">
  13. <text>资讯标题</text>
  14. <text>4567</text>
  15. </view>
  16. <text class="iconfont iconjiantouright"></text>
  17. </navigator>
  18. </view>
  19. </view>
  20. </ScrollY>
  21. </view>
  22. </template>
  23. <script>
  24. import ScrollY from '../../../components/ScrollY/index'
  25. import { createNamespacedHelpers } from 'vuex'
  26. const { mapState: mapIndexState, mapActions: mapIndexActions, mapMutations: mapIndexMutations } = createNamespacedHelpers('index')
  27. export default {
  28. name: 'YeZhuZiXun',
  29. data () {
  30. return {
  31. PageData: {
  32. pageNum: 1,
  33. pageSize: 15
  34. },
  35. HasNextPage: true,
  36. IsRefreshing: false,
  37. DataLock: false
  38. }
  39. },
  40. computed: {
  41. ...mapIndexState({
  42. YeZhuZiXunList: x => x.YeZhuZiXunList // 业主资讯列表
  43. })
  44. },
  45. components: {
  46. ScrollY
  47. },
  48. created () {
  49. this.Init() // 初始化
  50. },
  51. methods: {
  52. ...mapIndexActions([
  53. 'GetYeZhuZiXunList' // 获取资讯列表
  54. ]),
  55. ...mapIndexMutations([
  56. 'EmptyYeZhuZiXunList' // 清空资讯列表
  57. ]),
  58. Init () { // 初始化
  59. this.PageData.pageNum = 1
  60. this.HasNextPage = true
  61. this.EmptyYeZhuZiXunList() // 清空资讯列表
  62. this.ToGetPageList() // 获取列表
  63. },
  64. ToGetPageList () { // 获取列表
  65. this.GetYeZhuZiXunList({ queryData: { accountId: 5, ...this.PageData } }).then((res) => { // 获取资讯列表
  66. this.HasNextPage = res.data.data.hasNextPage
  67. this.DataLock = false
  68. this.IsRefreshing = false
  69. }).catch(() => {
  70. this.DataLock = false
  71. this.IsRefreshing = false
  72. })
  73. },
  74. ScrollBottom () { // 上拉加载
  75. if (this.DataLock || !this.HasNextPage) return
  76. this.DataLock = true
  77. this.PageData.pageNum += 1
  78. this.ToGetPageList() // 获取列表
  79. },
  80. Refresh (e) { // 页面下拉刷新
  81. if (this.DataLock) return
  82. this.DataLock = true
  83. this.IsRefreshing = true
  84. setTimeout(() => {
  85. this.Init() // 初始化
  86. }, 1000)
  87. }
  88. }
  89. }
  90. </script>
  91. <style lang="scss">
  92. @import "page.scss";
  93. </style>