messages.vue 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209
  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. <tm-no-data v-if="MessList.length === 0"
  40. :textArr="['暂时没有内容可以展示哦', '请返回上一页面或尝试刷新页面']" />
  41. <view class="bottomPanDuan"></view>
  42. </view>
  43. <view class="bottomTishi">
  44. <view v-if="loading"> 向上滑动加载更多! </view>
  45. <view v-else> 已经到底了~ </view>
  46. </view>
  47. </view>
  48. </template>
  49. <script>
  50. import moment from "moment";
  51. export default {
  52. data() {
  53. return {
  54. pageNum: 1,
  55. pageSize: 10,
  56. MessList: [],
  57. loading: false,
  58. currentPage: 0,
  59. totalPage: 0,
  60. };
  61. },
  62. mounted() {
  63. this.getMessList();
  64. },
  65. methods: {
  66. getMessList() {
  67. var currPage = this.currentPage + 1;
  68. this.$store
  69. .dispatch({
  70. type: "messages/commActions",
  71. payload: {
  72. key: "messagesList",
  73. data: {
  74. pageNum: currPage,
  75. pageSize: this.pageSize,
  76. },
  77. },
  78. })
  79. .then((res) => {
  80. this.totalPage = res.totalPage;
  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
  100. .dispatch({
  101. type: "messages/commActions",
  102. payload: {
  103. key: "toRead",
  104. data: {
  105. id: data.id,
  106. },
  107. },
  108. })
  109. .then((res) => {
  110. if (data.businessType == 2) {
  111. //改善任务
  112. uni.navigateTo({
  113. url: `/pages/mission-details/mission-details?taskId=${data.businessId}`,
  114. });
  115. } else if (data.businessType == 1) {
  116. //查核计划 跳情景详情
  117. uni.setStorageSync("situaionID", data.businessId);
  118. uni.navigateTo({
  119. url: `/pages/situationDetail/situationDetail?situationId=${data.businessId}`,
  120. });
  121. } else {
  122. //情景详情
  123. uni.setStorageSync("situaionID", data.businessId);
  124. uni.navigateTo({
  125. url: `/pages/situationDetail/situationDetail?situationId=${data.businessId}`,
  126. });
  127. }
  128. this.MessList = [];
  129. for (let i = 1; i < this.currentPage + 1; i++) {
  130. this.$store
  131. .dispatch({
  132. type: "messages/commActions",
  133. payload: {
  134. key: "messagesList",
  135. data: {
  136. pageNum: i,
  137. pageSize: this.pageSize,
  138. },
  139. },
  140. })
  141. .then((res) => {
  142. this.MessList = this.MessList.concat(res.list);
  143. });
  144. }
  145. });
  146. },
  147. },
  148. computed: {},
  149. };
  150. </script>
  151. <style lang="less">
  152. .messages-page {
  153. padding-top: 15rpx;
  154. height: 100%;
  155. overflow-y: auto;
  156. .messages-content {
  157. display: flex;
  158. background-color: #fff;
  159. .imgView {
  160. margin-top: 25rpx;
  161. margin-left: 25rpx;
  162. margin-right: 25rpx;
  163. margin-bottom: 63.75rpx;
  164. width: 56.25rpx;
  165. height: 56.25rpx;
  166. vertical-align: top;
  167. // .image-circle {
  168. // background-color: ;
  169. // }
  170. image {
  171. width: 56.25rpx;
  172. height: 56.25rpx;
  173. }
  174. }
  175. .contView {
  176. flex: 1;
  177. border-bottom: 0.62rpx solid #dadee6;
  178. .contView-title {
  179. margin-top: 25rpx;
  180. font-size: 22.5rpx;
  181. font-weight: 500;
  182. color: #292c33;
  183. }
  184. .contView-content {
  185. margin: 15rpx 0 20rpx;
  186. font-size: 20rpx;
  187. color: #525866;
  188. }
  189. .contView-time {
  190. margin-bottom: 25rpx;
  191. font-size: 17.5rpx;
  192. color: #666e80;
  193. }
  194. }
  195. }
  196. .bottomTishi {
  197. padding: 6.25rpx 0px;
  198. width: 100%;
  199. // position: absolute;
  200. // bottom: 0rpx;
  201. text-align: center;
  202. font-size: 17.5rpx;
  203. color: #525866;
  204. }
  205. }
  206. </style>