init
This commit is contained in:
@@ -0,0 +1,92 @@
|
||||
<template>
|
||||
<view v-if="tabIndex === 0">
|
||||
<!-- 垂直滚动区域 scroll和swiper的高度都要给且是一样的高度-->
|
||||
<scroll-view scroll-y="true">
|
||||
<view v-if="newItemData.length > 0">
|
||||
<view class="boxCon">
|
||||
<view class="tabConList">
|
||||
<view
|
||||
class="item"
|
||||
v-for="(item, index) in newItemData"
|
||||
:key="index"
|
||||
>
|
||||
<view @click="handleClick(item)">
|
||||
<text class="text active">
|
||||
{{ item.title }}
|
||||
</text>
|
||||
<text class="time">{{ taskTimeFormat(item.created) }}</text>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
<!-- 暂时先不做,后期做 -->
|
||||
<!-- <ReachBottom v-if="loading" :loadingText="loadingText"></ReachBottom> -->
|
||||
</view>
|
||||
|
||||
<!-- 无数据显示 -->
|
||||
<view v-else><EmptyPage :emptyData="emptyData"></EmptyPage></view>
|
||||
<!-- end -->
|
||||
</scroll-view>
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import { ref, onMounted } from "vue";
|
||||
import { taskTimeFormat } from "@/utils/index.js";
|
||||
// 公告数据
|
||||
import { newItemData } from "@/utils/commonData.js";
|
||||
// 接口api
|
||||
import { getNewList } from "@/pages/api/news.js";
|
||||
// 导入组件
|
||||
//空页面
|
||||
import EmptyPage from "@/components/uni-empty-page/index.vue";
|
||||
// 下拉提示
|
||||
import ReachBottom from "@/components/reach-bottom/index.vue";
|
||||
// ------定义变量------
|
||||
let loadingText = ref("");
|
||||
let loading = ref(false);
|
||||
// 获取父组件数据
|
||||
const props = defineProps({
|
||||
// 当前触发的tab值
|
||||
tabIndex: {
|
||||
type: Number,
|
||||
default: 0,
|
||||
},
|
||||
});
|
||||
// ------定义变量------
|
||||
const emit = defineEmits("handleSearch"); //子组件向父组件事件传递
|
||||
// ------生命周期------
|
||||
onMounted(() => {
|
||||
// init();
|
||||
});
|
||||
// ------定义方法------
|
||||
const init = () => {
|
||||
// TODO 暂时不做此功能数据先写死
|
||||
// getList();
|
||||
};
|
||||
// 获取公告列表
|
||||
const getList = async () => {
|
||||
await getNewList("300")
|
||||
.then((res) => {
|
||||
if (res.code === 200) {
|
||||
itemData.value = res.data;
|
||||
}
|
||||
})
|
||||
.catch((err) => {
|
||||
return uni.showToast({
|
||||
title: err.msg,
|
||||
duration: 1000,
|
||||
icon: "none",
|
||||
});
|
||||
});
|
||||
};
|
||||
const handleClick = async (item) => {
|
||||
uni.navigateTo({
|
||||
url: "/pages/news/detail?obj=" + JSON.stringify(item),
|
||||
});
|
||||
};
|
||||
//把数据、方法暴漏给父组件
|
||||
defineExpose({
|
||||
getList,
|
||||
});
|
||||
</script>
|
||||
@@ -0,0 +1,149 @@
|
||||
<template>
|
||||
<view v-if="tabIndex === 1">
|
||||
<scroll-view scroll-y="true">
|
||||
<view>
|
||||
<view class="boxCon">
|
||||
<view class="newConBox">
|
||||
<view class="item">
|
||||
<navigator
|
||||
:url="'/pages/news/system?title=取件相关&type=' + 301"
|
||||
open-type="redirect"
|
||||
>
|
||||
<view
|
||||
class="icon send"
|
||||
:class="objData.haveNewSendNotice ? 'active' : ''"
|
||||
><icon></icon
|
||||
></view>
|
||||
<view class="text">
|
||||
<view>取件相关</view>
|
||||
<view>{{
|
||||
objData.newSendNoticeTime
|
||||
? "您有一个新的取件订单"
|
||||
: "暂无消息"
|
||||
}}</view>
|
||||
</view>
|
||||
<text class="time" v-if="objData.newSendNoticeTime">{{
|
||||
taskTimeFormat(objData.newSendNoticeTime)
|
||||
}}</text>
|
||||
</navigator>
|
||||
</view>
|
||||
<view class="item">
|
||||
<navigator
|
||||
:url="'/pages/news/system?title=派件相关&type=' + 304"
|
||||
open-type="redirect"
|
||||
>
|
||||
<view
|
||||
class="icon delivery"
|
||||
:class="objData.haveNewDispatchNotice ? 'active' : ''"
|
||||
><icon></icon
|
||||
></view>
|
||||
<view class="text">
|
||||
<view>派件相关</view>
|
||||
<view>{{
|
||||
objData.newDispatchNoticeTime
|
||||
? "您有一个新的派件订单"
|
||||
: "暂无消息"
|
||||
}}</view>
|
||||
</view>
|
||||
<text class="time" v-if="objData.newDispatchNoticeTime">{{
|
||||
taskTimeFormat(objData.newDispatchNoticeTime)
|
||||
}}</text>
|
||||
</navigator>
|
||||
</view>
|
||||
<view class="item">
|
||||
<navigator
|
||||
:url="'/pages/news/system?title=签收提醒&type=' + 302"
|
||||
open-type="redirect"
|
||||
>
|
||||
<view
|
||||
class="icon income"
|
||||
:class="objData.haveNewReceiveNotice ? 'active' : ''"
|
||||
><icon></icon
|
||||
></view>
|
||||
<view class="text">
|
||||
<view>签收提醒</view>
|
||||
<view>{{
|
||||
objData.newReceiveNoticeTime
|
||||
? "您有一个派件已签收"
|
||||
: "暂无消息"
|
||||
}}</view>
|
||||
</view>
|
||||
<text class="time" v-if="objData.newReceiveNoticeTime">{{
|
||||
taskTimeFormat(objData.newReceiveNoticeTime)
|
||||
}}</text>
|
||||
</navigator>
|
||||
</view>
|
||||
<view class="item">
|
||||
<navigator
|
||||
:url="'/pages/news/system?title=快件取消&type=' + 303"
|
||||
open-type="redirect"
|
||||
>
|
||||
<view
|
||||
class="icon cancel"
|
||||
:class="objData.haveNewCancelNotice ? 'active' : ''"
|
||||
><icon></icon
|
||||
></view>
|
||||
<view class="text">
|
||||
<view>快件取消</view>
|
||||
<view>{{
|
||||
objData.newCancelNoticeTime
|
||||
? "您有一个快件已取消"
|
||||
: "暂无消息"
|
||||
}}</view>
|
||||
</view>
|
||||
<text class="time" v-if="objData.newCancelNoticeTime">{{
|
||||
taskTimeFormat(objData.newCancelNoticeTime)
|
||||
}}</text>
|
||||
</navigator>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</scroll-view>
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import { ref, onMounted } from "vue";
|
||||
import { taskTimeFormat } from "@/utils/index.js";
|
||||
// 接口api
|
||||
import { getNotice } from "@/pages/api/news.js";
|
||||
// 导入组件
|
||||
// ------定义变量------
|
||||
let objData = ref({}); //列表数据
|
||||
// 获取父组件数据
|
||||
const props = defineProps({
|
||||
// 当前触发的tab值
|
||||
tabIndex: {
|
||||
type: Number,
|
||||
default: 1,
|
||||
},
|
||||
});
|
||||
// ------定义变量------
|
||||
const emit = defineEmits("getTabIndex"); //子组件向父组件事件传递
|
||||
// ------生命周期------
|
||||
onMounted(() => {
|
||||
getOjb();
|
||||
});
|
||||
// ------定义方法------
|
||||
// 获取系统通知
|
||||
const getOjb = async () => {
|
||||
await getNotice()
|
||||
.then((res) => {
|
||||
if (res.code === 200) {
|
||||
objData.value = res.data;
|
||||
}
|
||||
})
|
||||
.catch((err) => {
|
||||
return uni.showToast({
|
||||
title: err.msg,
|
||||
duration: 1000,
|
||||
icon: "none",
|
||||
});
|
||||
});
|
||||
};
|
||||
//把数据、方法暴漏给父组件
|
||||
defineExpose({
|
||||
getOjb,
|
||||
});
|
||||
</script>
|
||||
68
project-wl-kuaidiyuan-uniapp-vue3/pages/news/detail.vue
Normal file
68
project-wl-kuaidiyuan-uniapp-vue3/pages/news/detail.vue
Normal file
@@ -0,0 +1,68 @@
|
||||
<!-- 公告详情页 -->
|
||||
<template>
|
||||
<!-- 自定义头部 -->
|
||||
<view class="navHead"><UniNav :title="title" @goBack="goBack"></UniNav></view>
|
||||
<!-- end -->
|
||||
<!-- 列表 -->
|
||||
<view class="pageBox newDetail">
|
||||
<view class="tit">{{ objData.title }}</view>
|
||||
<view class="time">{{ taskTimeFormat(objData.created) }}</view>
|
||||
<view v-if="objData.firstContent" class="first">{{
|
||||
objData.firstContent
|
||||
}}</view>
|
||||
<view>{{ objData.content }}</view>
|
||||
</view>
|
||||
<!-- end -->
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import { ref } from "vue";
|
||||
import { taskTimeFormat } from "@/utils/index.js";
|
||||
// 导入组件
|
||||
// 导航组件
|
||||
import UniNav from "@/components/uni-nav/index.vue";
|
||||
|
||||
// ------定义变量------
|
||||
const title = ref("详情"); //nav标题
|
||||
const pages = getCurrentPages(); //获取加载的页面,获取当前页面路由信息uniapp 做安卓不支持 vue-router
|
||||
const currentPage = pages[pages.length - 1]; //获取当前页面的对象
|
||||
let objData = ref(JSON.parse(currentPage.$page.options.obj)); //基本数据 获取列表页传过来的详情页,此页没有详情接口
|
||||
// ------定义方法------
|
||||
|
||||
// 返回上一页
|
||||
const goBack = () => {
|
||||
uni.redirectTo({
|
||||
url: "/pages/news/index",
|
||||
});
|
||||
};
|
||||
</script>
|
||||
<style lang="scss" scoped>
|
||||
body,
|
||||
uni-page-body,
|
||||
uni-page-head,
|
||||
.uni-page-head {
|
||||
background-color: #fff !important;
|
||||
}
|
||||
.pageBox {
|
||||
box-shadow: inset 0 22rpx 22rpx 0 rgba(162, 162, 162, 0.06);
|
||||
}
|
||||
.newDetail {
|
||||
padding: 60rpx 32rpx;
|
||||
color: var(--neutral-color-font);
|
||||
line-height: 48rpx;
|
||||
font-size: var(--font-size-13);
|
||||
.tit {
|
||||
line-height: 60rpx;
|
||||
font-size: var(--font-size-16);
|
||||
color: var(--neutral-color-main);
|
||||
font-weight: 600;
|
||||
}
|
||||
.time {
|
||||
font-size: var(--font-size-12);
|
||||
padding: 4rpx 0 28rpx;
|
||||
}
|
||||
.first {
|
||||
padding: 15rpx 0 40rpx;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
124
project-wl-kuaidiyuan-uniapp-vue3/pages/news/index.scss
Normal file
124
project-wl-kuaidiyuan-uniapp-vue3/pages/news/index.scss
Normal file
@@ -0,0 +1,124 @@
|
||||
body,
|
||||
uni-page-body {
|
||||
background: var(--neutral-color-background) !important;
|
||||
}
|
||||
.newBox {
|
||||
.tabScroll {
|
||||
margin-bottom: 32rpx;
|
||||
background: var(--neutral-color-white);
|
||||
::v-deep .uni-scroll-view-content {
|
||||
font-size: var(--font-size-14) !important;
|
||||
.scroll-row-item {
|
||||
flex: 1;
|
||||
text-align: center;
|
||||
margin-right: 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
::v-deep .newConBox {
|
||||
.item {
|
||||
line-height: 40rpx;
|
||||
padding: 0 28rpx;
|
||||
|
||||
|
||||
color: var(--neutral-color-font);
|
||||
position: relative;
|
||||
font-size: var(--font-size-12);
|
||||
.navigator-wrap{
|
||||
uni-navigator{
|
||||
display: flex;
|
||||
align-items: center;
|
||||
}
|
||||
}
|
||||
.text {
|
||||
white-space: nowrap;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
flex: 1;
|
||||
padding: 32rpx 0 28rpx;
|
||||
border-bottom: 1px solid var(--neutral-color-background);
|
||||
view{
|
||||
&:first-child{
|
||||
color: var(--neutral-color-main);
|
||||
font-size: var(--font-size-14);
|
||||
padding-bottom: 4rpx;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
.icon {
|
||||
width: 64rpx;
|
||||
height: 64rpx;
|
||||
margin-right: 36rpx;
|
||||
position: relative;
|
||||
&.send {
|
||||
background: url(@/static/icon17.png);
|
||||
background-size: contain;
|
||||
}
|
||||
&.delivery {
|
||||
background: url(@/static/icon27.png);
|
||||
background-size: contain;
|
||||
}
|
||||
&.income {
|
||||
background: url(@/static/icon18.png);
|
||||
background-size: contain;
|
||||
|
||||
}
|
||||
&.cancel {
|
||||
background: url(@/static/icon19.png);
|
||||
background-size: contain;
|
||||
}
|
||||
&.active {
|
||||
color: var(--neutral-color-main);
|
||||
icon {
|
||||
position: absolute;
|
||||
right: -14rpx;
|
||||
top: 2rpx;
|
||||
width: 14rpx;
|
||||
height: 14rpx;
|
||||
border-radius: 50%;
|
||||
margin-right: 12rpx;
|
||||
background: var(--essential-color-red);
|
||||
}
|
||||
}
|
||||
}
|
||||
.time{
|
||||
position: absolute;
|
||||
top: 32rpx;
|
||||
right: 44rpx;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
// 详情
|
||||
|
||||
// 系统列表
|
||||
.systemList{
|
||||
.item{
|
||||
padding:30rpx 32rpx;
|
||||
color: var(--neutral-color-font);
|
||||
line-height: 52rpx;
|
||||
margin-top: 40rpx;
|
||||
.tit{
|
||||
line-height: 40rpx;
|
||||
padding-bottom: 30rpx;
|
||||
color: var(--neutral-color-main);
|
||||
border-bottom: 1px solid var(--neutral-color-background);
|
||||
margin-bottom: 22rpx;
|
||||
font-weight: 600;
|
||||
}
|
||||
.time{
|
||||
display: flex;
|
||||
align-items: center;
|
||||
text{
|
||||
flex:1
|
||||
}
|
||||
.redBtn{
|
||||
display: inline-block;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
105
project-wl-kuaidiyuan-uniapp-vue3/pages/news/index.vue
Normal file
105
project-wl-kuaidiyuan-uniapp-vue3/pages/news/index.vue
Normal file
@@ -0,0 +1,105 @@
|
||||
<!-- 消息列表页 -->
|
||||
<template>
|
||||
<!-- 自定义头部 -->
|
||||
<view class="navHead">
|
||||
<UniNav :title="title" @goBack="goBack"></UniNav>
|
||||
</view>
|
||||
<!-- end -->
|
||||
|
||||
<!-- 列表 -->
|
||||
<view class="pageBox newBox">
|
||||
<!-- 搜索列表 -->
|
||||
<scroll-view
|
||||
scroll-x="true"
|
||||
class="tabScroll"
|
||||
:scroll-into-view="scrollinto"
|
||||
:scroll-with-animation="true"
|
||||
>
|
||||
<view
|
||||
v-for="(item, index) in tabBars"
|
||||
:key="index"
|
||||
:id="'tab' + index"
|
||||
class="scroll-row-item"
|
||||
@click="changeTab(index)"
|
||||
>
|
||||
<view :class="tabIndex == index ? 'scroll-row-item-act' : ''">
|
||||
<text class="line"></text>
|
||||
{{ item }}
|
||||
</view>
|
||||
</view>
|
||||
</scroll-view>
|
||||
<view class="homeSwiper">
|
||||
<!-- 公告 -->
|
||||
<Announcement ref="announcement" :tabIndex="tabIndex"></Announcement>
|
||||
<!-- end -->
|
||||
<!-- 系统通知 -->
|
||||
<Notification
|
||||
ref="notificat"
|
||||
@getTabIndex="getTabIndex"
|
||||
:tabIndex="tabIndex"
|
||||
></Notification>
|
||||
<!-- end -->
|
||||
</view>
|
||||
<!-- end -->
|
||||
</view>
|
||||
<!-- end -->
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import { ref, reactive } from "vue";
|
||||
import { useStore } from "vuex";
|
||||
// 导入组件
|
||||
// 导航组件
|
||||
import UniNav from "@/components/uni-nav/index.vue";
|
||||
// 公告列表
|
||||
import Announcement from "./components/announcement.vue";
|
||||
// 系统通知
|
||||
import Notification from "./components/notification.vue";
|
||||
// ------定义变量------
|
||||
const store = useStore(); //vuex获取、储存数据
|
||||
const users = store.state.user;
|
||||
const announcement = ref(); //定义ref
|
||||
const notificat = ref();
|
||||
const title = ref("消息"); //nav标题
|
||||
const tabBars = reactive(["公告", "系统通知"]);
|
||||
let scrollinto = ref("tab0"); //tab切换
|
||||
let tabIndex = users.tabIndex === 1 ? ref(1) : ref(0); //当前tab
|
||||
// ------定义方法------
|
||||
// tab选项卡切换轮播
|
||||
const changeTab = (index) => {
|
||||
// 点击的还是当前数据的时候直接return
|
||||
if (tabIndex.value == index) {
|
||||
return;
|
||||
}
|
||||
// 触发tab切换接口
|
||||
if (index === 0) {
|
||||
// 当前tab值为0刷新公告列表
|
||||
// announcement.value.getList()
|
||||
} else {
|
||||
// 当前tab值为1刷新系统通知
|
||||
notificat.value.getOjb();
|
||||
}
|
||||
tabIndex.value = index;
|
||||
store.commit("user/setTabIndex", index);
|
||||
// 滑动
|
||||
scrollinto.value = "tab" + index;
|
||||
};
|
||||
|
||||
// 触发选项卡事件
|
||||
const onChangeSwiperTab = (e) => {
|
||||
changeTab(e.detail.current);
|
||||
};
|
||||
// 获取子组件传来的tabindex
|
||||
const getTabIndex = (val) => {
|
||||
tabIndex.value = val;
|
||||
};
|
||||
// 返回上一页
|
||||
const goBack = () => {
|
||||
uni.redirectTo({
|
||||
url: "/pages/index/index",
|
||||
});
|
||||
store.commit("user/setNewType", null);
|
||||
};
|
||||
</script>
|
||||
|
||||
<style src="./index.scss" lang="scss" scoped></style>
|
||||
231
project-wl-kuaidiyuan-uniapp-vue3/pages/news/system.vue
Normal file
231
project-wl-kuaidiyuan-uniapp-vue3/pages/news/system.vue
Normal file
@@ -0,0 +1,231 @@
|
||||
<!-- 系统通知列表页 取件相关、签收提醒、快件取消 -->
|
||||
<template>
|
||||
<!-- 自定义头部 -->
|
||||
<view class="navHead">
|
||||
<UniNav
|
||||
:title="title"
|
||||
@goBack="goBack"
|
||||
@handleAll="handleAll"
|
||||
:rithtText="rithtText"
|
||||
></UniNav>
|
||||
</view>
|
||||
<!-- end -->
|
||||
<!-- 列表 -->
|
||||
<view class="pageBox newBox">
|
||||
<scroll-view
|
||||
scroll-y="true"
|
||||
:style="{ height: scrollH + 'px' }"
|
||||
v-if="itemData.length > 0"
|
||||
>
|
||||
<view class="systemList">
|
||||
<view class="boxBg item" v-for="(item, index) in itemData" :key="index">
|
||||
<view class="tit" :class="item.isRead === 0 ? 'active' : ''">
|
||||
<icon></icon>
|
||||
<text v-if="title === '取件相关'">您有一个新的取件订单</text>
|
||||
<text v-else-if="title === '派件相关'">您有一个新的派件订单</text>
|
||||
<text v-else-if="title === '签收提醒'">您有一个派件已签收</text>
|
||||
<text v-else>您有一个快件已取消</text>
|
||||
</view>
|
||||
<view class="address">{{ item.content }}</view>
|
||||
<view class="time">
|
||||
<text>{{ taskTimeFormat(item.created) }}</text>
|
||||
<button class="uni-btn redBtn" @click="handleDetail(item)">
|
||||
查看详情
|
||||
</button>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
<ReachBottom ref="loadMore"></ReachBottom>
|
||||
</scroll-view>
|
||||
<view v-else><EmptyPage :emptyData="emptyData"></EmptyPage></view>
|
||||
</view>
|
||||
<!-- end -->
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import { ref, reactive, onMounted } from "vue";
|
||||
import { onReachBottom } from "@dcloudio/uni-app";
|
||||
import { taskTimeFormat } from "@/utils/index.js";
|
||||
import { useStore } from "vuex";
|
||||
// 接口 api
|
||||
import { getMessagesList, msgRead, msgAllRead } from "@/pages/api/news.js";
|
||||
// 导入组件
|
||||
// 导航组件
|
||||
import UniNav from "@/components/uni-nav/index.vue";
|
||||
//空页面
|
||||
import EmptyPage from "@/components/uni-empty-page/index.vue";
|
||||
// 下拉提示
|
||||
import ReachBottom from "@/components/reach-bottom/index.vue";
|
||||
// ------定义变量------
|
||||
const store = useStore(); //vuex获取、储存数据
|
||||
const users = store.state.user;
|
||||
const pages = getCurrentPages(); //获取加载的页面,获取当前页面路由信息uniapp 做安卓不支持 vue-router
|
||||
const currentPage = pages[pages.length - 1].$page.options; //获取当前页面的对象
|
||||
const title = currentPage.title; //nav标题
|
||||
const type = currentPage.type; //当前派件类型
|
||||
const loadMore = ref(); //定义子组件的ref,可以调取子组件的值
|
||||
const emptyData = ref("暂无消息");
|
||||
const rithtText = ref("全部已读");
|
||||
let pageNumber = ref(1);
|
||||
|
||||
let totals = ref(0); //总页数
|
||||
let pageNum = ref(1); //存放当前页
|
||||
let page = reactive({
|
||||
contentType: type,
|
||||
page: 1,
|
||||
pageSize: 10,
|
||||
});
|
||||
let reload = ref(false);
|
||||
let scrollH = ref(null); //滚动高度
|
||||
let isReadAll = ref(false); //是否已全读
|
||||
let itemData = ref([]);
|
||||
let ids = ref([]);
|
||||
// 上下拉取
|
||||
onReachBottom(() => {
|
||||
if (pageNum.value >= Number(totals.value)) {
|
||||
loadMore.value.status = "noMore";
|
||||
return false;
|
||||
} else {
|
||||
loadMore.value.status = "loading";
|
||||
let times = setTimeout(() => {
|
||||
pageNum.value++;
|
||||
getList();
|
||||
}, 1000); //这里延时一秒在加载方法有个loading效果
|
||||
}
|
||||
});
|
||||
|
||||
// ------生命周期------
|
||||
onMounted(() => {
|
||||
// // 调用接口
|
||||
getList();
|
||||
// 获取屏幕信息
|
||||
uni.getSystemInfo({
|
||||
success: (res) => {
|
||||
scrollH.value = res.windowHeight - uni.upx2px();
|
||||
},
|
||||
});
|
||||
});
|
||||
//
|
||||
// ------定义方法------
|
||||
// 获取列表
|
||||
const getList = async () => {
|
||||
reload.value = true;
|
||||
page = {
|
||||
...page,
|
||||
page: pageNum.value,
|
||||
};
|
||||
await getMessagesList(page).then((res) => {
|
||||
if (res.code === 200) {
|
||||
if (res.data) {
|
||||
reload.value = false;
|
||||
itemData.value = itemData.value.concat(res.data.items);
|
||||
itemData.value.map((val) => {
|
||||
if (val.isRead === 0) {
|
||||
ids.value.push(val.id);
|
||||
}
|
||||
});
|
||||
|
||||
totals.value = res.data.pages;
|
||||
// 存储列表数据
|
||||
if (Number(res.data.pages) === pageNum.value) {
|
||||
loadMore.value.status = "noMore";
|
||||
}
|
||||
} else {
|
||||
itemData.value = [];
|
||||
}
|
||||
}
|
||||
});
|
||||
};
|
||||
// 进入详情,标记已读
|
||||
const handleDetail = async (item) => {
|
||||
// 把任务id用vuex的方法存储,方便其他页面调用
|
||||
store.commit("user/setTaskId", item.relevantId);
|
||||
store.commit("user/setTabIndex", 0);
|
||||
ids.value = [];
|
||||
ids.value.push(item.id);
|
||||
// 进入详情前先调用已读信息接口
|
||||
await msgRead(item.id).then((res) => {});
|
||||
|
||||
if (title === "取件相关") {
|
||||
// 方便从详情跳回列表页
|
||||
store.commit("user/setNewType", 301);
|
||||
if (item.status === 1) {
|
||||
uni.navigateTo({
|
||||
url: "/pages/details/index",
|
||||
});
|
||||
} else {
|
||||
uni.navigateTo({
|
||||
url: "/pages/details/waybill",
|
||||
});
|
||||
store.commit("user/setIsNew", true);
|
||||
}
|
||||
} else if (title === "派件相关") {
|
||||
if (item.status === 2) {
|
||||
store.commit("user/setTaskStatus", 5);
|
||||
store.commit("user/setIsNew", true);
|
||||
} else {
|
||||
store.commit("user/setTaskStatus", 4);
|
||||
}
|
||||
store.commit("user/setNewType", 304);
|
||||
uni.navigateTo({
|
||||
url: "/pages/details/waybill",
|
||||
});
|
||||
} else if (title === "签收提醒") {
|
||||
store.commit("user/setTaskStatus", 5);
|
||||
store.commit("user/setNewType", 302);
|
||||
uni.navigateTo({
|
||||
url: "/pages/details/waybill",
|
||||
});
|
||||
store.commit("user/setIsNew", true);
|
||||
} else {
|
||||
store.commit("user/setTaskStatus", null);
|
||||
store.commit("user/setNewType", 303);
|
||||
uni.navigateTo({
|
||||
url: "/pages/details/waybill",
|
||||
});
|
||||
}
|
||||
};
|
||||
// 全部已读
|
||||
const handleAll = async () => {
|
||||
let contentType = null;
|
||||
if (title === "取件相关") {
|
||||
contentType = 301;
|
||||
} else if (title === "派件相关") {
|
||||
contentType = 304;
|
||||
} else if (title === "签收提醒") {
|
||||
contentType = 302;
|
||||
} else {
|
||||
contentType = 303;
|
||||
}
|
||||
await msgAllRead(contentType)
|
||||
.then((res) => {
|
||||
itemData.value = [];
|
||||
pageNum.value = 1;
|
||||
getList();
|
||||
})
|
||||
.catch((err) => {
|
||||
isReadAll.value = true;
|
||||
return uni.showToast({
|
||||
title: err.msg,
|
||||
duration: 1000,
|
||||
icon: "none",
|
||||
});
|
||||
});
|
||||
};
|
||||
// 返回上一页
|
||||
const goBack = () => {
|
||||
store.commit("user/setTabIndex", 1);
|
||||
if (users.taskStatus === -1) {
|
||||
uni.redirectTo({
|
||||
url: "/pages/index/index",
|
||||
});
|
||||
} else {
|
||||
uni.redirectTo({
|
||||
url: "/pages/news/index",
|
||||
});
|
||||
}
|
||||
store.commit("user/setTaskStatus", 0);
|
||||
};
|
||||
</script>
|
||||
|
||||
<style src="./index.scss" lang="scss" scoped></style>
|
||||
Reference in New Issue
Block a user