index.vue 8.0 KB

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