messages.vue 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207
  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 || item.businessType == 3
  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.slice(5, 16) }}
  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
  67. .dispatch({
  68. type: "messages/commActions",
  69. payload: {
  70. key: "messagesList",
  71. data: {
  72. pageNum: currPage,
  73. pageSize: this.pageSize,
  74. },
  75. },
  76. })
  77. .then((res) => {
  78. this.totalPage = res.totalPage;
  79. //获取当前页码
  80. this.currentPage = res.pageNum;
  81. //当前页码与总页码进行比对
  82. this.loading = this.currentPage < this.totalPage;
  83. //将获得的数据拼接当前渲染数据中
  84. this.MessList = this.MessList.concat(res.list);
  85. });
  86. },
  87. touchend() {
  88. if (this.currentPage < this.totalPage) {
  89. var box = document.getElementsByClassName("bottomPanDuan")[0];
  90. var pos = box.getBoundingClientRect();
  91. if (pos.bottom <= document.documentElement.clientHeight) {
  92. this.getMessList();
  93. }
  94. }
  95. },
  96. toDetail(data) {
  97. this.$store
  98. .dispatch({
  99. type: "messages/commActions",
  100. payload: {
  101. key: "toRead",
  102. data: {
  103. id: data.id,
  104. },
  105. },
  106. })
  107. .then((res) => {
  108. if (data.businessType == 2) {
  109. //改善任务
  110. uni.navigateTo({
  111. url: `/pages/mission-details/mission-details?taskId=${data.businessId}`,
  112. });
  113. } else if (data.businessType == 1) {
  114. //查核计划 跳情景详情
  115. uni.setStorageSync("situaionID", data.businessId);
  116. uni.navigateTo({
  117. url: `/pages/situationDetail/situationDetail?situationId=${data.businessId}`,
  118. });
  119. } else {
  120. //情景详情
  121. uni.setStorageSync("situaionID", data.businessId);
  122. uni.navigateTo({
  123. url: `/pages/situationDetail/situationDetail?situationId=${data.businessId}`,
  124. });
  125. }
  126. this.MessList = [];
  127. for (let i = 1; i < this.currentPage + 1; i++) {
  128. this.$store
  129. .dispatch({
  130. type: "messages/commActions",
  131. payload: {
  132. key: "messagesList",
  133. data: {
  134. pageNum: i,
  135. pageSize: this.pageSize,
  136. },
  137. },
  138. })
  139. .then((res) => {
  140. this.MessList = this.MessList.concat(res.list);
  141. });
  142. }
  143. });
  144. },
  145. },
  146. computed: {},
  147. };
  148. </script>
  149. <style lang="less">
  150. .messages-page {
  151. padding-top: 15rpx;
  152. height: 100%;
  153. overflow-y: auto;
  154. .messages-content {
  155. display: flex;
  156. background-color: #fff;
  157. .imgView {
  158. margin-top: 25rpx;
  159. margin-left: 25rpx;
  160. margin-right: 25rpx;
  161. margin-bottom: 63.75rpx;
  162. width: 56.25rpx;
  163. height: 56.25rpx;
  164. vertical-align: top;
  165. // .image-circle {
  166. // background-color: ;
  167. // }
  168. image {
  169. width: 56.25rpx;
  170. height: 56.25rpx;
  171. }
  172. }
  173. .contView {
  174. flex: 1;
  175. border-bottom: 0.62rpx solid #dadee6;
  176. .contView-title {
  177. margin-top: 25rpx;
  178. font-size: 22.5rpx;
  179. font-weight: 500;
  180. color: #292c33;
  181. }
  182. .contView-content {
  183. margin: 15rpx 0 20rpx;
  184. font-size: 20rpx;
  185. color: #525866;
  186. }
  187. .contView-time {
  188. margin-bottom: 25rpx;
  189. font-size: 17.5rpx;
  190. color: #666e80;
  191. }
  192. }
  193. }
  194. .bottomTishi {
  195. padding: 6.25rpx 0px;
  196. width: 100%;
  197. // position: absolute;
  198. // bottom: 0rpx;
  199. text-align: center;
  200. font-size: 17.5rpx;
  201. color: #525866;
  202. }
  203. }
  204. </style>