This commit is contained in:
shuhongfan
2023-09-04 16:40:17 +08:00
commit cf5ac25c14
8267 changed files with 1305066 additions and 0 deletions

View File

@@ -0,0 +1,181 @@
<template>
<view class="dateBox uniPopup">
<view class="item">
<!-- 由于需求改动这块日期展示效果先不用 -->
<!-- <view class="date" @change="handleDate">
<icon class="dateIcon"></icon>
<text>{{ getNow(dates) }}</text>
<icon class="next"></icon>
</view> -->
<uni-datetime-picker type="date" :clear-icon="false" @change="handleDate">
<view class="date">
<icon class="dateIcon"></icon>
<text>{{ dates }}</text>
<icon class="next"></icon>
</view>
</uni-datetime-picker>
</view>
<view class="item" :class="isTmClick ? 'red' : ''" @click="hanleDay(0)">
<text :class="!isToday ? 'gray' : ''">明天</text>
</view>
<view class="item" :class="isAtClick ? 'red' : ''" @click="hanleDay(1)">
<text :class="!isToday ? 'gray' : ''">后天</text>
</view>
<!-- 由于需求改动这块日期展示效果先不用 -->
<!-- <view class="datePopupBox">
<uni-popup ref="popup" type="bottom" background-color="#fff">
<view class="popup-content">
<view class="tit">
<view @click="handleCancel('bottom')">取消</view>
<view>选择开始日期</view>
<view @click="handleComplete">完成</view>
</view>
<view class="date-select">
<picker-view class="picker-view" :value="defaultValue" :indicator-style="indicatorStyle" @change="bindChange">
<picker-view-column>
<view class="item" v-for="(item, index) in monthData.value" :key="index">
<text @click="handleGetNow(index)">{{ getNow(item) }}</text>
</view>
</picker-view-column>
</picker-view>
</view>
</view>
</uni-popup>
</view> -->
</view>
</template>
<script setup>
import { ref, reactive, onMounted, watch } from 'vue';
import { useStore } from 'vuex';
// 获取封装好的方法
import { getTate, getNow, getDay, afterTomorrowDay, tomorrowDay, getMonthDay } from '@/utils/index.js';
// ------定义变量------
const store = useStore(); //vuex获取、储存数据
const users = store.state.user;
const emit = defineEmits();
const popup = ref(); //定义弹层ref
let dates = ref(); //当前日期
let isPreExceed = ref(false); //触发前一天是否超过30天
let isNextExceed = ref(false); //触发后一天是否超过30天
const monthData = reactive([]); //时间数组
const indicatorStyle = ref(`height: 100rpx;`);
let defaultValue = ref([0]); //时间默认选择为数组第一个值
let times = ref(null); //触发的事件选择
let dateTime = ref(null); //时间选择筛选
// let isTomorrow = ref(false); //是否触发了明天、后台按钮,用来判断日期弹层是否要显示当前日期,如果触发了今天、后天,那么弹层显示的时候应该显示当前的日期
// 监听触发前一天、后一天按钮向前后者向后超过当前日期30天的日期按钮置灰
let isToday = ref(true); //如果是当天,明天后天可以触发
// let dayArr = reactive(['明天', '后天']);
let isActive = ref(null); //定义明后天的当前样式
const isTmClick = ref(false); //触发明天
const isAtClick = ref(false);//触发后天
watch(dates, (newValue, oldValue) => {
isToday.value = getNow(newValue) === getNow(new Date());
const obj = getMonthDay(newValue);
// 前一天按钮置灰
if (obj.timeNow === obj.timeStar) {
isPreExceed.value = true;
}
// 后一天按钮置灰
if (obj.timeNow === obj.timeEnd) {
isNextExceed.value = true;
}
// 弹层选择的时间和当前时间显示一致
monthData.value.map((val, index) => {
if (getTate(obj.timeNow) === val) {
defaultValue.value = [index];
}
});
// 传递当前筛选的时间
if (users.timeData) {
emit('getDateTime', getTate(users.timeData));
dates.value = users.timeData;
} else {
emit('getDateTime', getTate(obj.timeNow));
}
});
// ------生命周期------
onMounted(() => {
dates.value = getTate(new Date()); //获取当前日期
monthData.value = getDay(); //获取当月的所有日期
});
// ------定义方法------
// 触发今天、明天
const hanleDay = index => {
if (isToday.value) {
if (index === 0) {
isAtClick.value = false
isTmClick.value =!isTmClick.value
store.commit('user/setTimeData', tomorrowDay());
emit('getDateTime', getTate(tomorrowDay()));
if (!isTmClick.value) {
store.commit('user/setTimeData', getTate(new Date()));
emit('getDateTime', getTate(getTate(new Date())));
}
// isTomorrow.value = true;
} else {
isTmClick.value = false
isAtClick.value =!isAtClick.value
store.commit('user/setTimeData', afterTomorrowDay());
emit('getDateTime', getTate(afterTomorrowDay()));
if (!isAtClick.value) {
store.commit('user/setTimeData', getTate(new Date()));
emit('getDateTime', getTate(getTate(new Date())));
}
// isTomorrow.value = true;
}
}
};
// 时间弹层
const handleDate = type => {
times.value = type;
handleComplete();
// // 由于需求改动,以日历形式展现,以下先不用
// if (isTomorrow.value) {
// monthData.value.map((val, index) => {
// if (getTate(new Date()) === val) {
// defaultValue.value = [index];
// }
// });
// }
// isTomorrow.value = false;
// popup.value.open(type);
};
// // 由于需求改动,以日历形式展现,以下先不用
// // 选择时间
// const bindChange = e => {
// // 时间筛选
// times.value = monthData.value[e.detail.value[0]];
// };
// 完成
const handleComplete = () => {
// 清除明后天当前样式
isActive.value = null;
if (times.value === dates.value) {
isToday.value = true;
} else {
isToday.value = false;
}
if (times.value !== null) {
dates.value = times.value;
store.commit('user/setTimeData', times.value);
handleCancel();
} else {
uni.showToast({
title: '请选择日期',
icon: 'none'
});
}
};
// // 由于需求改动,以日历形式展现,以下先不用
// const handleGetNow = num => {
// times.value = monthData.value[num];
// };
// 关闭弹层
const handleCancel = () => {
popup.value.close();
};
</script>

View File

@@ -0,0 +1,131 @@
<template>
<!-- 列表内容 -->
<view v-for="(item, index) in itemData" :key="index" class="expressage">
<view class="boxBg">
<view class="tabList">
<view class="item" @click.stop="handleDetails($event, item)">
<view v-if="item.status !== 1" class="history">
<view class="titInfo" v-if="item.transportOrderId !== null"
>运单号{{ item.transportOrderId }}</view
>
<view class="address">收件人{{ item.name }}</view>
<view class="address">派件地址{{ item.address }}</view>
<view class="address">签收时间{{ item.actualEndTime }}</view>
<view class="time" v-if="item.status === 2"
>运费{{ item.amount }}</view
>
</view>
<view v-else class="history">
<view class="titInfo">
<view>
<text class="name">{{ item.name }}</text>
{{ item.phone }}
<!-- TODO拨打电话和发信息小图标暂时保留 -->
<!-- <icon class="phone" @click.stop="handlePhone($event, item.phone)"></icon>
<icon class="note" @click.stop="handleNote"></icon> -->
</view>
</view>
<view class="address">{{ item.address }}</view>
<view class="address">{{ item.distance }}公里</view>
<view class="time" v-if="item.transportOrderId !== null"
>运单号{{ item.transportOrderId }}</view
>
</view>
<text
@click.stop="handleDetails($event, item)"
class="delete"
v-if="item.status === 1"
><button class="uni-btn btn-default">去派件</button></text
>
<text
@click.stop="handleDetails($event, item)"
class="delete"
v-else-if="
item.status === 2 &&
item.paymentStatus === 1 &&
item.paymentMethod === 2 &&
item.signStatus !== 2
"
><button class="uni-btn btn-default">去收款</button></text
>
<text @click.stop="handleOpen($event, item.id)" class="delete" v-else
><button class="uni-btn concelBtn">删除</button></text
>
</view>
</view>
</view>
</view>
<!-- end -->
</template>
<script setup>
import { useStore } from "vuex";
// 获取父组件数据
const props = defineProps({
// 数据
itemData: {
type: Array,
default: () => [],
},
// 当前触发的tab值
tabIndex: {
type: Number,
default: 0,
},
});
// ------定义变量------
const store = useStore(); //vuex获取、储存数据
const users = store.state.user;
const emit = defineEmits(""); //子组件向父组件事件传递
// ------定义方法------
// 删除弹层
const handleOpen = (e, id) => {
// 阻止事件冒泡
e.stopPropagation();
emit("handleOpen", id);
};
// 去派件详情
const handleDetails = (e, item) => {
// 阻止事件冒泡
e.stopPropagation();
// 把任务id用vuex的方法存储方便其他页面调用
store.commit("user/setTaskId", item.id);
// 由于取件详情地址和派件详情地址样式一致,所以用类型 1取件2派件区分开
store.commit("user/setTaskType", 2);
store.commit("user/setDetailType", 2); //从历史订单他跳入订单详情
// 进入详情页
if (item.status === 1) {
// 已取件\已取消\去派件\已签收\详情页用的是一个,所以用类型status声明 1:待取件2:已取件,3:已取消,4:待派件,5:已签收
// 用vuex保存状态,因为当从详情页返回列表页的时候要显示对应的tab列表项
store.commit("user/setTaskStatus", 6);
uni.redirectTo({
url: "/pages/details/waybill",
});
} else if (
item.status === 2 &&
item.paymentStatus === 1 &&
item.paymentMethod === 2 &&
item.signStatus !== 2
) {
store.commit("user/setIsDelivery", true);
store.commit("user/setTaskStatus", 6);
// 未付款进入付款二维码页面
store.commit("user/setPayData", {});
uni.redirectTo({
url: "/pages/pay/scanPay",
});
} else {
// 已取件\已取消\去派件\已签收\详情页用的是一个,所以用类型status声明 1:待取件2:已取件,3:已取消,4:待派件,5:已签收
// 用vuex保存状态,因为当从详情页返回列表页的时候要显示对应的tab列表项
store.commit("user/setTaskStatus", 6);
// 已经完成的进入订单详情页
uni.redirectTo({
url: "/pages/details/waybill",
});
}
};
</script>

View File

@@ -0,0 +1,208 @@
<template>
<view class="pageBox">
<!-- tab切换 -->
<UniTab
:tabBars="tabBars"
ref="tab"
@getTabIndex="getTabIndex"
class="historyTab"
></UniTab>
<!-- end -->
<view class="homeSwiper historyboxTop">
<view v-if="itemData.length > 0">
<scroll-view scroll-y="true">
<!-- 取件 -->
<view v-if="tabIndex === 0"
><Pickup :itemData="itemData" @handleOpen="handleOpen"></Pickup
></view>
<!-- end -->
<!-- 派件 -->
<view v-else
><Delivery :itemData="itemData" @handleOpen="handleOpen"></Delivery
></view>
<!-- end -->
<!-- 上拉 -->
<ReachBottom ref="loadMore"></ReachBottom>
<!-- end -->
</scroll-view>
<!-- 空页面 -->
</view>
<view v-else><EmptyPage :emptyData="emptyData"></EmptyPage></view>
<!-- end -->
</view>
<!-- end -->
</view>
<!-- 提示窗 -->
<UniPopup
ref="popup"
:tipInfo="tipInfo"
@handleClick="handleClick"
></UniPopup>
<!-- end -->
</template>
<script setup>
import { ref, reactive, onMounted, watch } from "vue";
import { onReachBottom } from "@dcloudio/uni-app";
import { useStore } from "vuex";
import { getTimeDate} from '@/utils/index.js';
// 基本数据
import { HistoryTabData } from "@/utils/commonData.js";
//接口
import { getDeliveryList, taskDelete } from "@/pages/api/index.js";
// tab切换
import UniTab from "@/components/uni-tab/index.vue";
// 弹层
import UniPopup from "@/components/uni-popup/index.vue";
// 下拉提示
import ReachBottom from "@/components/reach-bottom/index.vue";
//空页面
import EmptyPage from "@/components/uni-empty-page/index.vue";
// 取件
import Pickup from "./pickup.vue";
// 派件
import Delivery from "./delivery.vue";
// 获取父组件数据
const props = defineProps({
// 筛选时间
dateTime: {
type: String,
default: "",
},
});
// ------定义变量------
const store = useStore(); //vuex获取、储存数据
const users = store.state.user;
const emit = defineEmits(""); //子组件向父组件事件传递
let popup = ref();
const tipInfo = ref("确认删除该订单吗?");
const tabBars = HistoryTabData;//tab标签数据
let taskId = ref(""); //任务id
let tabIndex = ref(0); //当前tab
const loadMore = ref(); //定义子组件的ref,可以调取子组件的值
let itemData = ref([]);//列表数据
let reload = ref(false); //是否加载
let pages = ref(0); //总页数
let pageNum = users.isFiltrate ? 1 : ref(1); //存放当前页
const emptyData = ref("暂无数据");
let isPullDown = ref(false); //是否下拉了
let page = reactive({
latitude: users.loacation.latitude !== undefined ? users.loacation.latitude : 40.062595,
longitude: users.loacation.longitude !== undefined ? users.loacation.longitude : 116.372809,
page: 1,
pageSize: 10,
taskType: 1,
});
watch(props, (newValue, oldValue) => {
// 存储清空列表数据
store.commit("user/setDeliveryData", []);
getList(newValue.dateTime);
});
// 监听tab切换
watch(tabIndex, (newValue, oldValue) => {
if (newValue === 0) {
page.taskType = 1;
} else {
page.taskType = 2;
}
// 存储清空列表数据
store.commit("user/setDeliveryData", []);
// 根据不同的tab值切更新 取件数据
getList(page.dateTime);
});
// ------生命周期------
onMounted(() => {
if (users.tabIndex) {
tabIndex.value = users.tabIndex;
}
});
// 上下拉取
onReachBottom(() => {
if (pageNum.value >= Number(pages.value)) {
loadMore.value.status = "noMore";
return false;
} else {
loadMore.value.status = "loading";
let times = setTimeout(() => {
pageNum.value++;
getList(page.dateTime);
}, 1000); //这里延时一秒在加载方法有个loading效果
}
});
// ------定义方法------
// 获取数据
const getList = async (time) => {
reload.value = true;
//判断是否进行了距离、时间、超时任务筛选如果是当前页设为第一页上拉的数值设为1便于第二次上拉
page = {
...page,
dateTime: (getTimeDate(time)).veryDayDate,
page: pageNum.value,
};
await getDeliveryList(page).then((res) => {
if (res.code === 200) {
if (res.data) {
reload.value = false;
if (users.deliveryData.length === 0) {
itemData.value = [];
}
if (users.istabChange) {
itemData.value = res.data.items;
store.commit("user/setIstabChange", false);
} else {
itemData.value = itemData.value.concat(res.data.items);
}
pages.value = res.data.pages;
// 存储列表数据
store.commit("user/setDeliveryData", itemData.value);
if (Number(res.data.pages) === pageNum.value) {
loadMore.value.status = "noMore";
}
} else {
itemData.value = [];
}
}
});
};
// 获取tab切换当前的index
const getTabIndex = (index) => {
store.commit("user/setTabIndex", 0);
store.commit("user/setIstabChange", true);
pageNum.value = 1;
pages.value = 1;
tabIndex.value = index;
itemData.value = [];
store.commit("user/setDeliveryData", []);
};
// 确认删除
const handleClick = async () => {
await taskDelete(taskId.value).then((res) => {
if (res.code === 200) {
store.commit("user/setDeliveryData", []);
getList(page.dateTime);
isPullDown.value = true;
return uni.showToast({
title: "删除成功!",
duration: 1000,
icon: "none",
});
}
});
};
// 删除弹层
const handleOpen = (id) => {
popup.value.dialogOpen();
taskId.value = id;
};
// 触发选项卡事件
const onChangeSwiperTab = (e) => {
changeTab(e.detail.current);
};
//把数据、方法暴漏给父组件
defineExpose({
getList,
});
</script>

View File

@@ -0,0 +1,125 @@
<template>
<!-- 列表内容 -->
<view v-for="(item, index) in itemData" :key="index" class="expressage">
<view class="boxBg">
<view class="tabList">
<view class="item" @click.stop="handleDetails($event, item)">
<view v-if="item.status !== 1" class="history">
<view class="titInfo">订单号SD{{ item.orderId }}</view>
<view class="address">寄件人{{ item.name }}</view>
<view class="address">取件地址{{ item.address }}</view>
<view class="address">取件时间{{ item.actualEndTime }}</view>
<view class="time" v-if="item.status === 2"
>运费{{ item.amount }}</view
>
</view>
<view v-else class="history">
<view class="titInfo">
<view>
<text class="name">{{ item.name }}</text>
{{ item.phone }}
<!-- TODO拨打电话和发信息小图标暂时保留 -->
<!-- <icon class="phone" @click.stop="handlePhone($event, item.phone)"></icon>
<icon class="note" @click.stop="handleNote"></icon> -->
</view>
</view>
<view class="address">{{ item.address }}</view>
<view class="address">{{ item.distance }}公里</view>
<view class="time"
>预约取件时间{{ taskTimeFormat(item.estimatedStartTime) }}
{{ overTimeFormat(item.estimatedEndTime) }}</view
>
</view>
<text
@click.stop="handleDetails($event, item)"
class="delete"
v-if="item.status === 1"
><button class="uni-btn btn-default">去取件</button></text
>
<text
@click.stop="handleDetails($event, item)"
class="delete"
v-else-if="
item.status === 2 &&
item.paymentStatus === 1 &&
item.paymentMethod === 1
"
><button class="uni-btn btn-default">去收款</button></text
>
<text @click.stop="handleOpen($event, item.id)" class="delete" v-else
><button class="uni-btn concelBtn">删除</button></text
>
</view>
</view>
</view>
</view>
<!-- end -->
</template>
<script setup>
import { onMounted } from "vue";
import { taskTimeFormat, overTimeFormat } from "@/utils/index.js";
import { useStore } from "vuex";
// 获取父组件数据
const props = defineProps({
// 数据
itemData: {
type: Array,
default: () => [],
},
// 当前触发的tab值
tabIndex: {
type: Number,
default: 0,
},
});
// ------定义变量------
const store = useStore(); //vuex获取、储存数据
const users = store.state.user;
const emit = defineEmits(""); //子组件向父组件事件传递
// ------生命周期------
onMounted(() => {});
// ------定义方法------
// 删除弹层
const handleOpen = (e, id) => {
// 阻止事件冒泡
e.stopPropagation();
emit("handleOpen", id);
};
// 去取件详情
const handleDetails = (e, item) => {
// 阻止事件冒泡
e.stopPropagation();
// 把任务id用vuex的方法存储方便其他页面调用
store.commit("user/setTaskId", item.id);
// 由于取件详情地址和派件详情地址样式一致,所以用类型 1取件2派件区分开
store.commit("user/setTaskType", 1);
// 已取件\已取消\去派件\已签收\详情页用的是一个,所以用类型status声明 1:待取件2:已取件,3:已取消,4:待派件,5:已签收
// 用vuex保存状态,因为当从详情页返回列表页的时候要显示对应的tab列表项
store.commit("user/setTaskStatus", 6);
store.commit("user/setDetailType", 1); //从历史订单他跳入订单详情
// 如果时带取件进入到去取件页面
// 进入详情页
if (item.status === 1) {
uni.redirectTo({
url: "/pages/details/index",
});
} else if (
item.status === 2 &&
item.paymentStatus === 1 &&
item.paymentMethod === 1
) {
// 未付款进入付款二维码页面
store.commit("user/setPayData", {});
uni.redirectTo({
url: "/pages/pay/scanPay",
});
} else {
// 已经完成的进入订单详情页
uni.redirectTo({
url: "/pages/details/waybill",
});
}
};
</script>