index.vue 8.6 KB

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