123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121
  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="PageList.length">
  11. <navigator :url="`./NewsDetail/index?id=${item.newsId}`" hover-class="other-navigator-hover" v-for="(item, index) in PageList" :key="index" class="Item flex-h">
  12. <view class="flex-item">
  13. <text>{{item.title}}</text>
  14. <text></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. const { mapActions: mapUserActions, mapMutations: mapUserMutations } = createNamespacedHelpers('user')
  28. export default {
  29. name: 'YeZhuZiXun',
  30. data () {
  31. return {
  32. PageList: [],
  33. PageData: {
  34. pageNum: 1,
  35. pageSize: 15
  36. },
  37. HasNextPage: true,
  38. IsRefreshing: false,
  39. DataLock: false
  40. }
  41. },
  42. computed: {
  43. ...mapIndexState({
  44. YeZhuZiXunList: x => x.YeZhuZiXunList // 业主资讯列表
  45. })
  46. },
  47. components: {
  48. ScrollY
  49. },
  50. created () {
  51. let _that = this
  52. wx.login({
  53. success (res) {
  54. _that.MainSignIn({ queryData: { code: res.code } }).then((res) => { // 获取用户信息
  55. _that.EditUserInfo({ name: 'PersonId', value: res.data.data.person.personId })
  56. _that.EditUserInfo({ name: 'OpenId', value: res.data.data.person.openId })
  57. _that.EditUserInfo({ name: 'SessionKey', value: res.data.data.extraInfo.sessionKey })
  58. if (res.data.data.person.phone !== undefined && res.data.data.person.phone !== null) {
  59. _that.EditUserInfo({ name: 'Phone', value: res.data.data.person.phone })
  60. }
  61. _that.Init()
  62. })
  63. }
  64. })
  65. },
  66. methods: {
  67. ...mapUserActions([
  68. 'MainSignIn' // 获取用户信息
  69. ]),
  70. ...mapUserMutations([
  71. 'EditUserInfo' // 编辑用户信息
  72. ]),
  73. ...mapIndexActions([
  74. 'GetYeZhuZiXunList' // 获取资讯列表
  75. ]),
  76. ...mapIndexMutations([
  77. 'EmptyYeZhuZiXunList' // 清空资讯列表
  78. ]),
  79. Init () { // 初始化
  80. this.PageData.pageNum = 1
  81. this.HasNextPage = true
  82. this.PageList = []
  83. this.EmptyYeZhuZiXunList() // 清空资讯列表
  84. this.ToGetPageList() // 获取列表
  85. },
  86. ToGetPageList () { // 获取列表
  87. this.GetYeZhuZiXunList({ queryData: { accountId: 5, ...this.PageData } }).then((res) => { // 获取资讯列表
  88. this.PageList = [...this.YeZhuZiXunList]
  89. this.HasNextPage = res.data.data.current < res.data.data.pages
  90. this.DataLock = false
  91. this.IsRefreshing = false
  92. }).catch(() => {
  93. this.DataLock = false
  94. this.IsRefreshing = false
  95. })
  96. },
  97. ScrollBottom () { // 上拉加载
  98. if (this.DataLock || !this.HasNextPage) return
  99. this.DataLock = true
  100. this.PageData.pageNum += 1
  101. this.ToGetPageList() // 获取列表
  102. },
  103. Refresh (e) { // 页面下拉刷新
  104. if (this.DataLock) return
  105. this.DataLock = true
  106. this.IsRefreshing = true
  107. setTimeout(() => {
  108. this.Init() // 初始化
  109. }, 1000)
  110. }
  111. }
  112. }
  113. </script>
  114. <style lang="scss">
  115. @import "page.scss";
  116. </style>