powerbank/pages/myorder/index.vue

225 lines
6.7 KiB
Vue
Raw Normal View History

2024-05-11 10:57:53 +08:00
<template>
<view class="page">
2024-05-25 18:06:00 +08:00
<u-navbar title="我的订单" :border-bottom="false" :background="bgc" title-color='#000' title-size='36'
height='58'></u-navbar>
<view class="listorder" @scrolltolower="onReachBottom" v-for="(item,index) in wateringList" :key="index">
<view class="title">
<view>订单号{{item.orderNo}} &nbsp;&nbsp; <u-icon @click="fuzhi(item.orderNo)" name="file-text"
size="38"></u-icon> </view>
<view @click="btnnav(item.orderId)"><u-icon name="arrow-right"></u-icon></view>
</view>
2024-05-11 10:57:53 +08:00
<view class="bh">
2024-05-22 18:04:44 +08:00
<text>柜机编号</text> <text>{{item.startCabinetSn}}</text>
2024-05-11 10:57:53 +08:00
</view>
<view class="bh">
2024-05-22 18:04:44 +08:00
<text>电池编号</text> <text>{{item.deviceSn}}</text>
2024-05-11 10:57:53 +08:00
</view>
<view class="bh">
2024-05-22 18:04:44 +08:00
<text>手机号码</text> <text>{{item.mobile}}</text>
2024-05-11 10:57:53 +08:00
</view>
<view class="bh">
2024-05-25 18:06:00 +08:00
<text>订单状态</text>
<text v-if="item.status == 1">租赁中</text>
<text v-if="item.status == 2">已归还</text>
<text v-if="item.status == 3">付款中</text>
<text v-if="item.status == 4">已付款</text>
<text v-if="item.status == 5">免费取消</text>
<text v-if="item.status == 6">租转卖</text>
2024-05-11 10:57:53 +08:00
</view>
<view class="bh">
2024-05-27 18:03:57 +08:00
<text>订单金额</text> <text>{{item.money == null ? (zujiemoney > item.priceStandard.feeMaxPrice ? item.priceStandard.feeMaxPrice : zujiemoney) : item.money}}</text>
2024-05-11 10:57:53 +08:00
</view>
<view class="bh">
2024-05-22 18:04:44 +08:00
<text>租借时间</text> <text>{{item.startRentTime}}</text>
2024-05-11 10:57:53 +08:00
</view>
<view class="bh">
2024-05-25 18:06:00 +08:00
<text>租借时长</text> <text>{{item.remainingTime}}</text>
2024-05-11 10:57:53 +08:00
</view>
2024-05-25 18:06:00 +08:00
</view>
2024-05-11 10:57:53 +08:00
</view>
</template>
<script>
export default {
data() {
return {
2024-05-22 18:04:44 +08:00
pagenum: 1,
wateringList: [],
pagesize: 10, // 一页多少数据
isLoading: false, // 是否正在加载数据
noMoreData: false, // 是否没有更多数据
total: 0,
2024-05-25 18:06:00 +08:00
keyword: '',
type: '',
bgc: {
background: '#25CE88'
2024-05-27 18:03:57 +08:00
},
zujiemoney:''
2024-05-11 10:57:53 +08:00
}
},
onLoad() {
2024-05-25 18:06:00 +08:00
this.getlist()
2024-05-11 10:57:53 +08:00
},
methods: {
2024-05-25 18:06:00 +08:00
btnnav(orderId) {
2024-05-11 10:57:53 +08:00
uni.navigateTo({
2024-05-25 18:06:00 +08:00
url: '/pages/myorder/returned/index?orderId=' + orderId
2024-05-11 10:57:53 +08:00
})
2024-05-22 18:04:44 +08:00
},
2024-05-25 18:06:00 +08:00
getlist() {
2024-05-22 18:04:44 +08:00
this.$u.get('/app/order/rent/list?pageNum=' + this.pagenum + '&pageSize=' + this.pagesize).then(res => {
if (res.code == 200) {
2024-05-25 18:06:00 +08:00
this.total = res.total;
if (res.rows.length > 0) {
res.rows.forEach(order => {
if(order.endRentTime == null){
var targetDate = new Date(order.startRentTime);
var currentDate = new Date();
var diff = targetDate - currentDate;
// 确保 diff 是非负的,以便计算剩余时间
var absDiff = Math.abs(diff);
var hours = Math.floor(absDiff / (1000 * 60 * 60));
var minutes = Math.floor((absDiff % (1000 * 60 * 60)) / (1000 * 60));
let formattedMinutes = minutes < 10 ? '0' + minutes : minutes;
// 直接拼接字符串,不要插入 '-'
order.remainingTime = hours + '时' + formattedMinutes + '分钟';
2024-05-27 18:03:57 +08:00
if (order.priceStandard.feeMode == 2) {
if (minutes >= order.priceStandard.feeFreeTime) {
this.zujiemoney = (hours + 1) * order.priceStandard.feePrice
} else {
this.zujiemoney = hours * order.priceStandard.feePrice
}
}else if(order.priceStandard.feeMode == 1){
if (minutes >= order.priceStandard.feeFreeTime) {
this.zujiemoney = (hours * 2 + 1) * order.priceStandard.feePrice
if(minutes >= 30){
this.zujiemoney = (hours * 2 + 2) * order.priceStandard.feePrice
}
} else {
this.zujiemoney = hours * 2 * order.priceStandard.feePrice
}
}
2024-05-25 18:06:00 +08:00
}else{
var targetDate = new Date(order.endRentTime);
var currentDate = new Date();
var diff = targetDate - currentDate;
var absDiff = Math.abs(diff);
var hours = Math.floor(absDiff / (1000 * 60 * 60));
var minutes = Math.floor((absDiff % (1000 * 60 * 60)) / (1000 * 60));
let formattedMinutes = minutes < 10 ? '0' + minutes : minutes;
order.remainingTime = hours + '时' + formattedMinutes + '分钟';
2024-05-27 18:03:57 +08:00
if (order.priceStandard.feeMode == 2) {
if (minutes >= order.priceStandard.feeFreeTime) {
this.zujiemoney = (hours + 1) * order.priceStandard.feePrice
} else {
this.zujiemoney = hours * order.priceStandard.feePrice
}
}else if(order.priceStandard.feeMode == 1){
if (minutes >= order.priceStandard.feeFreeTime) {
this.zujiemoney = (hours * 2 + 1) * order.priceStandard.feePrice
if(minutes >= 30){
this.zujiemoney = (hours * 2 + 2) * order.priceStandard.feePrice
}
} else {
this.zujiemoney = hours * 2 * order.priceStandard.feePrice
}
}
2024-05-25 18:06:00 +08:00
}
});
this.wateringList = this.wateringList.concat(res.rows);
// console.log(this.wateringList);
this.pagenum++;
} else {
// 没有更多数据
this.noMoreData = true;
}
this.isLoading = false;
2024-05-22 18:04:44 +08:00
}
2024-05-25 18:06:00 +08:00
}).catch(error => {
// 处理错误情况
console.error('请求出错:', error);
});
2024-05-22 18:04:44 +08:00
},
onReachBottom() {
let sum = this.total / this.pagesize
2024-05-25 18:06:00 +08:00
if (this.pagenum - 1 < sum) {
2024-05-22 18:04:44 +08:00
this.getlist();
} else {
uni.showToast({
title: '没有更多记录了',
icon: 'none',
duration: 1000
});
}
},
2024-05-25 18:06:00 +08:00
fuzhi(text) {
uni.setClipboardData({
data: text,
success: function(res) {
console.log('复制的信息:', text);
uni.showToast({
title: '复制成功',
});
}
});
}
2024-05-11 10:57:53 +08:00
}
}
</script>
<style lang="scss">
2024-05-25 18:06:00 +08:00
/deep/ .u-title,
/deep/ .uicon-nav-back {
padding-bottom: 40rpx;
}
2024-05-11 10:57:53 +08:00
page {
// background-color: ;
2024-05-22 18:04:44 +08:00
background: linear-gradient(180deg, #F4F5F7 0%, rgba(255, 255, 255, 0) 100%);
2024-05-11 10:57:53 +08:00
border-radius: 0rpx 0rpx 0rpx 0rpx;
2024-05-25 18:06:00 +08:00
padding-bottom: 200rpx;
2024-05-11 10:57:53 +08:00
}
.page {
width: 750rpx;
padding-left: 34rpx;
padding-right: 34rpx;
box-sizing: border-box;
2024-05-25 18:06:00 +08:00
// position: fixed;
2024-05-22 18:04:44 +08:00
// top: 0;
// left: 0;
2024-05-25 18:06:00 +08:00
.listorder {
2024-05-11 10:57:53 +08:00
margin-top: 32rpx;
width: 100%;
height: 100%;
background-color: #fff;
border-radius: 30rpx;
padding: 32rpx;
box-sizing: border-box;
2024-05-25 18:06:00 +08:00
.title {
2024-05-11 10:57:53 +08:00
display: flex;
justify-content: space-between;
font-weight: 400;
font-size: 32rpx;
color: #666666;
border-bottom: 1px solid #ccc;
padding-bottom: 20rpx;
margin-bottom: 28rpx;
}
2024-05-25 18:06:00 +08:00
.bh {
2024-05-11 10:57:53 +08:00
display: flex;
justify-content: space-between;
margin-top: 18rpx;
font-size: 24rpx;
color: #808080;
line-height: 32rpx;
}
}
}
</style>