index.vue 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206
  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='一键已读' @rightClick="rightClick">
  6. </u-navbar>
  7. <view class="top-bgc"></view>
  8. <view class="content">
  9. <view class="info-item flex" v-for="(item,index) in news" :key="index" @click="read(item)">
  10. <view class="left">
  11. <image src="@/static/images/news/cy.png" class="img" v-if="item.newsType=='承运通知'">
  12. </image>
  13. <image src="@/static/images/news/xt.png" class="img" v-else>
  14. </image>
  15. </view>
  16. <view class="right">
  17. <view class="row1 flex flex-space-between">
  18. <view class="title">
  19. {{item.newsType}}
  20. </view>
  21. <view class="time">
  22. {{item.updateDate}}
  23. </view>
  24. </view>
  25. <view class="row2 flex flex-space-between align-center">
  26. <view class="text point">
  27. {{item.newsContent}}
  28. </view>
  29. <view class="red-point" v-if="item.newsFlag==0"></view>
  30. </view>
  31. </view>
  32. <!-- <view class="flex flex-space-between">
  33. <view class="left">
  34. <view>系统消息</view>
  35. <u-badge :isDot="true" bgColor='red' :absolute='true' :offset='badgeOffset'></u-badge>
  36. </view>
  37. <view class="">
  38. 今天 21:51
  39. </view>
  40. </view>
  41. <view class="flex flex-space-between">
  42. 您的驾驶证即将到期,请尽快到“我的-身份认证”中更新,逾期将影响运费支付。
  43. </view> -->
  44. </view>
  45. </view>
  46. </mescroll-body>
  47. </template>
  48. <script>
  49. import MescrollMixin from "@/uni_modules/mescroll-uni/components/mescroll-uni/mescroll-mixins.js";
  50. import {
  51. mapState
  52. } from 'vuex';
  53. export default {
  54. mixins: [MescrollMixin], // 使用mixin
  55. data() {
  56. return {
  57. src: 'https://cdn.uviewui.com/uview/album/1.jpg',
  58. bgColor: '#317AFE',
  59. value: 100,
  60. news: [], // 数据列表
  61. badgeOffset: [0, -5]
  62. }
  63. },
  64. computed: {
  65. ...mapState(['hasLogin', 'userInfo', 'firstAuthentication'])
  66. },
  67. methods: {
  68. rightClick() {
  69. console.log(123)
  70. this.$request.baseRequest('post', '/newsInfo/api/editAllNewsInfo', {
  71. reCommonId: this.userInfo.id,
  72. }).then(res => {
  73. this.mescroll.resetUpScroll()
  74. })
  75. .catch(res => {
  76. uni.$u.toast(res.message);
  77. });
  78. },
  79. read(val) {
  80. this.$request.baseRequest('post', '/newsInfo/api/editNewsInfo', {
  81. id: val.id,
  82. }).then(res => {
  83. this.mescroll.resetUpScroll()
  84. })
  85. .catch(res => {
  86. uni.$u.toast(res.message);
  87. });
  88. },
  89. back() {
  90. uni.navigateBack({
  91. })
  92. },
  93. mescrollInit(mescroll) {
  94. this.mescroll = mescroll;
  95. },
  96. /*上拉加载的回调: 其中page.num:当前页 从1开始, page.size:每页数据条数,默认10 */
  97. upCallback(page) {
  98. // 此处可以继续请求其他接口
  99. // if(page.num == 1){
  100. // // 请求其他接口...
  101. // }
  102. // 如果希望先请求其他接口,再触发upCallback,可参考以下写法
  103. // if(!this.isInitxx){
  104. // apiGetxx().then(res=>{
  105. // this.isInitxx = true
  106. // this.mescroll.resetUpScroll() // 重新触发upCallback
  107. // }).catch(()=>{
  108. // this.mescroll.endErr()
  109. // })
  110. // return // 此处return,先获取xx
  111. // }
  112. //联网加载数据
  113. this.$request.baseRequest('get', '/newsInfo/selectNewsInfo', {
  114. reCommonId: this.userInfo.id,
  115. pageSize: page.size,
  116. currentPage: page.num,
  117. }).then(res => {
  118. this.news = res.data.records
  119. this.mescroll.endBySize(res.data.records.length, res.data.total);
  120. })
  121. .catch(res => {
  122. uni.$u.toast(res.message);
  123. });
  124. }
  125. }
  126. }
  127. </script>
  128. <style lang="scss">
  129. /deep/.u-navbar__content__right__text {
  130. font-size: 26rpx;
  131. color: #FFFFFF;
  132. }
  133. .top-bgc {
  134. position: absolute;
  135. width: 100%;
  136. height: 519rpx;
  137. // background: linear-gradient(180deg, #317AFE 0%, #F8F9FC 100%);
  138. }
  139. .content {
  140. // position: relative;
  141. // top: 0;
  142. background: #FFFFFF;
  143. margin: 20rpx;
  144. width: calc(100% - 40rpx);
  145. // padding: 20rpx;
  146. box-sizing: border-box;
  147. border-radius: 20rpx;
  148. }
  149. .info-item {
  150. padding: 30rpx;
  151. .img {
  152. width: 80rpx;
  153. height: 80rpx;
  154. }
  155. .left {
  156. margin-right: 20rpx;
  157. }
  158. .right {
  159. width: 100%;
  160. border-bottom: 1px solid #E6E6E6;
  161. .row1 {
  162. .title {
  163. font-size: 28rpx;
  164. color: #000000;
  165. }
  166. .time {
  167. font-size: 24rpx;
  168. color: #999999;
  169. }
  170. }
  171. .row2 {
  172. .text {
  173. font-size: 24rpx;
  174. color: #999999;
  175. width: 500rpx;
  176. }
  177. .red-point {
  178. width: 10rpx;
  179. height: 10rpx;
  180. background: #EE2F51;
  181. border-radius: 6rpx;
  182. margin-right: 20rpx;
  183. }
  184. }
  185. }
  186. }
  187. </style>