messages.vue 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204
  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/orange-read.png'
  20. : '/static/orange-noRead.png'
  21. : item.readStatus
  22. ? '/static/green-read.png'
  23. : '/static/green-noRead.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.setStorageSync('situaionID', data.businessId);
  115. uni.navigateTo({
  116. url: `/pages/situationDetail/situationDetail`,
  117. });
  118. }
  119. this.MessList = [];
  120. for (let i = 1; i < this.currentPage + 1; i++) {
  121. this.$store.dispatch({
  122. type: "messages/commActions",
  123. payload: {
  124. key: "messagesList",
  125. data: {
  126. pageNum: i,
  127. pageSize: this.pageSize,
  128. },
  129. },
  130. })
  131. .then((res) => {
  132. res.list.map((item) => {
  133. item.effectTime = moment(item.effectTime).format(
  134. "MM-DD hh:mm"
  135. );
  136. });
  137. this.MessList = this.MessList.concat(res.list);
  138. });
  139. }
  140. });
  141. },
  142. },
  143. computed: {},
  144. };
  145. </script>
  146. <style lang="less">
  147. .messages-page {
  148. padding-top: 15rpx;
  149. height: 100%;
  150. overflow-y: auto;
  151. .messages-content {
  152. display: flex;
  153. background-color: #fff;
  154. .imgView {
  155. margin-top: 25rpx;
  156. margin-left: 25rpx;
  157. margin-right: 25rpx;
  158. margin-bottom: 63.75rpx;
  159. width: 56.25rpx;
  160. height: 56.25rpx;
  161. vertical-align: top;
  162. .image-circle {
  163. background-color: ;
  164. }
  165. image {
  166. width: 56.25rpx;
  167. height: 90px;
  168. }
  169. }
  170. .contView {
  171. flex: 1;
  172. border-bottom: 0.62rpx solid #dadee6;
  173. .contView-title {
  174. margin-top: 25rpx;
  175. font-size: 22.5rpx;
  176. font-weight: 500;
  177. color: #292c33;
  178. }
  179. .contView-content {
  180. margin: 15rpx 0 20rpx;
  181. font-size: 20rpx;
  182. color: #525866;
  183. }
  184. .contView-time {
  185. margin-bottom: 25rpx;
  186. font-size: 17.5rpx;
  187. color: #666e80;
  188. }
  189. }
  190. }
  191. .bottomTishi {
  192. padding: 6.25rpx 0px;
  193. width: 100%;
  194. // position: absolute;
  195. // bottom: 0rpx;
  196. text-align: center;
  197. font-size: 17.5rpx;
  198. color: #525866;
  199. }
  200. }
  201. </style>