index.vue 8.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342
  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.newsContent}}
  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(), 5000)"
  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. var that = this
  100. that.$request.baseRequest('get', '/newsInfo/unreadMessage', {
  101. reCommonId: this.userInfo.id,
  102. }).then(res3 => {
  103. if (res3.data || res3.data == 0) {
  104. let name = 'myTip';
  105. let value = res3.data
  106. if (value == 0) {
  107. uni.removeTabBarBadge({
  108. index: 2
  109. })
  110. }
  111. that.$store.commit('$uStore', {
  112. name,
  113. value
  114. });
  115. if (value != 0 && value) {
  116. uni.setTabBarBadge({
  117. index: 2,
  118. text: value + ""
  119. })
  120. }
  121. }
  122. })
  123. this.$request.baseRequest('get', '/newsInfo/selectNewsInfo', {
  124. reCommonId: this.userInfo.id,
  125. pageSize: 10,
  126. currentPage: 1,
  127. }).then(res => {
  128. this.news = res.data.records //追加新数据
  129. })
  130. .catch(res => {});
  131. // this.mescroll.resetUpScroll()
  132. },
  133. computed: {
  134. ...mapState(['hasLogin', 'userInfo', 'firstAuthentication'])
  135. },
  136. methods: {
  137. confirmClick() {
  138. // #ifdef APP-PLUS
  139. if (this.alertTitle = '账号审核中') {
  140. if (uni.getSystemInfoSync().platform == 'ios') {
  141. plus.ios.import("UIApplication").sharedApplication().performSelector("exit")
  142. } else if (uni.getSystemInfoSync().platform == 'android') {
  143. plus.runtime.quit();
  144. }
  145. return
  146. }
  147. // #endif
  148. },
  149. cancelClick() {
  150. this.isShowAlert = false
  151. },
  152. rightClick() {
  153. uni.showLoading({
  154. title: '加载中',
  155. mask: true
  156. })
  157. this.$request.baseRequest('post', '/newsInfo/api/editAllNewsInfo', {
  158. reCommonId: this.userInfo.id,
  159. }).then(res => {
  160. this.mescroll.resetUpScroll()
  161. uni.hideLoading()
  162. uni.removeTabBarBadge({
  163. index: 2
  164. })
  165. })
  166. .catch(res => {
  167. uni.$u.toast(res.message);
  168. });
  169. },
  170. read(val) {
  171. let that = this
  172. if (val.newsType == "投诉结果" || val.newsType == "举报结果") {
  173. uni.$u.route("/pages/news/feedbackResults?id=" + val.bussId + "&type=" + val.newsType)
  174. } else {
  175. uni.$u.route("/pages/news/newsSee?_obj=" + JSON.stringify(val))
  176. }
  177. uni.showLoading({
  178. title: '加载中',
  179. mask: true
  180. })
  181. that.$request.baseRequest('post', '/newsInfo/api/editNewsInfo', {
  182. id: val.id,
  183. }).then(res => {
  184. that.mescroll.resetUpScroll()
  185. that.look()
  186. uni.hideLoading()
  187. })
  188. .catch(res => {
  189. uni.$u.toast(res.message);
  190. });
  191. },
  192. look() {
  193. let that = this
  194. that.$request.baseRequest('get', '/newsInfo/unreadMessage', {
  195. reCommonId: this.userInfo.id,
  196. }).then(res3 => {
  197. if (res3.data || res3.data == 0) {
  198. let name = 'myTip';
  199. let value = res3.data
  200. if (value == 0) {
  201. uni.removeTabBarBadge({
  202. index: 2
  203. })
  204. }
  205. that.$store.commit('$uStore', {
  206. name,
  207. value
  208. });
  209. if (value != 0 && value) {
  210. uni.setTabBarBadge({
  211. index: 2,
  212. text: value + ""
  213. })
  214. }
  215. }
  216. })
  217. },
  218. back() {
  219. uni.navigateBack({
  220. })
  221. },
  222. mescrollInit(mescroll) {
  223. this.mescroll = mescroll;
  224. },
  225. /*上拉加载的回调: 其中page.num:当前页 从1开始, page.size:每页数据条数,默认10 */
  226. upCallback(page) {
  227. // 此处可以继续请求其他接口
  228. // if(page.num == 1){
  229. // // 请求其他接口...
  230. // }
  231. // 如果希望先请求其他接口,再触发upCallback,可参考以下写法
  232. // if(!this.isInitxx){
  233. // apiGetxx().then(res=>{
  234. // this.isInitxx = true
  235. // this.mescroll.resetUpScroll() // 重新触发upCallback
  236. // }).catch(()=>{
  237. // this.mescroll.endErr()
  238. // })
  239. // return // 此处return,先获取xx
  240. // }
  241. //联网加载数据
  242. this.$request.baseRequest('get', '/newsInfo/selectNewsInfo', {
  243. reCommonId: this.userInfo.id,
  244. pageSize: page.size,
  245. currentPage: page.num,
  246. }).then(res => {
  247. if (page.num == 1) {
  248. this.news = []; //追加新数据
  249. }
  250. this.news = this.news.concat(res.data.records); //追加新数据
  251. this.mescroll.endBySize(res.data.records.length, res.data.total);
  252. })
  253. .catch(res => {
  254. uni.$u.toast(res.message);
  255. });
  256. }
  257. }
  258. }
  259. </script>
  260. <style lang="scss">
  261. /deep/.u-navbar__content__right__text {
  262. font-size: 26rpx;
  263. color: #FFFFFF;
  264. }
  265. .top-bgc {
  266. position: absolute;
  267. width: 100%;
  268. height: 519rpx;
  269. // background: linear-gradient(180deg, #317AFE 0%, #F8F9FC 100%);
  270. }
  271. .content {
  272. // position: relative;
  273. // top: 0;
  274. background: #FFFFFF;
  275. margin: 20rpx;
  276. width: calc(100% - 40rpx);
  277. // padding: 20rpx;
  278. box-sizing: border-box;
  279. border-radius: 20rpx;
  280. padding-top: 30rpx;
  281. }
  282. .info-item {
  283. padding: 0 30rpx 30rpx 30rpx;
  284. .img {
  285. width: 80rpx;
  286. height: 80rpx;
  287. }
  288. .left {
  289. margin-right: 20rpx;
  290. }
  291. .right {
  292. width: 100%;
  293. border-bottom: 1px solid #E6E6E6;
  294. padding-bottom: 20rpx;
  295. .row1 {
  296. .title {
  297. font-size: 32rpx;
  298. color: #000000;
  299. }
  300. .time {
  301. font-size: 32rpx;
  302. color: #999999;
  303. }
  304. }
  305. .row2 {
  306. .text {
  307. font-size: 28rpx;
  308. color: #999999;
  309. width: 500rpx;
  310. }
  311. .red-point {
  312. width: 10rpx;
  313. height: 10rpx;
  314. background: #EE2F51;
  315. border-radius: 6rpx;
  316. margin-right: 20rpx;
  317. }
  318. }
  319. }
  320. }
  321. </style>