powerbank/pages/myorder/index.vue
2024-06-07 18:02:00 +08:00

248 lines
7.3 KiB
Vue
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<template>
<view class="page">
<u-navbar title="我的订单" :border-bottom="false" :background="bgc" title-color='#000' back-icon-color="#000" title-size='36' height='50'></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>
<view class="bh">
<text>柜机编号</text> <text>{{item.startCabinetSn}}</text>
</view>
<view class="bh">
<text>电池编号</text> <text>{{item.deviceSn}}</text>
</view>
<view class="bh">
<text>手机号码</text> <text>{{item.mobile}}</text>
</view>
<view class="bh">
<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>
<text v-if="item.status == 7">弹出失败</text>
<text v-if="item.status == 8">全额退款</text>
<text v-if="item.status == 9">部分退款</text>
</view>
<view class="bh" v-if="item.sale.money">
<text>销售金额</text> <text>{{item.sale.money / 100}}元</text>
</view>
<view class="bh" v-else>
<text>订单金额</text>
<text>{{item.money > item.priceStandard.feeMaxPrice ? item.priceStandard.feeMaxPrice : item.money}}元</text>
</view>
<view class="bh">
<text>租借时间</text> <text>{{item.startRentTime}}</text>
</view>
<view class="bh" v-if="item.sale.payTime">
<text>租转卖时间</text> <text>{{item.sale.payTime}}</text>
</view>
<view class="bh" v-else>
<text>租借时长</text> <text>{{item.remainingTime}}</text>
</view>
</view>
<view class="" style="width: 448rpx;height: 448rpx;margin: auto;margin-top: 100rpx;text-align: center;"
v-if="showflag">
<image style="width: 448rpx;height: 448rpx;"
src="https://api.ccttiot.com/smartmeter/img/static/ufLi6IZd5kh1MIEZFYTo" mode=""></image>
<view class="" style="font-size: 30rpx;color: #ccc;margin-top: 30rpx;">暂无更多订单记录...</view>
</view>
</view>
</template>
<script>
export default {
data() {
return {
pagenum: 1,
wateringList: [],
pagesize: 10, // 一页多少数据
isLoading: false, // 是否正在加载数据
noMoreData: false, // 是否没有更多数据
total: 0,
keyword: '',
type: '',
bgc: {
background: '#25CE88'
},
zujiemoney: 0,
showflag: false
}
},
onLoad() {
},
onShow() {
this.wateringList = []
this.getlist()
},
methods: {
btnnav(orderId) {
uni.navigateTo({
url: '/pages/myorder/returned/index?orderId=' + orderId
})
},
getlist() {
this.$u.get('/app/order/rent/list?pageNum=' + this.pagenum + '&pageSize=' + this.pagesize).then(res => {
if (res.code == 200) {
this.total = res.total;
if (this.total > 0) {
this.showflag = false
} else {
this.showflag = true
}
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;
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 + '分钟';
if (order.priceStandard.feeMode == 2) {
if (minutes >= order.priceStandard.feeFreeTime) {
order.money = (hours + 1) * order.priceStandard.feePrice
} else {
order.money = hours * order.priceStandard.feePrice
}
} else if (order.priceStandard.feeMode == 1) {
if (minutes >= order.priceStandard.feeFreeTime) {
order.money = (hours * 2 + 1) * order.priceStandard.feePrice
if (minutes >= 30) {
order.money = (hours * 2 + 2) * order.priceStandard
.feePrice
}
} else {
order.money = hours * 2 * order.priceStandard.feePrice
}
}
} 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 + '分钟';
if (order.priceStandard.feeMode == 2) {
if (minutes >= order.priceStandard.feeFreeTime) {
order.money = (hours + 1) * order.priceStandard.feePrice
} else {
order.money = hours * order.priceStandard.feePrice
}
} else if (order.priceStandard.feeMode == 1) {
if (minutes >= order.priceStandard.feeFreeTime) {
order.money = (hours * 2 + 1) * order.priceStandard.feePrice
if (minutes >= 30) {
order.money = (hours * 2 + 2) * order.priceStandard.feePrice
}
} else {
order.money = hours * 2 * order.priceStandard.feePrice
}
}
}
})
this.wateringList = this.wateringList.concat(res.rows);
this.pagenum++;
} else {
// 没有更多数据
this.noMoreData = true;
}
this.isLoading = false;
} else {
uni.navigateTo({
url: '/pages/login/login'
})
}
}).catch(error => {
// 处理错误情况
console.error('请求出错:', error);
});
},
onReachBottom() {
let sum = this.total / this.pagesize
if (this.pagenum - 1 < sum) {
this.getlist();
} else {
uni.showToast({
title: '没有更多记录了',
icon: 'none',
duration: 1000
});
}
},
fuzhi(text) {
uni.setClipboardData({
data: text,
success: function(res) {
console.log('复制的信息:', text);
uni.showToast({
title: '复制成功',
});
}
});
}
}
}
</script>
<style lang="scss">
/deep/ .u-title,
/deep/ .uicon-nav-back {
padding-bottom: 22rpx;
}
page {
border-radius: 0rpx 0rpx 0rpx 0rpx;
padding-bottom: 200rpx;
}
.page {
width: 750rpx;
padding-left: 34rpx;
padding-right: 34rpx;
box-sizing: border-box;
.listorder {
margin-top: 32rpx;
width: 100%;
height: 100%;
background-color: #fff;
border-radius: 30rpx;
padding: 32rpx;
box-sizing: border-box;
.title {
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;
}
.bh {
display: flex;
justify-content: space-between;
margin-top: 18rpx;
font-size: 24rpx;
color: #808080;
line-height: 32rpx;
}
}
}
</style>