index.vue 3.4KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117
  1. <template>
  2. <view class="page ZhengNengLiangShiJi">
  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/zhengnengliangshiji.png"></image>
  8. </view>
  9. <!-- 列表 -->
  10. <view class="List" v-if="PageList.length">
  11. <navigator v-for="(item, index) in PageList" :key="index" :url="`../../HuiShengHuo/ActivityList/ActivityDetail/index?id=${item.activityId}`" hover-class="other-navigator-hover" class="Item flex-h">
  12. <view class="flex-item">
  13. <text>{{item.name}}</text>
  14. <text>副标题</text>
  15. <text>来源</text>
  16. </view>
  17. <view class="Img">
  18. <view>
  19. <view class="MainItemImg">
  20. <image mode="aspectFill" :src="item.thumb"></image>
  21. </view>
  22. </view>
  23. </view>
  24. </navigator>
  25. </view>
  26. </view>
  27. </ScrollY>
  28. </view>
  29. </template>
  30. <script>
  31. import ScrollY from '../../../components/ScrollY/index'
  32. import { createNamespacedHelpers } from 'vuex'
  33. const { mapState: mapIndexState, mapActions: mapIndexActions, mapMutations: mapIndexMutations } = createNamespacedHelpers('index')
  34. const { mapActions: mapUserActions, mapMutations: mapUserMutations } = createNamespacedHelpers('user')
  35. export default {
  36. name: 'ZhengNengLiangShiJi',
  37. data () {
  38. return {
  39. PageList: [],
  40. PageData: {
  41. pageNum: 1,
  42. pageSize: 15
  43. },
  44. HasNextPage: true,
  45. IsRefreshing: false,
  46. DataLock: false
  47. }
  48. },
  49. computed: {
  50. ...mapIndexState({
  51. ZhengNengLiangShiJiList: x => x.ZhengNengLiangShiJiList // 正能量事迹列表
  52. })
  53. },
  54. components: {
  55. ScrollY
  56. },
  57. created () {
  58. this.$authed(() => {
  59. this.Init()
  60. })
  61. },
  62. methods: {
  63. ...mapUserActions([
  64. 'MainSignIn' // 获取用户信息
  65. ]),
  66. ...mapUserMutations([
  67. 'EditUserInfo' // 编辑用户信息
  68. ]),
  69. ...mapIndexActions([
  70. 'GetZhengNengLiangShiJiList' // 获取正能量事迹列表
  71. ]),
  72. ...mapIndexMutations([
  73. 'EmptyZhengNengLiangShiJiList' // 清空正能量事迹列表
  74. ]),
  75. Init () { // 初始化
  76. this.PageData.pageNum = 1
  77. this.HasNextPage = true
  78. this.EmptyZhengNengLiangShiJiList() // 清空正能量事迹列表
  79. this.PageList = []
  80. this.ToGetPageList() // 获取列表
  81. },
  82. ToGetPageList () { // 获取列表
  83. this.GetZhengNengLiangShiJiList({ queryData: { ...this.PageData, typeId: 6 } }).then((res) => { // 获取正能量事迹列表
  84. this.PageList = [...this.ZhengNengLiangShiJiList]
  85. this.HasNextPage = res.data.data.current < res.data.data.pages
  86. this.DataLock = false
  87. this.IsRefreshing = false
  88. }).catch(() => {
  89. this.DataLock = false
  90. this.IsRefreshing = false
  91. })
  92. },
  93. ScrollBottom () { // 上拉加载
  94. if (this.DataLock || !this.HasNextPage) return
  95. this.DataLock = true
  96. this.PageData.pageNum += 1
  97. this.ToGetPageList() // 获取列表
  98. },
  99. Refresh (e) { // 页面下拉刷新
  100. if (this.DataLock) return
  101. this.DataLock = true
  102. this.IsRefreshing = true
  103. setTimeout(() => {
  104. this.Init() // 获取列表
  105. }, 1000)
  106. }
  107. }
  108. }
  109. </script>
  110. <style lang="scss">
  111. @import "page.scss";
  112. </style>