index.vue 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183
  1. <template>
  2. <mescroll-body ref="mescrollRef" @init="mescrollInit" @down="downCallback" @up="upCallback"
  3. style="background-color: #F5F6FA;">
  4. <u-navbar title="消息中心" leftIconSize='0' :bgColor="bgColor" :placeholder='true' leftIconColor="#fff"
  5. titleStyle='color:#fff' rightText='一键已读'>
  6. </u-navbar>
  7. <view class="top-bgc"></view>
  8. <view class="content">
  9. <view class="info-item flex" v-for="good in goods" :key="good.id">
  10. <view class="left">
  11. <u--image :showLoading="true" src="@/static/images/news/xt.png" width="80rpx" height="80rpx"></u--image>
  12. </view>
  13. <view class="right">
  14. <view class="row1 flex flex-space-between">
  15. <view class="title">
  16. 系统消息
  17. </view>
  18. <view class="time">
  19. 11:00
  20. </view>
  21. </view>
  22. <view class="row2 flex flex-space-between align-center">
  23. <view class="text point">
  24. 您的驾驶证即将到期,请尽快到“我的…您的驾驶证即将到期,请尽快到“我的…您的驾驶证即将到期,请尽快到“我的…您的驾驶证即将到期,请尽快到“我的…
  25. </view>
  26. <view class="red-point"></view>
  27. </view>
  28. </view>
  29. <!-- <view class="flex flex-space-between">
  30. <view class="left">
  31. <view>系统消息</view>
  32. <u-badge :isDot="true" bgColor='red' :absolute='true' :offset='badgeOffset'></u-badge>
  33. </view>
  34. <view class="">
  35. 今天 21:51
  36. </view>
  37. </view>
  38. <view class="flex flex-space-between">
  39. 您的驾驶证即将到期,请尽快到“我的-身份认证”中更新,逾期将影响运费支付。
  40. </view> -->
  41. </view>
  42. </view>
  43. </mescroll-body>
  44. </template>
  45. <script>
  46. import MescrollMixin from "@/uni_modules/mescroll-uni/components/mescroll-uni/mescroll-mixins.js";
  47. import {
  48. apiGoods
  49. } from "@/api/mock.js"
  50. export default {
  51. mixins: [MescrollMixin], // 使用mixin
  52. data() {
  53. return {
  54. src: 'https://cdn.uviewui.com/uview/album/1.jpg',
  55. bgColor: '#317AFE',
  56. value: 100,
  57. goods: [], // 数据列表
  58. badgeOffset: [0, -5]
  59. }
  60. },
  61. methods: {
  62. back() {
  63. uni.navigateBack({
  64. })
  65. },
  66. /*上拉加载的回调: 其中page.num:当前页 从1开始, page.size:每页数据条数,默认10 */
  67. upCallback(page) {
  68. // 此处可以继续请求其他接口
  69. // if(page.num == 1){
  70. // // 请求其他接口...
  71. // }
  72. // 如果希望先请求其他接口,再触发upCallback,可参考以下写法
  73. // if(!this.isInitxx){
  74. // apiGetxx().then(res=>{
  75. // this.isInitxx = true
  76. // this.mescroll.resetUpScroll() // 重新触发upCallback
  77. // }).catch(()=>{
  78. // this.mescroll.endErr()
  79. // })
  80. // return // 此处return,先获取xx
  81. // }
  82. //联网加载数据
  83. apiGoods(page.num, page.size).then(res => {
  84. //联网成功的回调,隐藏下拉刷新和上拉加载的状态;
  85. //mescroll会根据传的参数,自动判断列表如果无任何数据,则提示空;列表无下一页数据,则提示无更多数据;
  86. //方法一(推荐): 后台接口有返回列表的总页数 totalPage
  87. //this.mescroll.endByPage(res.list.length, totalPage); //必传参数(当前页的数据个数, 总页数)
  88. //方法二(推荐): 后台接口有返回列表的总数据量 totalSize
  89. //this.mescroll.endBySize(res.list.length, totalSize); //必传参数(当前页的数据个数, 总数据量)
  90. //方法三(推荐): 您有其他方式知道是否有下一页 hasNext
  91. //this.mescroll.endSuccess(res.list.length, hasNext); //必传参数(当前页的数据个数, 是否有下一页true/false)
  92. //方法四 (不推荐),会存在一个小问题:比如列表共有20条数据,每页加载10条,共2页.如果只根据当前页的数据个数判断,则需翻到第三页才会知道无更多数据
  93. this.mescroll.endSuccess(res.list.length);
  94. //设置列表数据
  95. if (page.num == 1) this.goods = []; //如果是第一页需手动制空列表
  96. this.goods = this.goods.concat(res.list); //追加新数据
  97. }).catch(() => {
  98. //联网失败, 结束加载
  99. this.mescroll.endErr();
  100. })
  101. }
  102. }
  103. }
  104. </script>
  105. <style lang="scss">
  106. /deep/.u-navbar__content__right__text {
  107. font-size: 26rpx;
  108. color: #FFFFFF;
  109. }
  110. .top-bgc {
  111. position: absolute;
  112. width: 100%;
  113. height: 519rpx;
  114. background: linear-gradient(180deg, #317AFE 0%, #F8F9FC 100%);
  115. }
  116. .content {
  117. // position: relative;
  118. // top: 0;
  119. background: #FFFFFF;
  120. margin: 20rpx;
  121. width: calc(100% - 40rpx);
  122. padding: 20rpx;
  123. box-sizing: border-box;
  124. border-radius: 20rpx;
  125. }
  126. .info-item {
  127. padding: 30rpx 0;
  128. .left {
  129. margin-right: 20rpx;
  130. }
  131. .right {
  132. width: 100%;
  133. border-bottom: 1px solid #E6E6E6;
  134. .row1 {
  135. .title {
  136. font-size: 28rpx;
  137. color: #000000;
  138. }
  139. .time {
  140. font-size: 24rpx;
  141. color: #999999;
  142. }
  143. }
  144. .row2 {
  145. .text {
  146. font-size: 24rpx;
  147. color: #999999;
  148. width: 500rpx;
  149. }
  150. .red-point {
  151. width: 10rpx;
  152. height: 10rpx;
  153. background: #EE2F51;
  154. border-radius: 6rpx;
  155. margin-right: 20rpx;
  156. }
  157. }
  158. }
  159. }
  160. </style>