messages.vue 5.0 KB

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