123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351 |
- <template>
- <view>
- <u-navbar title="消息中心" leftIconSize='0' :bgColor="bgColor" :placeholder='true' leftIconColor="#fff"
- titleStyle='color:#fff' rightText='一键已读' @rightClick="rightClick">
- </u-navbar>
- <!-- <view class="top-bgc"></view> -->
- <mescroll-body ref="mescrollRef" @init="mescrollInit" @down="downCallback" @up="upCallback"
- style="background-color: #fff;">
- <view class="content" v-if="news.length!=0">
- <view class="info-item flex" v-for="(item,index) in news" :key="index" @click="read(item)">
- <view class="left">
- <image src="@/static/images/news/cy.png" class="img" v-if="item.newsType=='承运通知'">
- </image>
- <image src="@/static/images/news/xt.png" class="img" v-else>
- </image>
- </view>
- <view class="right" :style="{'border-bottom':index==news.length-1?'1px solid #fff':'1px solid #e6e6e6'}">
- <view class="row1 flex flex-space-between">
- <view class="title">
- {{item.newsType}}
- </view>
- <view class="time">
- {{item.createDate}}
- </view>
- </view>
- <view class="row2 flex flex-space-between align-center">
- <view style='white-space: pre-wrap;' class="text point">
- {{item.newsTitle}}
- </view>
- <view class="red-point" v-if="item.newsFlag==0"></view>
- </view>
- </view>
- <!-- <view class="flex flex-space-between">
- <view class="left">
- <view>系统消息</view>
- <u-badge :isDot="true" bgColor='red' :absolute='true' :offset='badgeOffset'></u-badge>
- </view>
- <view class="">
- 今天 21:51
- </view>
- </view>
- <view class="flex flex-space-between">
- 您的驾驶证即将到期,请尽快到“我的-身份认证”中更新,逾期将影响运费支付。
- </view> -->
- </view>
- <u-modal :show="isShowAlert" :title="alertTitle" :content='alertContent' :confirmText='confirmText'
- :closeOnClickOverlay='true' :showCancelButton='showCancelButton' @confirm="$u.throttle(confirmClick(), 1000)"
- @close="cancelClick" @cancel="cancelClick" class="modal">
- </u-modal>
- </view>
- </mescroll-body>
- </view>
- </template>
- <script>
- var that
- import MescrollMixin from "@/uni_modules/mescroll-uni/components/mescroll-uni/mescroll-mixins.js";
- import {
- mapState
- } from 'vuex';
- export default {
- mixins: [MescrollMixin], // 使用mixin
- data() {
- return {
- confirmText: '',
- showCancelButton: true,
- alertTitle: '',
- alertContent: "",
- isShowAlert: false,
- showCancelButton: true,
- src: 'https://cdn.uviewui.com/uview/album/1.jpg',
- bgColor: '#F5BA3C',
- value: 100,
- news: [], // 数据列表
- badgeOffset: [0, -5],
- mescroll: null
- }
- },
- // async onLoad() {
- // that = this
- // // #ifdef APP-PLUS
- // let _status = await that.$request.baseRequest('get', '/cargoOwnerInfo/firstAuthentication', {
- // phone: this.userInfo.phone,
- // }).then(res => {
- // return res.data.authenticationStatus
- // })
- // if (_status == '已禁用') {
- // this.isShowAlert = true
- // this.alertTitle = '账号审核中'
- // this.confirmText = '退出APP'
- // this.showCancelButton = false
- // } else {
- // console.log(1231233212332312312213)
- // }
- // // #endif
- // },
- onLoad() {
- },
- onShow() {
- uni.setTabBarItem({
- index: 0,
- text: '订单',
- iconPath: 'static/images/common/dingdan@2x(1).png',
- selectedIconPath: 'static/images/common/dingdan@2x.png'
- })
- var that = this
- that.$request.baseRequest('get', '/newsInfo/unreadMessage', {
- reCommonId: this.userInfo.id,
- }).then(res3 => {
- if (res3.data || res3.data == 0) {
- let name = 'myTip';
- let value = res3.data
- if (value == 0) {
- uni.removeTabBarBadge({
- index: 2
- })
- }
- that.$store.commit('$uStore', {
- name,
- value
- });
- if (value != 0 && value) {
- uni.setTabBarBadge({
- index: 2,
- text: value + ""
- })
- }
- }
- })
- this.$request.baseRequest('get', '/newsInfo/selectNewsInfo', {
- reCommonId: this.userInfo.id,
- pageSize: 10,
- currentPage: 1,
- }).then(res => {
- this.news = res.data.records //追加新数据
- })
- .catch(res => {});
- // this.mescroll.resetUpScroll()
- },
- computed: {
- ...mapState(['hasLogin', 'userInfo', 'firstAuthentication'])
- },
- methods: {
- confirmClick() {
- // #ifdef APP-PLUS
- if (this.alertTitle = '账号审核中') {
- if (uni.getSystemInfoSync().platform == 'ios') {
- plus.ios.import("UIApplication").sharedApplication().performSelector("exit")
- } else if (uni.getSystemInfoSync().platform == 'android') {
- plus.runtime.quit();
- }
- return
- }
- // #endif
- },
- cancelClick() {
- this.isShowAlert = false
- },
- rightClick() {
- uni.showLoading({
- title: '加载中',
- mask: true
- })
- this.$request.baseRequest('post', '/newsInfo/api/editAllNewsInfo', {
- reCommonId: this.userInfo.id,
- }).then(res => {
- this.mescroll.resetUpScroll()
- uni.hideLoading()
- uni.removeTabBarBadge({
- index: 2
- })
- })
- .catch(res => {
- uni.hideLoading()
- uni.$u.toast(res.message);
- });
- },
- read(val) {
- let that = this
- if (val.newsType == "投诉结果" || val.newsType == "举报结果") {
- uni.$u.route("/pages/news/feedbackResults?id=" + val.bussId + "&type=" + val.newsType)
- } else {
- uni.$u.route("/pages/news/newsSee?_obj=" + JSON.stringify(val))
- }
- uni.showLoading({
- title: '加载中',
- mask: true
- })
- that.$request.baseRequest('post', '/newsInfo/api/editNewsInfo', {
- id: val.id,
- }).then(res => {
- uni.hideLoading()
- that.mescroll.resetUpScroll()
- that.look()
- uni.hideLoading()
- })
- .catch(res => {
- uni.hideLoading()
- uni.$u.toast(res.message);
- });
- },
- look() {
- let that = this
- that.$request.baseRequest('get', '/newsInfo/unreadMessage', {
- reCommonId: this.userInfo.id,
- }).then(res3 => {
- if (res3.data || res3.data == 0) {
- let name = 'myTip';
- let value = res3.data
- if (value == 0) {
- uni.removeTabBarBadge({
- index: 2
- })
- }
- that.$store.commit('$uStore', {
- name,
- value
- });
- if (value != 0 && value) {
- uni.setTabBarBadge({
- index: 2,
- text: value + ""
- })
- }
- }
- })
- },
- back() {
- uni.navigateBack({
- })
- },
- mescrollInit(mescroll) {
- this.mescroll = mescroll;
- },
- /*上拉加载的回调: 其中page.num:当前页 从1开始, page.size:每页数据条数,默认10 */
- upCallback(page) {
- // 此处可以继续请求其他接口
- // if(page.num == 1){
- // // 请求其他接口...
- // }
- // 如果希望先请求其他接口,再触发upCallback,可参考以下写法
- // if(!this.isInitxx){
- // apiGetxx().then(res=>{
- // this.isInitxx = true
- // this.mescroll.resetUpScroll() // 重新触发upCallback
- // }).catch(()=>{
- // this.mescroll.endErr()
- // })
- // return // 此处return,先获取xx
- // }
- //联网加载数据
- this.$request.baseRequest('get', '/newsInfo/selectNewsInfo', {
- reCommonId: this.userInfo.id,
- pageSize: page.size,
- currentPage: page.num,
- }).then(res => {
- if (page.num == 1) {
- this.news = []; //追加新数据
- }
- this.news = this.news.concat(res.data.records); //追加新数据
- this.mescroll.endBySize(res.data.records.length, res.data.total);
- })
- .catch(res => {
- uni.$u.toast(res.message);
- });
- }
- }
- }
- </script>
- <style lang="scss">
- /deep/.u-navbar__content__right__text {
- font-size: 26rpx;
- color: #FFFFFF;
- }
- .top-bgc {
- position: absolute;
- width: 100%;
- height: 519rpx;
- // background: linear-gradient(180deg, #F5BA3C 0%, #F8F9FC 100%);
- }
- .content {
- // position: relative;
- // top: 0;
- background: #FFFFFF;
- margin: 20rpx;
- width: calc(100% - 40rpx);
- // padding: 20rpx;
- box-sizing: border-box;
- border-radius: 20rpx;
- padding-top: 30rpx;
- }
- .info-item {
- padding: 0 30rpx 30rpx 30rpx;
- .img {
- width: 80rpx;
- height: 80rpx;
- }
- .left {
- margin-right: 20rpx;
- }
- .right {
- width: 100%;
- border-bottom: 1px solid #E6E6E6;
- padding-bottom: 20rpx;
- .row1 {
- .title {
- font-size: 32rpx;
- color: #000000;
- }
- .time {
- font-size: 32rpx;
- color: #999999;
- }
- }
- .row2 {
- .text {
- font-size: 28rpx;
- color: #999999;
- width: 500rpx;
- }
- .red-point {
- width: 10rpx;
- height: 10rpx;
- background: #EE2F51;
- border-radius: 6rpx;
- margin-right: 20rpx;
- }
- }
- }
- }
- </style>
|