index.vue 9.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366
  1. <template>
  2. <!-- <mescroll-body ref="mescrollRef" @init="mescrollInit" @down="downCallback" @up="upCallback"
  3. style="background-color: #F5F6FA;"> -->
  4. <view>
  5. <u-navbar title="消息中心" leftIconSize='0' :bgColor="bgColor" :placeholder='true' leftIconColor="#fff"
  6. titleStyle='color:#fff' rightText='全部已读' @rightClick="rightClick">
  7. </u-navbar>
  8. <view class="top-bgc"></view>
  9. <mescroll-body ref="mescrollRef" @init="mescrollInit" @down="downCallback" @up="upCallback"
  10. style="background-color: #F5F6FA;">
  11. <view class="content" v-if="news.length > 0">
  12. <view class="info-item flex" v-for="(item,index) in news" :key="index" @click="read(item)">
  13. <view class="left">
  14. <image src="@/static/images/news/cy.png" class="img" v-if="item.newsType=='承运通知'">
  15. </image>
  16. <image src="@/static/images/news/xt.png" class="img" v-else>
  17. </image>
  18. </view>
  19. <view class="right" :style="{'border-bottom':index==news.length-1?'1px solid #fff':'1px solid #e6e6e6'}">
  20. <view class="row1 flex flex-space-between">
  21. <view class="title">
  22. {{item.newsType}}
  23. </view>
  24. <view class="time">
  25. {{item.createDate}}
  26. </view>
  27. </view>
  28. <view class="row2 flex flex-space-between align-center">
  29. <view style='white-space: pre-wrap;' class="text point1">
  30. {{item.newsContent}}
  31. </view>
  32. <view class="red-point" v-if="item.newsFlag==0"></view>
  33. </view>
  34. </view>
  35. <!-- <view class="flex flex-space-between">
  36. <view class="left">
  37. <view>系统消息</view>
  38. <u-badge :isDot="true" bgColor='red' :absolute='true' :offset='badgeOffset'></u-badge>
  39. </view>
  40. <view class="">
  41. 今天 21:51
  42. </view>
  43. </view>
  44. <view class="flex flex-space-between">
  45. 您的驾驶证即将到期,请尽快到“我的-身份认证”中更新,逾期将影响运费支付。
  46. </view> -->
  47. <u-modal :show="isShowAlert" :title="alertTitle" :closeOnClickOverlay='true'
  48. :showCancelButton='showCancelButton' confirmColor='#2772FB' @confirm="confirmClick"
  49. @close="cancelClick" @cancel="cancelClick"></u-modal>
  50. </view>
  51. </view>
  52. </mescroll-body>
  53. </view>
  54. </template>
  55. <script>
  56. var that
  57. import MescrollMixin from "@/uni_modules/mescroll-uni/components/mescroll-uni/mescroll-mixins.js";
  58. import {
  59. mapState
  60. } from 'vuex';
  61. export default {
  62. mixins: [MescrollMixin], // 使用mixin
  63. data() {
  64. return {
  65. confirmText: '确定',
  66. showCancelButton: true,
  67. isShowAlert: false,
  68. alertTitle: '',
  69. src: 'https://cdn.uviewui.com/uview/album/1.jpg',
  70. bgColor: '#317AFE',
  71. value: 100,
  72. news: [], // 数据列表
  73. badgeOffset: [0, -5],
  74. mescroll: null
  75. }
  76. },
  77. // async onLoad() {
  78. // that = this
  79. // // #ifdef APP-PLUS
  80. // let _status = await that.$request.baseRequest('get', '/driverInfo/firstAuthentication', {
  81. // driverPhone: this.userInfo.phone,
  82. // }).then(res => {
  83. // return res.data.authenticationStatus
  84. // })
  85. // // if (_status == '已禁用') {
  86. // // this.isShowAlert = true
  87. // // this.alertTitle == '账号审核中'
  88. // // this.confirmText = '退出APP'
  89. // // this.showCancelButton = false
  90. // // } else {
  91. // // console.log(1231233212332312312213)
  92. // // }
  93. // // #endif
  94. // },
  95. onShow() {
  96. uni.setTabBarItem({
  97. index: 0,
  98. text: '货源',
  99. iconPath: 'static/images/common/huoyuan@2x(1).png',
  100. selectedIconPath: 'static/images/common/huoyuan@2x.png'
  101. })
  102. uni.setTabBarItem({
  103. index: 2,
  104. text: '订单',
  105. iconPath: 'static/images/common/dingdan@2x(1).png',
  106. selectedIconPath: 'static/images/common/dingdan@2x.png'
  107. })
  108. this.newsNumber()
  109. this.upCallback({
  110. size: 10,
  111. num: 1
  112. })
  113. },
  114. computed: {
  115. ...mapState(['hasLogin', 'userInfo', 'firstAuthentication'])
  116. },
  117. methods: {
  118. newsNumber() {
  119. let that = this
  120. that.$request.baseRequest('get', '/newsInfo/unreadMessage', {
  121. reCommonId: this.userInfo.id,
  122. }).then(res3 => {
  123. if (res3.data || res3.data == 0) {
  124. let name = 'myTip';
  125. let value = res3.data
  126. if (value == 0) {
  127. uni.removeTabBarBadge({
  128. index: 3
  129. })
  130. }
  131. that.$store.commit('$uStore', {
  132. name,
  133. value
  134. });
  135. if (value != 0 && value) {
  136. uni.setTabBarBadge({
  137. index: 3,
  138. text: value + ""
  139. })
  140. }
  141. that.$forceUpdate()
  142. }
  143. })
  144. },
  145. confirmClick() {
  146. // #ifdef APP-PLUS
  147. if (this.alertTitle == '账号审核中') {
  148. if (uni.getSystemInfoSync().platform == 'ios') {
  149. plus.ios.import("UIApplication").sharedApplication().performSelector("exit")
  150. } else if (uni.getSystemInfoSync().platform == 'android') {
  151. plus.runtime.quit();
  152. }
  153. return
  154. }
  155. // #endif
  156. },
  157. rightClick() {
  158. uni.showLoading({
  159. title: '加载中',
  160. mask: true
  161. })
  162. this.$request.baseRequest('post', '/newsInfo/api/editAllNewsInfo', {
  163. reCommonId: this.userInfo.id,
  164. }).then(res => {
  165. this.mescroll.resetUpScroll()
  166. uni.hideLoading()
  167. uni.removeTabBarBadge({
  168. index: 2
  169. })
  170. this.newsNumber() //消息气泡
  171. })
  172. .catch(res => {
  173. uni.hideLoading()
  174. uni.$u.toast(res.message);
  175. });
  176. },
  177. read(val) {
  178. uni.$u.route("/pages/news/newsSee?_obj=" + JSON.stringify(val))
  179. uni.showLoading({
  180. title: '加载中',
  181. mask: true
  182. })
  183. this.$request.baseRequest('post', '/newsInfo/api/editNewsInfo', {
  184. id: val.id,
  185. }).then(res => {
  186. this.mescroll.resetUpScroll()
  187. this.look()
  188. uni.hideLoading()
  189. this.newsNumber() //查询消息气泡
  190. })
  191. .catch(res => {
  192. uni.hideLoading()
  193. uni.$u.toast(res.message);
  194. });
  195. },
  196. look() {
  197. let that = this
  198. that.$request.baseRequest('get', '/newsInfo/unreadMessage', {
  199. reCommonId: this.userInfo.id,
  200. }).then(res3 => {
  201. if (res3.data || res3.data == 0) {
  202. let name = 'myTip';
  203. let value = res3.data
  204. if (value == 0) {
  205. uni.removeTabBarBadge({
  206. index: 3
  207. })
  208. }
  209. that.$store.commit('$uStore', {
  210. name,
  211. value
  212. });
  213. if (value != 0 && value) {
  214. uni.setTabBarBadge({
  215. index: 3,
  216. text: value + ""
  217. })
  218. }
  219. }
  220. })
  221. },
  222. back() {
  223. uni.navigateBack({
  224. })
  225. },
  226. mescrollInit(mescroll) {
  227. this.mescroll = mescroll;
  228. },
  229. downCallback() {
  230. // 第2种: 下拉刷新和上拉加载调同样的接口, 则不用第1种, 直接mescroll.resetUpScroll()即可
  231. // 重置列表为第一页 (自动执行 page.num=1, 再触发upCallback方法 )
  232. this.mescroll.resetUpScroll()
  233. },
  234. /*上拉加载的回调: 其中page.num:当前页 从1开始, page.size:每页数据条数,默认10 */
  235. upCallback(page) {
  236. console.log(page)
  237. // 此处可以继续请求其他接口
  238. if (page.num == 1) {
  239. this.news = []
  240. // 请求其他接口...
  241. }
  242. // 如果希望先请求其他接口,再触发upCallback,可参考以下写法
  243. // if(!this.isInitxx){
  244. // apiGetxx().then(res=>{
  245. // this.isInitxx = true
  246. // this.mescroll.resetUpScroll() // 重新触发upCallback
  247. // }).catch(()=>{
  248. // this.mescroll.endErr()
  249. // })
  250. // return // 此处return,先获取xx
  251. // }
  252. //联网加载数据
  253. this.$request.baseRequest('get', '/newsInfo/selectNewsInfo', {
  254. reCommonId: this.userInfo.id,
  255. pageSize: page.size,
  256. currentPage: page.num,
  257. }).then(res => {
  258. if (page.num == 1) {
  259. this.news = []
  260. }
  261. this.news = this.news.concat(res.data.records); //追加新数据
  262. this.$forceUpdate()
  263. this.mescroll.endBySize(res.data.records.length, res.data.total);
  264. })
  265. .catch(res => {
  266. uni.$u.toast(res.message);
  267. });
  268. }
  269. }
  270. }
  271. </script>
  272. <style lang="scss" scoped>
  273. /deep/.u-navbar__content__right__text {
  274. font-size: 26rpx;
  275. color: #FFFFFF;
  276. }
  277. /deep/.point1 {
  278. text-overflow: ellipsis;
  279. overflow: hidden;
  280. /* white-space: nowrap; */
  281. display: -webkit-box;
  282. -webkit-line-clamp: 1;
  283. -webkit-box-orient: vertical;
  284. text-overflow: ellipsis;
  285. margin-top: 20rpx;
  286. }
  287. .top-bgc {
  288. position: absolute;
  289. width: 100%;
  290. height: 519rpx;
  291. // background: linear-gradient(180deg, #317AFE 0%, #F8F9FC 100%);
  292. }
  293. .content {
  294. // position: relative;
  295. // top: 0;
  296. background: #FFFFFF;
  297. margin: 20rpx;
  298. width: calc(100% - 40rpx);
  299. // padding: 20rpx;
  300. box-sizing: border-box;
  301. border-radius: 20rpx;
  302. padding-top: 30rpx;
  303. }
  304. .info-item {
  305. padding: 20rpx 30rpx 30rpx 30rpx;
  306. .img {
  307. width: 80rpx;
  308. height: 80rpx;
  309. margin-top: 20rpx;
  310. }
  311. .left {
  312. margin-right: 20rpx;
  313. }
  314. .right {
  315. width: 100%;
  316. border-bottom: 1px solid #E6E6E6;
  317. padding-bottom: 20rpx;
  318. .row1 {
  319. .title {
  320. font-size: 32rpx;
  321. color: #000000;
  322. font-weight: 600;
  323. }
  324. .time {
  325. font-size: 32rpx;
  326. color: #999999;
  327. }
  328. }
  329. .row2 {
  330. .text {
  331. font-size: 28rpx;
  332. color: #999999;
  333. width: 500rpx;
  334. }
  335. .red-point {
  336. width: 10rpx;
  337. height: 10rpx;
  338. background: #EE2F51;
  339. border-radius: 6rpx;
  340. margin-right: 20rpx;
  341. }
  342. }
  343. }
  344. }
  345. </style>