index.vue 6.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285
  1. <!-- @format -->
  2. <template>
  3. <view
  4. style="height: 100vh; background-color: #f3f4f9; padding: 20rpx"
  5. class=""
  6. >
  7. <view
  8. style="
  9. width: 100%;
  10. display: flex;
  11. justify-content: center;
  12. margin-bottom: 30rpx;
  13. "
  14. >
  15. <u-tabs
  16. :itemStyle="{ width: '250rpx', marginBottom: '20rpx' }"
  17. :lineWidth="50"
  18. :activeStyle="{ color: '#3c9cff' }"
  19. :list="tabsList"
  20. @click="handleChange"
  21. ></u-tabs>
  22. </view>
  23. <view v-if="ledgerList.length">
  24. <view
  25. v-for="item in ledgerList"
  26. style="
  27. background-color: #fff;
  28. border-radius: 20rpx;
  29. padding: 20rpx;
  30. margin: 0rpx auto 20rpx;
  31. "
  32. class=""
  33. >
  34. <view @click="detailInfo(item)" class="">
  35. <view style="display: inline-block" class="">
  36. <view
  37. style="line-height: 60rpx; font-size: 36rpx; font-weight: 700"
  38. class=""
  39. >
  40. {{ item.title }}
  41. </view>
  42. <view>
  43. {{ item.typeName }}
  44. </view>
  45. <view style="line-height: 50rpx; color: #929292" class="">
  46. {{ item.createTime }}
  47. </view>
  48. </view>
  49. <view style="float: right; margin-top: 30rpx" class="">
  50. <view v-if="item.readStatus == 1" style="color: limegreen" class="">
  51. 已读消息
  52. </view>
  53. <view v-if="item.readStatus == 0" style="color: red" class="">
  54. 未读消息
  55. </view>
  56. </view>
  57. </view>
  58. </view>
  59. </view>
  60. <view v-else>
  61. <u-empty mode="message"> </u-empty>
  62. </view>
  63. </view>
  64. </template>
  65. <script>
  66. import { getReadMessageState } from "@/api/work.js";
  67. import { msgList } from "@/api/work.js";
  68. export default {
  69. data() {
  70. return {
  71. tabsList: [
  72. {
  73. name: "未读",
  74. state: 0,
  75. },
  76. {
  77. name: "已读",
  78. state: 1,
  79. },
  80. ],
  81. readColor: {
  82. 已撤回: "#fa3534",
  83. 已接收: "#2979ff",
  84. 待提交: "#2979ff",
  85. 备案中: "#2979ff",
  86. 已拒绝: "#fa3534",
  87. 勿备案: "#fa3534",
  88. 未备案: "#909399",
  89. 免备案: "#909399",
  90. 已退回: "#fa3534",
  91. },
  92. read: [], //备案字典
  93. queryParams: {
  94. pageNum: 1,
  95. pageSize: 10,
  96. readStatus: 0,
  97. },
  98. ledgerList: [],
  99. total: 0,
  100. current: 0,
  101. swiperDotIndex: 0,
  102. data: [
  103. {
  104. image: "/static/images/banner/banner01.jpg",
  105. },
  106. {
  107. image: "/static/images/banner/banner02.jpg",
  108. },
  109. {
  110. image: "/static/images/banner/banner03.jpg",
  111. },
  112. ],
  113. };
  114. },
  115. onShow() {
  116. this.getList();
  117. uni.startPullDownRefresh();
  118. getReadMessageState().then(({ data }) => {
  119. uni.setTabBarBadge({
  120. //显示数字
  121. index: 1, //tabbar下标
  122. text: `${data.count}`, //数字
  123. });
  124. });
  125. },
  126. onLoad() {
  127. // useDict("read_status").then((res) => {
  128. // this.read = res;
  129. // });
  130. this.getList();
  131. uni.startPullDownRefresh();
  132. },
  133. onPullDownRefresh() {
  134. this.getList();
  135. setTimeout(function () {
  136. uni.stopPullDownRefresh();
  137. }, 800);
  138. },
  139. methods: {
  140. handleChange(row) {
  141. this.queryParams.readStatus = row.state;
  142. this.getList();
  143. },
  144. detailInfo(item) {
  145. uni.navigateTo({
  146. url: "/pages/work/detailInfo?id=" + item.id,
  147. });
  148. },
  149. getList() {
  150. uni.showLoading({
  151. title: "加载中...",
  152. });
  153. msgList({
  154. ...this.queryParams,
  155. }).then(({ rows, total }) => {
  156. this.ledgerList = rows;
  157. this.total = total;
  158. uni.hideLoading();
  159. });
  160. },
  161. onReachBottom() {
  162. //触底事件
  163. if (this.queryParams.pageNum * this.queryParams.pageSize >= this.total) {
  164. uni.showToast({
  165. title: "没有更多数据了",
  166. icon: "none",
  167. duration: 1000,
  168. });
  169. setTimeout(() => {
  170. uni.hideLoading();
  171. }, 500);
  172. } else {
  173. if (this.queryParams.pageNum <= this.queryParams.pageNum - 1) {
  174. setTimeout(() => {
  175. uni.hideLoading();
  176. }, 500);
  177. } else {
  178. uni.showLoading({
  179. title: "加载中",
  180. });
  181. this.queryParams.pageNum++;
  182. msgList({
  183. ...this.queryParams,
  184. }).then(({ rows, total }) => {
  185. this.ledgerList = [...this.ledgerList, ...rows];
  186. this.total = total;
  187. });
  188. }
  189. setTimeout(() => {
  190. uni.hideLoading();
  191. }, 500);
  192. }
  193. },
  194. clickBannerItem(item) {
  195. console.info(item);
  196. },
  197. changeSwiper(e) {
  198. this.current = e.detail.current;
  199. },
  200. changeGrid(e) {
  201. this.$modal.showToast("模块建设中~");
  202. },
  203. },
  204. };
  205. </script>
  206. <style lang="scss">
  207. /* #ifndef APP-NVUE */
  208. page {
  209. display: flex;
  210. flex-direction: column;
  211. box-sizing: border-box;
  212. background-color: #fff;
  213. min-height: 100%;
  214. height: auto;
  215. }
  216. view {
  217. font-size: 14px;
  218. line-height: inherit;
  219. }
  220. /* #endif */
  221. .text {
  222. text-align: center;
  223. font-size: 26rpx;
  224. margin-top: 10rpx;
  225. }
  226. .grid-item-box {
  227. flex: 1;
  228. /* #ifndef APP-NVUE */
  229. display: flex;
  230. /* #endif */
  231. flex-direction: column;
  232. align-items: center;
  233. justify-content: center;
  234. padding: 15px 0;
  235. }
  236. .uni-margin-wrap {
  237. width: 690rpx;
  238. width: 100%;
  239. }
  240. .swiper {
  241. height: 300rpx;
  242. }
  243. .swiper-box {
  244. height: 150px;
  245. }
  246. .swiper-item {
  247. /* #ifndef APP-NVUE */
  248. display: flex;
  249. /* #endif */
  250. flex-direction: column;
  251. justify-content: center;
  252. align-items: center;
  253. color: #fff;
  254. height: 300rpx;
  255. line-height: 300rpx;
  256. }
  257. @media screen and (min-width: 500px) {
  258. .uni-swiper-dot-box {
  259. width: 400px;
  260. /* #ifndef APP-NVUE */
  261. margin: 0 auto;
  262. /* #endif */
  263. margin-top: 8px;
  264. }
  265. .image {
  266. width: 100%;
  267. }
  268. }
  269. </style>