chuangte_bike_newxcx/pages/myorder/index.vue
2026-01-28 18:00:39 +08:00

655 lines
17 KiB
Vue

<template>
<view class="page">
<u-navbar title="订单列表" :border-bottom="false" :background="bgc" back-icon-color="#262B37" title-color='#262B37'
title-size='36' height='36' id="navbar">
</u-navbar>
<view class="topbj"></view>
<view class="navtab" v-if="activeindex == 2">
<view class="zctab">
申请退还押金
<image src="https://api.ccttiot.com/smartmeter/img/static/uwzdktgeyR4JgzgUeOOd" mode=""></image>
<text></text>
</view>
<view class="qxtab" @click="btnac(1)">
我的订单
<image src="https://api.ccttiot.com/smartmeter/img/static/uSsQmBFEejLf0rHSDJFw" mode=""></image>
</view>
</view>
<view class="navtab" v-else>
<view class="zctabs" @click="btnac(2)">
申请退还押金
<image src="https://api.ccttiot.com/smartmeter/img/static/uduOC3zyhXDBftRcCA77" mode=""></image>
</view>
<view class="qxtabs">
我的订单
<image src="https://api.ccttiot.com/smartmeter/img/static/uQ4WOC2D9wPq93sPNQTW" mode=""></image>
<text></text>
</view>
</view>
<u-tabs v-if="activeindex != 2" :list="lists" :is-scroll="false" :current="currents" inactive-color="#89bdef" @change="changes"></u-tabs>
<!-- 申请退还押金列表 -->
<scroll-view class="zuchelist" v-if="activeindex == 2" @scrolltolower="handleScrollToLower" scroll-y refresher-enabled @refresherrefresh="onRefresh" :refresher-triggered="isRefreshing" refresher-default-style="black">
<view class="zuchelist_item" v-for="(item,index) in depositList" :key="index" @click="btnDepositDetail(item.id)">
<view class="top">
{{item.no || '--'}} <text :style="{fontSize: '30rpx', fontWeight: '600', color: getStatusColor(item.status)}">{{getStatusText(item.status)}}</text>
</view>
<view class="quche">
<text style="font-size: 32rpx;font-weight: 600;">申请金额</text> <text style="font-weight: 600;color: #4297F3;">¥{{item.amount ? parseFloat(item.amount).toFixed(2) : '0.00'}}</text>
</view>
<view class="quche">
<text>运营区:{{item.areaName || '--'}}</text>
</view>
<view class="quche">
<text>申请时间:{{item.createTime || '--'}}</text>
</view>
</view>
<view class="dibutishi" v-if="depositList.length == 0">
当前没有更多申请记录咯...
</view>
</scroll-view>
<!-- 骑行订单 -->
<scroll-view v-else class="qixinglist" @scrolltolower="handqixing" scroll-y refresher-enabled @refresherrefresh="onRefresh" :refresher-triggered="isRefreshing" refresher-default-style="black">
<view class="qixinglist_item" v-for="(item,index) in qixinglist" :key="index" @click="btnxqqx(item.id)">
<view class="top">
<view class="lt">
<image src="/static/image/icon17.png" mode=""></image> {{item.deviceVehicleNum == null ? '--' : item.deviceVehicleNum}}
</view>
<view class="rt" v-if="item.status == 'WAIT_PAY'" :style="{color: getOrderStatusColor(item.status)}">
待支付 <u-icon name="arrow-right" :color="getOrderStatusColor(item.status)" size="28"></u-icon>
</view>
<view class="rt" v-if="item.status == 'CANCELED'" :style="{color: getOrderStatusColor(item.status)}">
已取消 <u-icon name="arrow-right" :color="getOrderStatusColor(item.status)" size="28"></u-icon>
</view>
<view class="rt" v-if="item.status == 'PROCESSING'" :style="{color: getOrderStatusColor(item.status)}">
进行中 <u-icon name="arrow-right" :color="getOrderStatusColor(item.status)" size="28"></u-icon>
</view>
<view class="rt" v-if="item.status == 'FINISHED'" :style="{color: getOrderStatusColor(item.status)}">
已完成 <u-icon name="arrow-right" :color="getOrderStatusColor(item.status)" size="28"></u-icon>
</view>
<view class="rt" v-if="item.status == 'WAIT_VERIFY'" :style="{color: getOrderStatusColor(item.status)}">
待审核 <u-icon name="arrow-right" :color="getOrderStatusColor(item.status)" size="28"></u-icon>
</view>
<view class="rt" v-if="item.status == 'RIDE_WAIT_PAY'" :style="{color: getOrderStatusColor(item.status)}">
骑行待支付 <u-icon name="arrow-right" :color="getOrderStatusColor(item.status)" size="28"></u-icon>
</view>
</view>
<view class="bot">
<view class="lt">
<view class="">
<text>开始时间:</text> {{item.startTime == null ? '--' : item.startTime}}
</view>
<view class="" v-if="item.status == 'PROCESSING'">
<text>已骑行:</text> {{computeTimeDiff(item.startTime)}}
</view>
<view class="" v-if="item.status != 'PROCESSING'">
<text>时长:</text> {{computedList(item.duration)}}
</view>
<view class="" v-if="item.status == 'PROCESSING'">
<text>距离:</text> 订单结束后展示
</view>
<view class="" v-if="item.status != 'PROCESSING'">
<text>距离:</text> {{item.distance > 1000 ? (item.distance / 1000).toFixed(2) + 'km' : item.distance.toFixed(2) + 'm'}}
</view>
<view class="" v-if="item.status == 'WAIT_VERIFY'">
<text>还车审核:</text> 未审核
</view>
</view>
<view class="rt">
{{item.totalFee.toFixed(2)}}元
</view>
</view>
</view>
<view class="dibutishi">
当前没有更多骑行订单咯...
</view>
</scroll-view>
</view>
</template>
<script>
export default {
data() {
return {
iconobj:this.$store.state.iconobj,
bgc: {
backgroundColor: "#C4E1FF",
},
activeindex:1,
list: [{
name: '全部'
}, {
name: '待取车'
}, {
name: '使用中',
}, {
name: '已完成',
}, {
name: '已取消',
}],
lists: [{
name: '全部'
}, {
name: '待支付'
}, {
name: '已完成',
}],
current: 0,
currents: 0,
pageNum:1,
pageSize:10,
qixinglist:[],
depositList:[],
total:'',
depositTotal:0,
status:'',
isRefreshing: false,
}
},
onLoad() {
if(this.activeindex == 2){
this.getDepositList()
}else{
this.getlist()
}
},
onShow() {
},
methods: {
// 下拉刷新
onRefresh() {
this.isRefreshing = true
this.pageNum = 1
if(this.activeindex == 2){
this.getDepositList()
}else{
this.getlist()
}
setTimeout(() => {
this.isRefreshing = false
}, 1000)
},
// 计算实付金额
formatPayedAmount(payedAmount, payRefunded, payRefunding) {
if (!payedAmount) return '0.00';
const amount = parseFloat(payedAmount) || 0;
const refunded = parseFloat(payRefunded) || 0;
const refunding = parseFloat(payRefunding) || 0;
const actualAmount = amount - (refunded + refunding);
return `${actualAmount.toFixed(2)}`;
},
// 跳转到骑行订单详情
btnxqqx(id){
uni.navigateTo({
url:'/page_user/yongche/orderxq?id=' + id
})
},
computedList(seconds, showSeconds = true) {
if (isNaN(seconds)) return "--"
const h = Math.floor(seconds / 3600)
const m = Math.floor((seconds % 3600) / 60)
const s = seconds % 60
const parts = []
if (h > 0) parts.push(`${h}时`)
if (m > 0 || h > 0) parts.push(`${m}分`) // 如果有小时则始终显示分钟
if (showSeconds) parts.push(`${s}秒`)
return parts.join("") || "0钟"
},
// 计算开始时间到现在的时间差
computeTimeDiff(startTime) {
if (!startTime) return '--';
const start = new Date(startTime);
const now = new Date();
const diff = Math.floor((now - start) / 1000); // 转换为秒
const hours = Math.floor(diff / 3600);
const minutes = Math.floor((diff % 3600) / 60);
let result = '';
if (hours > 0) result += `${hours}时`;
if (minutes > 0 || hours > 0) result += `${minutes}分`;
return result || '0分';
},
// 请求订单列表
getlist(){
this.$u.get(`/app/order/mineList?pageNum=${this.pageNum}&pageSize=10&suitType=${this.activeindex}&status=${this.status}&isAsc=desc&orderByColumn=createTime`).then((res) => {
if (res.code == 200) {
if(this.pageNum == 1){
this.qixinglist = res.rows
}else{
this.qixinglist = this.qixinglist.concat(res.rows)
}
this.pageNum ++
this.total = res.total
}else if(res.code == 401){
uni.showModal({
title: '提示',
content: '您当前未登录,是否前去登录?',
showCancel: true,
success: function (res) {
if (res.confirm) {
uni.reLaunch({
url:'/pages/login/login'
})
} else if (res.cancel) {
}
}
})
}
})
},
// 点击进入订单详情
btnxq(){
uni.navigateTo({
url:'/page_fenbao/orderxq'
})
},
// 点击进入押金退还详情
btnDepositDetail(id){
uni.navigateTo({
url:'/pages/depositRefund/detail?id=' + id
})
},
// 获取状态文本
getStatusText(status){
const statusMap = {
1: '待审核',
2: '待退款',
3: '退款成功',
4: '已驳回'
}
return statusMap[status] || '--'
},
// 获取押金退还状态颜色
getStatusColor(status){
const colorMap = {
1: '#FF9500', // 待审核 - 橙色
2: '#4297F3', // 待退款 - 蓝色
3: '#52C41A', // 退款成功 - 绿色
4: '#FF4D4F' // 已驳回 - 红色
}
return colorMap[status] || '#808080'
},
// 获取骑行订单状态颜色
getOrderStatusColor(status){
const colorMap = {
'WAIT_PAY': '#FF9500', // 待支付 - 橙色
'CANCELED': '#999999', // 已取消 - 灰色
'PROCESSING': '#4297F3', // 进行中 - 蓝色
'FINISHED': '#52C41A', // 已完成 - 绿色
'WAIT_VERIFY': '#FF9500', // 待审核 - 橙色
'RIDE_WAIT_PAY': '#FF9500' // 骑行待支付 - 橙色
}
return colorMap[status] || '#808080'
},
// 获取押金退还列表
getDepositList(){
this.$u.get(`/app/depositRefund/list?pageNum=${this.pageNum}&pageSize=${this.pageSize}&orderByColumn=createTime&isAsc=desc`).then((res) => {
if (res.code == 200) {
if(this.pageNum == 1){
this.depositList = res.rows || []
}else{
this.depositList = this.depositList.concat(res.rows || [])
}
this.pageNum ++
this.depositTotal = res.total || 0
}else if(res.code == 401){
uni.showModal({
title: '提示',
content: '您当前未登录,是否前去登录?',
showCancel: true,
success: function (res) {
if (res.confirm) {
uni.reLaunch({
url:'/pages/login/login'
})
} else if (res.cancel) {
}
}
})
}
})
},
// 滚动骑行订单到底部分页请求
handqixing() {
if(this.total > this.qixinglist.length){
this.getlist()
}
},
// 滚动押金退还列表到底部分页请求
handleScrollToLower() {
if(this.depositTotal > this.depositList.length){
this.getDepositList()
}
},
// 点击骑行订单tabs筛选
changes(index) {
this.currents = index
if(index == 0){
this.status = ''
}else if(index == 1){
this.status = 'WAIT_PAY'
}else if(index == 2){
this.status = 'FINISHED'
}
this.pageNum = 1
this.getlist()
},
// 点击租车tabs筛选
change(index) {
this.current = index
},
// 点击切换tab选项
btnac(num){
if(num == 1){
this.activeindex = 1
}else{
this.activeindex = 2
}
this.pageNum = 1
if(this.activeindex == 2){
this.getDepositList()
}else{
this.getlist()
}
}
}
}
</script>
<style lang="scss">
page {
background: #F7F7F7;
}
.qixinglist{
height: 76vh;
overflow: scroll;
padding-bottom: 20rpx;
box-sizing: border-box;
.dibutishi{
width: 100%;
text-align: center;
margin-top: 18rpx;
color: #ccc;
}
.qixinglist_item{
margin-top: 18rpx;
width: 714rpx;
max-height: 452rpx;
background: #FFFFFF;
border-radius: 20rpx 20rpx 20rpx 20rpx;
margin: auto;
margin-top: 20rpx;
padding: 24rpx 28rpx;
box-sizing: border-box;
.bot{
display: flex;
justify-content: space-between;
align-items: center;
margin-top: 22rpx;
.lt{
font-size: 28rpx;
color:#3D3D3D;
view{
margin-top: 8rpx;
}
text{
color: #808080;
}
}
.rt{
font-weight: 600;
font-size: 40rpx;
color: #3D3D3D;
}
}
.top{
display: flex;
justify-content: space-between;
.rt{
font-size: 26rpx;
color: #808080;
}
.lt{
display: flex;
align-items: center;
font-weight: 600;
font-size: 32rpx;
color: #3D3D3D;
image{
width: 42rpx;
height: 42rpx;
margin-right: 18rpx;
}
}
}
}
}
.zuchelist{
height: 80vh;
overflow: scroll;
padding-bottom: 20rpx;
box-sizing: border-box;
.dibutishi{
width: 100%;
text-align: center;
margin-top: 18rpx;
color: #ccc;
}
.zuchelist_item{
width: 714rpx;
max-height: 700rpx;
padding-bottom: 28rpx;
box-sizing: border-box;
background: #FFFFFF;
border-radius: 20rpx 20rpx 20rpx 20rpx;
margin: auto;
margin-top: 20rpx;
overflow: hidden;
}
.bot{
display: flex;
justify-content: space-between;
align-items: center;
width: 693rpx;
margin: auto;
padding: 0 14rpx;
box-sizing: border-box;
margin-top: 40rpx;
.rt{
display: flex;
justify-content: space-between;
.huan{
width: 106rpx;
height: 52rpx;
background: #4297F3;
border-radius: 8rpx 8rpx 8rpx 8rpx;
border: 2rpx solid #4297F3;
text-align: center;
line-height: 52rpx;
font-size: 26rpx;
color: #FFFFFF;
margin-left: 10rpx;
}
.xuzu{
width: 106rpx;
height: 52rpx;
border-radius: 8rpx 8rpx 8rpx 8rpx;
border: 2rpx solid #4297F3;
font-size: 26rpx;
color: #4297F3;
text-align: center;
line-height: 52rpx;
}
}
.lt{
view{
font-size: 26rpx;
color: #3D3D3D;
margin-top: 18rpx;
}
}
}
.quche{
padding: 0 24rpx;
box-sizing: border-box;
display: flex;
justify-content: space-between;
margin-top: 18rpx;
.price{
font-weight: 600;
font-size: 32rpx;
color: #3D3D3D;
}
text{
font-size: 26rpx;
color: #3D3D3D;
}
}
.top{
width: 714rpx;
height: 84rpx;
background: linear-gradient( 270deg, rgba(220,237,255,0) 0%, #DCEDFF 80%);
line-height: 84rpx;
font-size: 24rpx;
color: #3D3D3D;
padding:0 24rpx;
box-sizing: border-box;
display: flex;
justify-content: space-between;
}
}
@keyframes fadeIn {
from {
opacity: 0;
}
to {
opacity: 1;
}
}
@keyframes fadeIns {
from {
transform: translateX(-500%);
}
to {
transform: translateX(0%);
}
}
@keyframes fadeInss {
from {
transform: translateX(500%);
}
to {
transform: translateX(0%);
}
}
.navtab{
display: flex;
width: 100%;
height: 114rpx;
position: relative;
background-color: #C4E1FF;
z-index: 1;
.qxtabs{
width: 50%;
text-align: center;
padding-top: 40rpx;
box-sizing: border-box;
font-weight: 600;
font-size: 36rpx;
color: #3D3D3D;
animation: fadeIn 0.3s ease-in-out forwards;
text{
width: 54rpx;
height: 6rpx;
background: #4297F3;
border-radius: 4rpx 4rpx 4rpx 4rpx;
display: block;
margin: auto;
margin-top: 8rpx;
animation: fadeIns 0.5s ease-in-out forwards;
}
image{
width: 439rpx;
height: 114rpx;
position: absolute;
bottom:0;
right: 0;
z-index: -1;
}
}
.zctabs{
width: 50%;
font-size: 32rpx;
font-weight: 600;
color: #3D3D3D;
text-align: center;
padding-top: 46rpx;
box-sizing: border-box;
image{
width: 400rpx;
height: 94rpx;
position: absolute;
bottom: 0;
left:0;
z-index: -2;
}
}
.qxtab{
width: 50%;
text-align: center;
padding-top: 46rpx;
box-sizing: border-box;
font-weight: 600;
font-size: 32rpx;
color: #3D3D3D;
image{
width: 439rpx;
height: 94rpx;
position: absolute;
bottom:0;
right: 0;
z-index: -2;
}
}
.zctab{
width: 50%;
font-weight: 600;
font-size: 36rpx;
color: #3D3D3D;
text-align: center;
padding-top: 40rpx;
box-sizing: border-box;
animation: fadeIn 0.3s ease-in-out forwards;
text{
animation: fadeInss 0.5s ease-in-out forwards;
width: 54rpx;
height: 6rpx;
background: #4297F3;
border-radius: 4rpx 4rpx 4rpx 4rpx;
display: block;
margin: auto;
margin-top: 8rpx;
}
image{
width: 400rpx;
height: 114rpx;
position: absolute;
top: 0;
left:0;
z-index: -1;
}
}
}
.topbj{
width: 100%;
height: 22rpx;
background-color: #C4E1FF;
}
</style>