Dining_Hall/pages/remainingSum/rechargeRecord.vue

327 lines
7.9 KiB
Vue
Raw Normal View History

<template>
<page-meta :page-font-size="fontValue+'px'" :root-font-size="fontValue+'px'"></page-meta>
<view>
2025-02-19 09:34:34 +08:00
<Navbar title="充值记录" :goTo="paths.remainingSum" :showRightText="true" :isBack="false" :text="'充值日期'" @clickIcon="handleRightText"/>
2025-03-14 15:15:54 +08:00
<u-loading-page :loading="showLoading" loading-text="加载中..."></u-loading-page>
2025-04-27 15:58:51 +08:00
<view class="recharge-history">
<!-- 顶部标签导航 -->
2025-02-19 09:34:34 +08:00
<view class="tab-navigation">
2025-04-27 15:58:51 +08:00
<Tabs :tabList="tabList" @changeTab="changeTab"/>
2025-03-14 15:15:54 +08:00
</view>
<!-- 充值记录列表 -->
2025-04-27 15:58:51 +08:00
<scroll-view scroll-y @scrolltolower="onScrollTolower" class="record-list" v-if="!showLoading">
2025-02-19 09:34:34 +08:00
<view v-for="(record, index) in rechargeRecords" :key="index" class="record-item">
<!-- 左侧图标 -->
2025-02-19 09:34:34 +08:00
<u-icon :name="getIconClass(record.type)" size="42"></u-icon>
<!-- <text>{{index}}</text> -->
<!-- 中间充值详情 -->
2025-02-19 09:34:34 +08:00
<view class="record-details">
<view class="status" v-if="record.payState<=3" style="color: seagreen;">{{ record.payStateName }}</view>
<view class="status" v-if="record.payState>3" style="color: red;">{{ record.payStateName }}</view>
<view class="time">充值方式{{ record.payTypeName }}</view>
<view class="time">{{ record.tradeTime }}</view>
2025-03-14 15:15:54 +08:00
<view class="time" v-if="record.payState==4">失败原因{{ record.failReason }}</view>
2025-02-19 09:34:34 +08:00
</view>
<!-- 右侧金额信息 -->
2025-02-19 09:34:34 +08:00
<view class="amount-info">
<view class="amount">¥{{ (record.amount/100).toFixed(2) }}</view>
2025-03-14 15:15:54 +08:00
<view class="balance" v-if="record.payState==3">余额: {{ (record.walletBalTotal/100).toFixed(2) }}</view>
2025-04-27 15:58:51 +08:00
<view class="query-btn" v-if="record.payState==2||record.payState==4" @click="queryResult(record)">再次查询充值结果</view>
2025-03-14 15:15:54 +08:00
</view>
2025-02-19 09:34:34 +08:00
</view>
2025-03-14 15:15:54 +08:00
</scroll-view>
2025-02-19 09:34:34 +08:00
</view>
2025-03-14 15:15:54 +08:00
<u-datetime-picker
ref="datetimePicker"
:show="show"
v-model="dateValue"
title="选择日期"
:filter="filter"
mode="date"
closeOnClickOverlay
@confirm="confirm"
@cancel="cancel"
@change="change"
@close="close"
></u-datetime-picker>
</view>
</template>
<script>
2025-03-14 15:15:54 +08:00
import { chargeRecordApi,getRechargeQueryResultApi } from '../../api/index/index'
import Tabs from '@/pages/components/Tabs.vue'
import UIcon from '../../uni_modules/uview-ui/components/u-icon/u-icon.vue'
2025-04-27 15:58:51 +08:00
export default {
name: 'rechargeRecord',
components: { UIcon, Tabs },
data() {
return {
2025-04-27 15:58:51 +08:00
fontValue:uni.getStorageSync('fontSize') || 8,
tabIndex: 0,
2025-03-14 15:15:54 +08:00
showLoading:true,
2025-04-27 15:58:51 +08:00
paths: {
remainingSum: '/pages/remainingSum/index'
},
current: 0,
show: false,
dateValue:new Date(),
startDateTime:"",
endDateTime: "",
activeTab: 'all',
tabs: [
{ id: 'all', name: '全部' },
{ id: 'success', name: '充值成功' },
{ id: 'failed', name: '充值失败' },
{ id: 'timeout', name: '充值超时' }
],
tabList: ['全部', '充值成功', '充值失败', '充值超时'],
queryParam:{
pageNum:1,
pageSize:10
},
rechargeState:"",
total:0,
rechargeRecords: []
}
},
2025-02-19 09:34:34 +08:00
onLoad() {
this.getRecordList()
},
methods: {
2025-03-14 15:15:54 +08:00
//再次查询充值结果
queryResult(item){
console.log(item)
let param = {
2025-03-14 15:15:54 +08:00
"accTradeId": item.tradeId,
}
getRechargeQueryResultApi(param).then((res)=>{
this.getRecordList()
}).catch(()=>{
this.getRecordList()
})
2025-03-14 15:15:54 +08:00
},
2025-02-19 09:34:34 +08:00
onScrollTolower(){
if(this.total>this.rechargeRecords.length){
this.queryParam.pageNum++
this.getRecordList()
}
},
async getRecordList() {
this.showLoading=true
2025-02-19 09:34:34 +08:00
let params = {
2025-04-27 15:58:51 +08:00
custId: uni.getStorageSync('custId'),
2025-02-19 09:34:34 +08:00
rechargeState:this.rechargeState,
current:this.queryParam.pageNum,
size:this.queryParam.pageSize,
2025-03-14 15:15:54 +08:00
startDateTime:this.startDateTime,
endDateTime:this.endDateTime
2025-02-19 09:34:34 +08:00
}
const res = await chargeRecordApi(params)
console.log('?? ~ getBalance ~ res', res)
2025-02-19 09:34:34 +08:00
// this.rechargeRecords = res.records;
this.total=res.total;
res.records.forEach(item=>{
item.tradeTime = item.tradeTime.replace('T', ' ')
})
if (this.queryParam.pageNum==1) {
this.rechargeRecords = res.records
} else {
this.rechargeRecords.push(...res.records)
}
this.showLoading=false
2025-02-19 09:34:34 +08:00
},
changeTab(index) {
console.log('?? ~ changeTab ~ index:', index)
2025-04-27 15:58:51 +08:00
// this.tabIndex = index;
2025-02-19 09:34:34 +08:00
if(index==0){
this.rechargeState="";
this.queryParam.pageNum=1;
this.getRecordList()
}else{
this.rechargeState=index;
this.queryParam.pageNum=1;
this.getRecordList()
}
},
filter(type, options) {
2025-02-19 09:34:34 +08:00
// if (type === 'year') {
// return options.filter((option) => option % 2 === 0)
// }
return options
},
confirm(e) {
2025-03-14 15:15:54 +08:00
this.show = false;
2025-02-19 09:34:34 +08:00
if (!isNaN(e.value)) {
2025-03-14 15:15:54 +08:00
// const timestamp = parseInt(e.value);
const selectedDate = new Date(e.value);
console.log(selectedDate)
2025-02-19 09:34:34 +08:00
const year = selectedDate.getFullYear();
const month = ("0" + (selectedDate.getMonth() + 1)).slice(-2);
2025-03-14 15:15:54 +08:00
const day = ("0" + selectedDate.getDate()).slice(-2);
2025-02-19 09:34:34 +08:00
const hours = ("0" + selectedDate.getHours()).slice(-2);
const minutes = ("0" + selectedDate.getMinutes()).slice(-2);
2025-03-14 15:15:54 +08:00
const seconds = ("0" + selectedDate.getSeconds()).slice(-2);
2025-04-14 17:39:27 +08:00
// this.startDateTime = `${year}-${month}-${day} ${hours}:${minutes}:${seconds}`;
this.startDateTime = `${year}-${month}-${day} 00:00:00`;
// const endDate = new Date(selectedDate.getTime() + 86399999)
// const year2 = endDate.getFullYear();
// const month2 = ("0" + (endDate.getMonth() + 1)).slice(-2);
// const day2 = ("0" + endDate.getDate()).slice(-2);
this.endDateTime = `${year}-${month}-${day} 23:59:59`
2025-02-19 09:34:34 +08:00
this.show = false;
this.queryParam.pageNum=1;
this.getRecordList()
}
2025-03-14 15:15:54 +08:00
console.log(this.startDateTime)
console.log(this.endDateTime)
},
cancel() {
2025-02-19 09:34:34 +08:00
this.show = false;
},
change(e) {
console.log('change', e)
},
close() {
2025-02-19 09:34:34 +08:00
this.show = false;
},
handleRightText() {
console.log('?? ~ handleRightText ~ ')
this.current = 5
2025-02-19 09:34:34 +08:00
this.show = true
},
setActiveTab(tabId) {
this.activeTab = tabId
},
getIconClass(type) {
switch (type) {
case 'wechat':
return require('../../static/images/successful.png')
case 'wallet':
return require('../../static/images/lose.png')
default:
return require('../../static/images/delay.png')
}
}
}
}
</script>
2025-04-27 15:58:51 +08:00
<style lang="scss" scoped>
page {
background: #fff;
}
.recharge-history {
background: #fff;
//background-color: #f3f4f6;
2025-02-19 09:34:34 +08:00
min-height: 94vh;
}
.tab-navigation {
display: flex;
background-color: white;
padding: 15px 16px 0 16px;
}
.tab {
padding: 12px 16px;
position: relative;
cursor: pointer;
}
.tab.active {
color: #f97316;
}
.tab.active::after {
content: '';
position: absolute;
bottom: 0;
left: 0;
width: 100%;
height: 2px;
background-color: #f97316;
}
.record-list {
2025-02-19 09:34:34 +08:00
// background-color: #22c55e;
height: 87vh;
//padding: 0 16px;
}
.record-item {
display: flex;
align-items: center;
background-color: white;
margin-top: 8px;
padding: 16px;
border-radius: 8px;
}
.icon {
width: 40px;
height: 40px;
border-radius: 50%;
display: flex;
align-items: center;
justify-content: center;
}
.inner-circle {
width: 24px;
height: 24px;
background-color: white;
border-radius: 50%;
}
.default-icon {
background-color: #3b82f6;
}
.wechat-icon {
background-color: #22c55e;
}
.wallet-icon {
background-color: #f97316;
}
.record-details {
flex: 1;
margin-left: 12px;
}
.status {
font-size: 32rpx;
font-weight: 500;
}
.time {
font-size: 28rpx;
color: #6b7280;
}
.amount-info {
text-align: right;
}
.amount {
color: #f97316;
}
.balance {
font-size: 28rpx;
color: #6b7280;
}
2025-03-14 15:15:54 +08:00
.query-btn{
padding: 14rpx 10rpx;
font-size: 20rpx;
background: #f97316;
color: #FFF;
margin-top: 10rpx;
border-radius: 4rpx;
}
</style>