notice-page.vue 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177
  1. <template>
  2. <view class="notice-page">
  3. <u-navbar
  4. height="40px"
  5. title="消息通知"
  6. bgColor="#fff"
  7. autoBack
  8. placeholder
  9. >
  10. </u-navbar>
  11. <view class="container_main">
  12. <view v-for="(item, i) in list" :key="i" class="item-wrap">
  13. <view class="time-box">{{ item.date }}</view>
  14. <notice-item
  15. v-for="child in item.msgList"
  16. :key="child.id"
  17. :item="child"
  18. @toDetail="toDetail"
  19. ></notice-item>
  20. </view>
  21. <!-- 加载更多 -->
  22. <u-loadmore
  23. v-if="list.length > 0"
  24. :status="loadStatus"
  25. @loadmore="onLoadMore"
  26. />
  27. <u-empty
  28. mode="data"
  29. text="暂无内容"
  30. marginTop="60"
  31. icon="https://xiangli-erp.oss-cn-hangzhou.aliyuncs.com/APP/no-notifcations.png"
  32. v-if="list.length == 0"
  33. ></u-empty>
  34. </view>
  35. </view>
  36. </template>
  37. <script>
  38. import noticeItem from "./components/notice-item.vue";
  39. import { getMsgList } from "@/common/request/apis/index.js";
  40. export default {
  41. components: {
  42. noticeItem,
  43. },
  44. data() {
  45. return {
  46. currentPage: 1,
  47. pageSize: 10,
  48. loadStatus: "loadmore", //加载前值为loadmore,加载中为loading,没有数据为nomore
  49. list: [],
  50. };
  51. },
  52. onLoad() {
  53. this.loadData();
  54. },
  55. onPullDownRefresh() {
  56. // 下拉刷新
  57. this.onRefresh();
  58. },
  59. onReachBottom() {
  60. // 触底加载更多
  61. this.onLoadMore();
  62. },
  63. methods: {
  64. async onRefresh() {
  65. try {
  66. await this.loadData(true);
  67. } finally {
  68. uni.stopPullDownRefresh();
  69. }
  70. },
  71. async onLoadMore() {
  72. if (this.loadStatus !== "loadmore") return;
  73. this.loadStatus = "loading";
  74. try {
  75. await this.loadData();
  76. } catch (e) {
  77. this.loadStatus = "loadmore";
  78. }
  79. },
  80. async loadData(isRefresh = false) {
  81. if (isRefresh) {
  82. this.currentPage = 1;
  83. this.list = [];
  84. }
  85. try {
  86. this.loadStatus = "loading";
  87. const currentPage = this.currentPage;
  88. const pageSize = this.pageSize;
  89. const params = {
  90. currentPage,
  91. pageSize,
  92. };
  93. console.log("params=====", params);
  94. const res = await getMsgList(params);
  95. const { rows, total } = res.data;
  96. console.log("res====", res);
  97. this.list = [...this.list, ...rows];
  98. if (currentPage * pageSize < Number(total)) {
  99. this.currentPage++;
  100. this.loadStatus = "loadmore";
  101. } else {
  102. this.loadStatus = "nomore";
  103. }
  104. } catch (error) {}
  105. },
  106. toDetail(val) {
  107. switch (val.type) {
  108. case "拣货任务":
  109. uni.navigateTo({
  110. url: `/pages/picking-task/detail?id=${val.title}`,
  111. });
  112. break;
  113. case "采购入库":
  114. uni.navigateTo({
  115. url: `/pages/purchase/detail?id=${val.title}`,
  116. });
  117. break;
  118. case "盘点任务":
  119. uni.navigateTo({
  120. url: `/pages/inventory-task/taskDetail?id=${val.title}`,
  121. });
  122. break;
  123. case "复核任务":
  124. if (val.content.includes("CGDD")) {
  125. uni.navigateTo({
  126. url: `/pages/purchase/detail?id=${val.title}`,
  127. });
  128. } else {
  129. uni.navigateTo({
  130. url: `/pages/picking-task/detail?id=${val.title}`,
  131. });
  132. }
  133. break;
  134. default:
  135. break;
  136. }
  137. },
  138. },
  139. };
  140. </script>
  141. <style lang="scss" scoped>
  142. .notice-page {
  143. min-height: 100vh;
  144. background-color: #f0f6fb;
  145. .container_main {
  146. padding: 32rpx 24rpx;
  147. .item-wrap {
  148. margin-bottom: 24rpx;
  149. }
  150. .time-box {
  151. position: relative;
  152. color: #000;
  153. font-family: "PingFang SC";
  154. font-size: 28rpx;
  155. font-weight: 400;
  156. padding-left: 20rpx;
  157. margin-bottom: 24rpx;
  158. &::before {
  159. content: "";
  160. display: block;
  161. width: 6rpx;
  162. height: 30rpx;
  163. border-radius: 100rpx;
  164. background: #0256ff;
  165. position: absolute;
  166. left: 0;
  167. top: 50%;
  168. transform: translateY(-50%);
  169. }
  170. }
  171. }
  172. }
  173. </style>