index.vue 8.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339
  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. console.log(122232)
  99. that.$request.baseRequest('get', '/newsInfo/unreadMessage', {
  100. reCommonId: this.userInfo.id,
  101. }).then(res3 => {
  102. if (res3.data) {
  103. let name = 'myTip';
  104. let value = res3.data
  105. if (value == 0) {
  106. uni.removeTabBarBadge({
  107. index: 2
  108. })
  109. }
  110. that.$store.commit('$uStore', {
  111. name,
  112. value
  113. });
  114. if (value != 0 && value) {
  115. uni.setTabBarBadge({
  116. index: 2,
  117. text: value + ""
  118. })
  119. }
  120. }
  121. })
  122. this.$request.baseRequest('get', '/newsInfo/selectNewsInfo', {
  123. reCommonId: this.userInfo.id,
  124. pageSize: 10,
  125. currentPage: 1,
  126. }).then(res => {
  127. this.news = res.data.records //追加新数据
  128. })
  129. .catch(res => {
  130. uni.$u.toast(res.message);
  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. if (value == 0) {
  198. uni.removeTabBarBadge({
  199. index: 2
  200. })
  201. }
  202. that.$store.commit('$uStore', {
  203. name,
  204. value
  205. });
  206. if (value != 0 && value) {
  207. uni.setTabBarBadge({
  208. index: 2,
  209. text: value + ""
  210. })
  211. }
  212. }
  213. })
  214. },
  215. back() {
  216. uni.navigateBack({
  217. })
  218. },
  219. mescrollInit(mescroll) {
  220. this.mescroll = mescroll;
  221. },
  222. /*上拉加载的回调: 其中page.num:当前页 从1开始, page.size:每页数据条数,默认10 */
  223. upCallback(page) {
  224. // 此处可以继续请求其他接口
  225. // if(page.num == 1){
  226. // // 请求其他接口...
  227. // }
  228. // 如果希望先请求其他接口,再触发upCallback,可参考以下写法
  229. // if(!this.isInitxx){
  230. // apiGetxx().then(res=>{
  231. // this.isInitxx = true
  232. // this.mescroll.resetUpScroll() // 重新触发upCallback
  233. // }).catch(()=>{
  234. // this.mescroll.endErr()
  235. // })
  236. // return // 此处return,先获取xx
  237. // }
  238. //联网加载数据
  239. this.$request.baseRequest('get', '/newsInfo/selectNewsInfo', {
  240. reCommonId: this.userInfo.id,
  241. pageSize: page.size,
  242. currentPage: page.num,
  243. }).then(res => {
  244. if(page.num == 1){
  245. this.news = []; //追加新数据
  246. }
  247. this.news = this.news.concat(res.data.records); //追加新数据
  248. this.mescroll.endBySize(res.data.records.length, res.data.total);
  249. })
  250. .catch(res => {
  251. uni.$u.toast(res.message);
  252. });
  253. }
  254. }
  255. }
  256. </script>
  257. <style lang="scss">
  258. /deep/.u-navbar__content__right__text {
  259. font-size: 26rpx;
  260. color: #FFFFFF;
  261. }
  262. .top-bgc {
  263. position: absolute;
  264. width: 100%;
  265. height: 519rpx;
  266. // background: linear-gradient(180deg, #317AFE 0%, #F8F9FC 100%);
  267. }
  268. .content {
  269. // position: relative;
  270. // top: 0;
  271. background: #FFFFFF;
  272. margin: 20rpx;
  273. width: calc(100% - 40rpx);
  274. // padding: 20rpx;
  275. box-sizing: border-box;
  276. border-radius: 20rpx;
  277. padding-top: 30rpx;
  278. }
  279. .info-item {
  280. padding: 0 30rpx 30rpx 30rpx;
  281. .img {
  282. width: 80rpx;
  283. height: 80rpx;
  284. }
  285. .left {
  286. margin-right: 20rpx;
  287. }
  288. .right {
  289. width: 100%;
  290. border-bottom: 1px solid #E6E6E6;
  291. padding-bottom: 20rpx;
  292. .row1 {
  293. .title {
  294. font-size: 32rpx;
  295. color: #000000;
  296. }
  297. .time {
  298. font-size: 32rpx;
  299. color: #999999;
  300. }
  301. }
  302. .row2 {
  303. .text {
  304. font-size: 28rpx;
  305. color: #999999;
  306. width: 500rpx;
  307. }
  308. .red-point {
  309. width: 10rpx;
  310. height: 10rpx;
  311. background: #EE2F51;
  312. border-radius: 6rpx;
  313. margin-right: 20rpx;
  314. }
  315. }
  316. }
  317. }
  318. </style>