messages.vue 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177
  1. <template>
  2. <view class="messages-page">
  3. <view class="contBody" @touchend="touchend" :style="MessList.length <= 8 ? {height:'calc(100% - 30rpx)'} : {}">
  4. <view v-for="(item,index) in MessList" :key="index" class="messages-content" @click="toDetail(item)">
  5. <view class="imgView">
  6. <image :src="item.businessType == 1 ? (item.readStatus ? '/static/橙色已读.png' : '/static/橙色未读.png') : (item.readStatus ? '/static/绿色已读.png' : '/static/绿色未读.png')"></image>
  7. </view>
  8. <view class="contView">
  9. <view class="contView-title">
  10. {{item.title}}
  11. </view>
  12. <view class="contView-content">
  13. {{item.content}}
  14. </view>
  15. <view class="contView-time">
  16. {{item.effectTime}}
  17. </view>
  18. </view>
  19. </view>
  20. <view class="bottomPanDuan"></view>
  21. </view>
  22. <view class="bottomTishi">
  23. <view v-if="loading">
  24. 向上滑动加载更多!
  25. </view>
  26. <view v-else>
  27. 已经到底了~
  28. </view>
  29. </view>
  30. </view>
  31. </template>
  32. <script>
  33. import moment from 'moment';
  34. export default {
  35. data() {
  36. return {
  37. pageNum: 1,
  38. pageSize: 10,
  39. MessList: [],
  40. loading: false,
  41. currentPage: 0,
  42. totalPage: 0,
  43. }
  44. },
  45. mounted() {
  46. this.getMessList();
  47. },
  48. methods:{
  49. getMessList(){
  50. var currPage = this.currentPage + 1;
  51. this.$store.dispatch({
  52. type: "messages/commActions",
  53. payload: {
  54. key: "messagesList",
  55. data: {
  56. pageNum: currPage,
  57. pageSize: this.pageSize,
  58. }
  59. },
  60. }).then(res=>{
  61. this.totalPage = res.totalPage;
  62. res.list.map((item)=>{
  63. item.effectTime = moment(item.effectTime).format('MM-DD hh:mm')
  64. })
  65. //获取当前页码
  66. this.currentPage = res.pageNum;
  67. //当前页码与总页码进行比对
  68. this.loading = this.currentPage < this.totalPage;
  69. //将获得的数据拼接当前渲染数据中
  70. this.MessList = this.MessList.concat(res.list);
  71. })
  72. },
  73. touchend(){
  74. if(this.currentPage < this.totalPage){
  75. var box = document.getElementsByClassName('bottomPanDuan')[0];
  76. var pos = box.getBoundingClientRect();
  77. if(pos.bottom<=document.documentElement.clientHeight){
  78. this.getMessList();
  79. }
  80. }
  81. },
  82. toDetail(data){
  83. this.$store.dispatch({
  84. type: "messages/commActions",
  85. payload: {
  86. key: "toRead",
  87. data: {
  88. id:data.id
  89. }
  90. },
  91. }).then(res=>{
  92. uni.navigateTo({
  93. url: '/pages/mission-details/mission-details'
  94. });
  95. this.MessList = [];
  96. for(let i = 0 ; i < this.currentPage; i++){
  97. this.$store.dispatch({
  98. type: "messages/commActions",
  99. payload: {
  100. key: "messagesList",
  101. data: {
  102. pageNum: i,
  103. pageSize: this.pageSize,
  104. }
  105. },
  106. }).then(res=>{
  107. this.MessList = this.MessList.concat(res.list);
  108. })
  109. }
  110. })
  111. }
  112. },
  113. computed:{
  114. }
  115. }
  116. </script>
  117. <style lang="less">
  118. .messages-page{
  119. padding-top: 15rpx;
  120. height: 100%;
  121. overflow-y: auto;
  122. .messages-content{
  123. display: flex;
  124. background-color: #fff;
  125. .imgView{
  126. margin-top: 25rpx;
  127. margin-left: 25rpx;
  128. margin-right: 25rpx;
  129. margin-bottom: 63.75rpx;
  130. width: 56.25rpx;
  131. height: 56.25rpx;
  132. vertical-align: top;
  133. .image-circle{
  134. background-color: ;
  135. }
  136. image{
  137. width: 56.25rpx;
  138. height: 90px;
  139. }
  140. }
  141. .contView{
  142. flex: 1;
  143. border-bottom: 0.62rpx solid #DADEE6;
  144. .contView-title{
  145. margin-top:25rpx ;
  146. font-size: 22.5rpx;
  147. font-weight: 500;
  148. color: #292C33;
  149. }
  150. .contView-content{
  151. margin:15rpx 0 20rpx;
  152. font-size: 20rpx;
  153. color: #525866;
  154. }
  155. .contView-time{
  156. margin-bottom: 25rpx;
  157. font-size: 17.5rpx;
  158. color: #666E80;
  159. }
  160. }
  161. }
  162. .bottomTishi{
  163. padding: 6.25rpx 0px;
  164. width: 100%;
  165. // position: absolute;
  166. // bottom: 0rpx;
  167. text-align: center;
  168. font-size: 17.5rpx;
  169. color: #525866;
  170. }
  171. }
  172. </style>