NoticeList.vue 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188
  1. <template><page-meta :root-font-size="fontSize+'px'"></page-meta>
  2. <member-base :show="false"><view style="position: absolute;top:0;right:0;left:0;bottom:0" class="scroll-view-wrapper div container">
  3. <view class="div common-header-wrap">
  4. <view class="status-holder"></view>
  5. <view :style="'height:'+navHeight+'px'"></view>
  6. <view class="common-header-holder"></view>
  7. <view class="common-header-fixed">
  8. <title-header />
  9. <uni-nav-bar title="通知消息" class="common-header" left-icon="back" @clickLeft="goBack()">
  10. </uni-nav-bar>
  11. </view>
  12. </view>
  13. <view class="scroll-view div" style="position:relative">
  14. <scroll-view style="position: absolute;top:0;right:0;left:0;bottom:0" class="div" @scrolltolower="loadMore" scroll-y="true">
  15. <view
  16. class="div body"
  17. v-if="notice_list && notice_list.length"
  18. >
  19. <view
  20. class="div notice-message-body"
  21. v-for="(item, index) in notice_list"
  22. :key="item.message_id"
  23. >
  24. <view class="p">{{$moment.unix(item.message_time).format('YYYY-MM-DD HH:mm')}}</view>
  25. <view class="div notice-track">
  26. <view class="div notice-status">
  27. <view class="p title">{{ message_type_text[item.message_type] }}</view>
  28. <view class="p content">{{ item.message_body }}</view>
  29. </view>
  30. </view>
  31. </view>
  32. </view>
  33. <empty-record v-else-if="notice_list && !notice_list.length"></empty-record>
  34. </scroll-view>
  35. </view>
  36. </view></member-base>
  37. </template>
  38. <script>
  39. import {getFontSize} from '@/util/common'
  40. import TitleHeader from '../../TitleHeader'
  41. import MemberBase from '../MemberBase'
  42. import { getNoticeList } from '../../../api/memberNotice'
  43. import EmptyRecord from '../../EmptyRecord'
  44. export default {
  45. name: 'NoticeList',
  46. components:{
  47. TitleHeader,
  48. MemberBase,
  49. EmptyRecord
  50. },
  51. computed:{
  52. fontSize(){
  53. return getFontSize()
  54. },
  55. },
  56. data(){
  57. return {
  58. navHeight: 0,
  59. params: { 'page': 0, 'per_page': 10 },
  60. loading: false, // 是否加载更多
  61. isMore: true, // 是否有更多
  62. message_type_text: ['私信', '系统消息', '留言'],
  63. wrapperHeight: 0,
  64. notice_list: false,
  65. }
  66. },
  67. created () {
  68. this.loadMore()
  69. },
  70. mounted(){
  71. // #ifdef MP-WEIXIN
  72. this.navHeight = uni.getMenuButtonBoundingClientRect().top
  73. // #endif
  74. this.wrapperHeight = uni.getSystemInfoSync().windowHeight - 130
  75. },
  76. methods: {
  77. goBack () {
  78. uni.navigateBack({delta:1})
  79. },
  80. loadMore () {
  81. this.loading = true
  82. this.params.page = ++this.params.page
  83. if (this.isMore) {
  84. this.loading = false
  85. this.getNoticeList(true)
  86. }
  87. },
  88. getNoticeList () {
  89. uni.showLoading({ title: '加载中' })
  90. getNoticeList(this.params).then(res => {
  91. uni.hideLoading()
  92. if (res.result.hasmore) {
  93. this.isMore = true
  94. } else {
  95. this.isMore = false
  96. }
  97. let temp = res.result.notice_list
  98. if (temp) {
  99. if (!this.notice_list) {
  100. this.notice_list = temp
  101. } else {
  102. this.notice_list = this.notice_list.concat(temp)
  103. }
  104. }
  105. }).catch(function (error) {
  106. uni.hideLoading()
  107. uni.showToast({icon:'none',title: error.message})
  108. })
  109. }
  110. }
  111. }
  112. </script>
  113. <style scoped lang="scss">
  114. .scroll-view-wrapper{display: flex;flex-direction: column;}
  115. .scroll-view{flex:1}
  116. .container {
  117. display: flex;
  118. flex-direction: column;
  119. justify-content: flex-start;
  120. align-items: stretch;
  121. .header {
  122. border-bottom: 1px solid #e8eaed;
  123. position: fixed;
  124. width: 100%;
  125. z-index: 1;
  126. }
  127. .body {
  128. width: 100%;
  129. .notice-message-body {
  130. width: 100%;
  131. height: 100%;
  132. > .p {
  133. text-align: center;
  134. margin-top:1rem;
  135. margin-bottom:0.5rem;
  136. font-size:$fontSize;
  137. color: #7c7f88;
  138. }
  139. .notice-track {
  140. display: flex;
  141. justify-content: space-between;
  142. align-items: center;
  143. height: 100%;
  144. background: rgba(255, 255, 255, 1);
  145. border-radius:0.1rem;
  146. margin: 0 0.5rem;
  147. .notice-status {
  148. display: flex;
  149. justify-content: space-between;
  150. align-items: center;
  151. flex-wrap: wrap;
  152. margin: 0.6rem 0.75rem 0.7rem 0.75rem;
  153. .title {
  154. font-size:$subFontSize;
  155. color: #333;
  156. margin: 0 0 0.7rem 0;
  157. }
  158. .content {
  159. font-size:$fontSize;
  160. color: #666;
  161. width: 100%;
  162. height: 100%;
  163. }
  164. }
  165. .arrow-right {
  166. width:0.25rem;
  167. height: 0.5rem;
  168. margin-right: 0.6rem;
  169. margin-left: 0.65rem;
  170. }
  171. }
  172. }
  173. }
  174. }
  175. </style>