index.vue 8.0 KB

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