index.vue 7.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314
  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. <u-modal :show="isShowAlert" :title="alertTitle" :closeOnClickOverlay='true'
  45. :showCancelButton='showCancelButton' confirmColor='#2772FB' @confirm="confirmClick"
  46. @close="cancelClick" @cancel="cancelClick"></u-modal>
  47. </view>
  48. </view>
  49. </mescroll-body>
  50. </template>
  51. <script>
  52. var that
  53. import MescrollMixin from "@/uni_modules/mescroll-uni/components/mescroll-uni/mescroll-mixins.js";
  54. import {
  55. mapState
  56. } from 'vuex';
  57. export default {
  58. mixins: [MescrollMixin], // 使用mixin
  59. data() {
  60. return {
  61. confirmText: '确定',
  62. showCancelButton: true,
  63. isShowAlert: false,
  64. alertTitle: '',
  65. src: 'https://cdn.uviewui.com/uview/album/1.jpg',
  66. bgColor: '#317AFE',
  67. value: 100,
  68. news: [], // 数据列表
  69. badgeOffset: [0, -5],
  70. mescroll: null
  71. }
  72. },
  73. async onLoad() {
  74. that = this
  75. // #ifdef APP-PLUS
  76. let _status = await that.$request.baseRequest('get', '/driverInfo/firstAuthentication', {
  77. driverPhone: this.userInfo.phone,
  78. }).then(res => {
  79. return res.data.authenticationStatus
  80. })
  81. if (_status == '已禁用') {
  82. this.isShowAlert = true
  83. this.alertTitle == '账号审核中'
  84. this.confirmText = '退出APP'
  85. this.showCancelButton = false
  86. } else {
  87. console.log(1231233212332312312213)
  88. }
  89. // #endif
  90. },
  91. onShow() {
  92. that.$request.baseRequest('get', '/newsInfo/unreadMessage', {
  93. reCommonId: this.userInfo.id,
  94. }).then(res3 => {
  95. if (res3.data) {
  96. let name = 'myTip';
  97. let value = res3.data
  98. if (value == 0) {
  99. uni.removeTabBarBadge({
  100. index: 2
  101. })
  102. }
  103. that.$store.commit('$uStore', {
  104. name,
  105. value
  106. });
  107. if (value != 0 && value) {
  108. uni.setTabBarBadge({
  109. index: 2,
  110. text: value + ""
  111. })
  112. }
  113. }
  114. })
  115. // this.mescroll.resetUpScroll()
  116. },
  117. computed: {
  118. ...mapState(['hasLogin', 'userInfo', 'firstAuthentication'])
  119. },
  120. methods: {
  121. confirmClick() {
  122. // #ifdef APP-PLUS
  123. if (this.alertTitle == '账号审核中') {
  124. if (uni.getSystemInfoSync().platform == 'ios') {
  125. plus.ios.import("UIApplication").sharedApplication().performSelector("exit")
  126. } else if (uni.getSystemInfoSync().platform == 'android') {
  127. plus.runtime.quit();
  128. }
  129. return
  130. }
  131. // #endif
  132. },
  133. rightClick() {
  134. uni.showLoading({
  135. title: '加载中',
  136. mask: true
  137. })
  138. this.$request.baseRequest('post', '/newsInfo/api/editAllNewsInfo', {
  139. reCommonId: this.userInfo.id,
  140. }).then(res => {
  141. this.mescroll.resetUpScroll()
  142. uni.hideLoading()
  143. uni.removeTabBarBadge({
  144. index: 2
  145. })
  146. })
  147. .catch(res => {
  148. uni.$u.toast(res.message);
  149. });
  150. },
  151. read(val) {
  152. uni.showLoading({
  153. title: '加载中',
  154. mask: true
  155. })
  156. this.$request.baseRequest('post', '/newsInfo/api/editNewsInfo', {
  157. id: val.id,
  158. }).then(res => {
  159. this.mescroll.resetUpScroll()
  160. this.look()
  161. uni.hideLoading()
  162. })
  163. .catch(res => {
  164. uni.$u.toast(res.message);
  165. });
  166. },
  167. look() {
  168. that.$request.baseRequest('get', '/newsInfo/unreadMessage', {
  169. reCommonId: this.userInfo.id,
  170. }).then(res3 => {
  171. if (res3.data || res3.data == 0) {
  172. let name = 'myTip';
  173. let value = res3.data
  174. if (value == 0) {
  175. uni.removeTabBarBadge({
  176. index: 2
  177. })
  178. }
  179. that.$store.commit('$uStore', {
  180. name,
  181. value
  182. });
  183. if (value != 0 && value) {
  184. uni.setTabBarBadge({
  185. index: 2,
  186. text: value + ""
  187. })
  188. }
  189. }
  190. })
  191. },
  192. back() {
  193. uni.navigateBack({
  194. })
  195. },
  196. mescrollInit(mescroll) {
  197. this.mescroll = mescroll;
  198. },
  199. /*上拉加载的回调: 其中page.num:当前页 从1开始, page.size:每页数据条数,默认10 */
  200. upCallback(page) {
  201. // 此处可以继续请求其他接口
  202. // if(page.num == 1){
  203. // // 请求其他接口...
  204. // }
  205. // 如果希望先请求其他接口,再触发upCallback,可参考以下写法
  206. // if(!this.isInitxx){
  207. // apiGetxx().then(res=>{
  208. // this.isInitxx = true
  209. // this.mescroll.resetUpScroll() // 重新触发upCallback
  210. // }).catch(()=>{
  211. // this.mescroll.endErr()
  212. // })
  213. // return // 此处return,先获取xx
  214. // }
  215. //联网加载数据
  216. this.$request.baseRequest('get', '/newsInfo/selectNewsInfo', {
  217. reCommonId: this.userInfo.id,
  218. pageSize: page.size,
  219. currentPage: page.num,
  220. }).then(res => {
  221. this.news = this.news.concat(res.data.records); //追加新数据
  222. // this.news = res.data.records
  223. this.mescroll.endBySize(res.data.records.length, res.data.total);
  224. })
  225. .catch(res => {
  226. uni.$u.toast(res.message);
  227. });
  228. }
  229. }
  230. }
  231. </script>
  232. <style lang="scss">
  233. /deep/.u-navbar__content__right__text {
  234. font-size: 26rpx;
  235. color: #FFFFFF;
  236. }
  237. .top-bgc {
  238. position: absolute;
  239. width: 100%;
  240. height: 519rpx;
  241. // background: linear-gradient(180deg, #317AFE 0%, #F8F9FC 100%);
  242. }
  243. .content {
  244. // position: relative;
  245. // top: 0;
  246. background: #FFFFFF;
  247. margin: 20rpx;
  248. width: calc(100% - 40rpx);
  249. // padding: 20rpx;
  250. box-sizing: border-box;
  251. border-radius: 20rpx;
  252. padding-top: 30rpx;
  253. }
  254. .info-item {
  255. padding: 0 30rpx 30rpx 30rpx;
  256. .img {
  257. width: 80rpx;
  258. height: 80rpx;
  259. }
  260. .left {
  261. margin-right: 20rpx;
  262. }
  263. .right {
  264. width: 100%;
  265. border-bottom: 1px solid #E6E6E6;
  266. padding-bottom: 20rpx;
  267. .row1 {
  268. .title {
  269. font-size: 32rpx;
  270. color: #000000;
  271. }
  272. .time {
  273. font-size: 32rpx;
  274. color: #999999;
  275. }
  276. }
  277. .row2 {
  278. .text {
  279. font-size: 28rpx;
  280. color: #999999;
  281. width: 500rpx;
  282. }
  283. .red-point {
  284. width: 10rpx;
  285. height: 10rpx;
  286. background: #EE2F51;
  287. border-radius: 6rpx;
  288. margin-right: 20rpx;
  289. }
  290. }
  291. }
  292. }
  293. </style>