notice.vue 2.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  1. <template>
  2. <view>
  3. <view class="edgeInsetTop"></view>
  4. <view class="wanl-logistics-list margin-top-bj" v-if="dataList.length != 0">
  5. <block v-for="(item, index) in dataList" :key="item.id">
  6. <view class="text-center wanl-gray">
  7. {{ $appKit.timeToChat(item.createtime) }}
  8. </view>
  9. <view class="item margin-lr-bj margin-tb bg-white radius-bock padding-bj" @tap="handleTap(item.url)">
  10. <view class="title margin-bottom-bj">
  11. <text class="text-df">{{ item.title }}</text>
  12. <text class="text-sm wanl-gray-light wlIcon-fanhui2"></text>
  13. </view>
  14. <view class="action">
  15. <image :src="$appKit.oss(item.image, 82, 82)"></image>
  16. <view class="padding-xs flex flex-wrap align-content-between">
  17. <view class="text-df margin-bottom-xs">{{ item.content }}</view>
  18. <text class="text-sm wanl-gray">{{ $t('notice.from') }} {{ item.come }}</text>
  19. </view>
  20. </view>
  21. </view>
  22. </block>
  23. </view>
  24. <wanl-empty src="notice_default3x" :text="$t('notice.noCouponLiveProduct')" v-else />
  25. <view class="edgeInsetBottom"></view>
  26. </view>
  27. </template>
  28. <script>
  29. import { pullNoticeList } from '@/features/mall/mall-gateway'
  30. export default {
  31. data() {
  32. return {
  33. dataList: [],
  34. reload: false,
  35. total: 0,
  36. current_page: 1,
  37. last_page: 1,
  38. status: 'more',
  39. contentText: {
  40. contentdown: ' ',
  41. contentrefresh: '',
  42. contentnomore: ''
  43. }
  44. }
  45. },
  46. onLoad() {
  47. this.contentText.contentrefresh = this.$t('notice.loading')
  48. this.loadData()
  49. // 清除本地角标
  50. this.$store.commit('statistics/noticec', { notice: 0 })
  51. },
  52. onPullDownRefresh() {
  53. this.current_page = 1
  54. this.reload = true
  55. this.loadData()
  56. },
  57. onReachBottom() {
  58. if (this.current_page >= this.last_page) {
  59. this.status = 'noMore'
  60. } else {
  61. this.reload = false
  62. this.current_page = this.current_page + 1
  63. this.status = 'loading'
  64. this.loadData()
  65. }
  66. },
  67. methods: {
  68. async loadData() {
  69. try {
  70. const res = await pullNoticeList({
  71. type: 'notice',
  72. page: this.current_page
  73. })
  74. uni.stopPullDownRefresh()
  75. this.dataList = this.reload ? res.data : this.dataList.concat(res.data)
  76. this.total = res.total
  77. this.current_page = res.current_page
  78. this.last_page = res.last_page
  79. this.status = res.total == 0 ? 'noMore' : 'more'
  80. } catch (e) {
  81. uni.stopPullDownRefresh()
  82. console.error('[notice] 加載通知列表失敗:', e)
  83. }
  84. },
  85. handleTap(url) {
  86. if (url) {
  87. uni.navigateTo({ url })
  88. }
  89. }
  90. }
  91. }
  92. </script>
  93. <style>
  94. </style>