index.vue 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252
  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. var that
  50. import MescrollMixin from "@/uni_modules/mescroll-uni/components/mescroll-uni/mescroll-mixins.js";
  51. import {
  52. mapState
  53. } from 'vuex';
  54. export default {
  55. mixins: [MescrollMixin], // 使用mixin
  56. data() {
  57. return {
  58. src: 'https://cdn.uviewui.com/uview/album/1.jpg',
  59. bgColor: '#317AFE',
  60. value: 100,
  61. news: [], // 数据列表
  62. badgeOffset: [0, -5],
  63. mescroll: null
  64. }
  65. },
  66. onLoad() {
  67. that = this
  68. },
  69. onShow() {
  70. that.$request.baseRequest('get', '/newsInfo/unreadMessage', {
  71. reCommonId: this.userInfo.id,
  72. }).then(res3 => {
  73. if (res3.data) {
  74. let name = 'myTip';
  75. let value = res3.data
  76. if (value == 0) {
  77. uni.removeTabBarBadge({
  78. index: 2
  79. })
  80. }
  81. that.$store.commit('$uStore', {
  82. name,
  83. value
  84. });
  85. if (value != 0 && value) {
  86. uni.setTabBarBadge({
  87. index: 2,
  88. text: value + ""
  89. })
  90. }
  91. }
  92. })
  93. // this.mescroll.resetUpScroll()
  94. },
  95. computed: {
  96. ...mapState(['hasLogin', 'userInfo', 'firstAuthentication'])
  97. },
  98. methods: {
  99. rightClick() {
  100. uni.showLoading({
  101. title: '加载中',
  102. mask: true
  103. })
  104. this.$request.baseRequest('post', '/newsInfo/api/editAllNewsInfo', {
  105. reCommonId: this.userInfo.id,
  106. }).then(res => {
  107. this.mescroll.resetUpScroll()
  108. uni.hideLoading()
  109. uni.removeTabBarBadge({
  110. index: 2
  111. })
  112. })
  113. .catch(res => {
  114. uni.$u.toast(res.message);
  115. });
  116. },
  117. read(val) {
  118. uni.showLoading({
  119. title: '加载中',
  120. mask: true
  121. })
  122. this.$request.baseRequest('post', '/newsInfo/api/editNewsInfo', {
  123. id: val.id,
  124. }).then(res => {
  125. this.mescroll.resetUpScroll()
  126. uni.hideLoading()
  127. })
  128. .catch(res => {
  129. uni.$u.toast(res.message);
  130. });
  131. },
  132. back() {
  133. uni.navigateBack({
  134. })
  135. },
  136. mescrollInit(mescroll) {
  137. this.mescroll = mescroll;
  138. },
  139. /*上拉加载的回调: 其中page.num:当前页 从1开始, page.size:每页数据条数,默认10 */
  140. upCallback(page) {
  141. // 此处可以继续请求其他接口
  142. // if(page.num == 1){
  143. // // 请求其他接口...
  144. // }
  145. // 如果希望先请求其他接口,再触发upCallback,可参考以下写法
  146. // if(!this.isInitxx){
  147. // apiGetxx().then(res=>{
  148. // this.isInitxx = true
  149. // this.mescroll.resetUpScroll() // 重新触发upCallback
  150. // }).catch(()=>{
  151. // this.mescroll.endErr()
  152. // })
  153. // return // 此处return,先获取xx
  154. // }
  155. //联网加载数据
  156. this.$request.baseRequest('get', '/newsInfo/selectNewsInfo', {
  157. reCommonId: this.userInfo.id,
  158. pageSize: page.size,
  159. currentPage: page.num,
  160. }).then(res => {
  161. this.news = res.data.records
  162. this.mescroll.endBySize(res.data.records.length, res.data.total);
  163. })
  164. .catch(res => {
  165. uni.$u.toast(res.message);
  166. });
  167. }
  168. }
  169. }
  170. </script>
  171. <style lang="scss">
  172. /deep/.u-navbar__content__right__text {
  173. font-size: 26rpx;
  174. color: #FFFFFF;
  175. }
  176. .top-bgc {
  177. position: absolute;
  178. width: 100%;
  179. height: 519rpx;
  180. // background: linear-gradient(180deg, #317AFE 0%, #F8F9FC 100%);
  181. }
  182. .content {
  183. // position: relative;
  184. // top: 0;
  185. background: #FFFFFF;
  186. margin: 20rpx;
  187. width: calc(100% - 40rpx);
  188. // padding: 20rpx;
  189. box-sizing: border-box;
  190. border-radius: 20rpx;
  191. padding-top: 30rpx;
  192. }
  193. .info-item {
  194. padding: 0 30rpx 30rpx 30rpx;
  195. .img {
  196. width: 80rpx;
  197. height: 80rpx;
  198. }
  199. .left {
  200. margin-right: 20rpx;
  201. }
  202. .right {
  203. width: 100%;
  204. border-bottom: 1px solid #E6E6E6;
  205. padding-bottom: 20rpx;
  206. .row1 {
  207. .title {
  208. font-size: 32rpx;
  209. color: #000000;
  210. }
  211. .time {
  212. font-size: 32rpx;
  213. color: #999999;
  214. }
  215. }
  216. .row2 {
  217. .text {
  218. font-size: 28rpx;
  219. color: #999999;
  220. width: 500rpx;
  221. }
  222. .red-point {
  223. width: 10rpx;
  224. height: 10rpx;
  225. background: #EE2F51;
  226. border-radius: 6rpx;
  227. margin-right: 20rpx;
  228. }
  229. }
  230. }
  231. }
  232. </style>