index.vue 4.0KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126
  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="`./StarOwnerDetail/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. <image mode="aspectFill" class="centerLabel" :src="item.thumb"></image>
  20. </view>
  21. </view>
  22. </navigator>
  23. </view>
  24. </view>
  25. </ScrollY>
  26. </view>
  27. </template>
  28. <script>
  29. import ScrollY from '../../../components/ScrollY/index'
  30. import { createNamespacedHelpers } from 'vuex'
  31. const { mapState: mapIndexState, mapActions: mapIndexActions, mapMutations: mapIndexMutations } = createNamespacedHelpers('index')
  32. const { mapActions: mapUserActions, mapMutations: mapUserMutations } = createNamespacedHelpers('user')
  33. export default {
  34. name: 'ZhengNengLiangShiJi',
  35. data () {
  36. return {
  37. PageList: [],
  38. PageData: {
  39. pageNum: 1,
  40. pageSize: 15
  41. },
  42. HasNextPage: true,
  43. IsRefreshing: false,
  44. DataLock: false
  45. }
  46. },
  47. computed: {
  48. ...mapIndexState({
  49. ZhengNengLiangShiJiList: x => x.ZhengNengLiangShiJiList // 正能量事迹列表
  50. })
  51. },
  52. components: {
  53. ScrollY
  54. },
  55. created () {
  56. let _that = this
  57. wx.login({
  58. success (res) {
  59. _that.MainSignIn({ queryData: { code: res.code } }).then((res) => { // 获取用户信息
  60. _that.EditUserInfo({ name: 'PersonId', value: res.data.data.person.personId })
  61. _that.EditUserInfo({ name: 'OpenId', value: res.data.data.person.openId })
  62. _that.EditUserInfo({ name: 'SessionKey', value: res.data.data.extraInfo.sessionKey })
  63. if (res.data.data.person.phone !== undefined && res.data.data.person.phone !== null) {
  64. _that.EditUserInfo({ name: 'Phone', value: res.data.data.person.phone })
  65. }
  66. _that.Init()
  67. })
  68. }
  69. })
  70. },
  71. methods: {
  72. ...mapUserActions([
  73. 'MainSignIn' // 获取用户信息
  74. ]),
  75. ...mapUserMutations([
  76. 'EditUserInfo' // 编辑用户信息
  77. ]),
  78. ...mapIndexActions([
  79. 'GetZhengNengLiangShiJiList' // 获取正能量事迹列表
  80. ]),
  81. ...mapIndexMutations([
  82. 'EmptyZhengNengLiangShiJiList' // 清空正能量事迹列表
  83. ]),
  84. Init () { // 初始化
  85. this.PageData.pageNum = 1
  86. this.HasNextPage = true
  87. this.EmptyZhengNengLiangShiJiList() // 清空正能量事迹列表
  88. this.PageList = []
  89. this.ToGetPageList() // 获取列表
  90. },
  91. ToGetPageList () { // 获取列表
  92. this.GetZhengNengLiangShiJiList({ queryData: { ...this.PageData, typeId: 6 } }).then((res) => { // 获取正能量事迹列表
  93. this.PageList = [...this.ZhengNengLiangShiJiList]
  94. this.HasNextPage = res.data.data.current < res.data.data.pages
  95. this.DataLock = false
  96. this.IsRefreshing = false
  97. }).catch(() => {
  98. this.DataLock = false
  99. this.IsRefreshing = false
  100. })
  101. },
  102. ScrollBottom () { // 上拉加载
  103. if (this.DataLock || !this.HasNextPage) return
  104. this.DataLock = true
  105. this.PageData.pageNum += 1
  106. this.ToGetPageList() // 获取列表
  107. },
  108. Refresh (e) { // 页面下拉刷新
  109. if (this.DataLock) return
  110. this.DataLock = true
  111. this.IsRefreshing = true
  112. setTimeout(() => {
  113. this.Init() // 获取列表
  114. }, 1000)
  115. }
  116. }
  117. }
  118. </script>
  119. <style lang="scss">
  120. @import "page.scss";
  121. </style>