index.vue 7.6 KB

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