PixelAI-mobile/pages/mobile_web/my/child_pages/recharge.vue
2025-01-22 20:25:38 +08:00

315 lines
8.5 KiB
Vue
Raw 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>
<!-- #ifdef APP -->
<view class="recharge-detail" :style="{ backgroundImage: `url(${myFileUrl+background})`,paddingTop: CustomBar+'rpx' }">
<view class="app-top" :style="{ height: CustomBar+'rpx',
background: topLevel===0? '#ffffff00' : `rgba(255, 255, 255,${topLevel})` }"></view>
<!-- #endif -->
<!-- #ifndef APP -->
<view class="recharge-detail" :style="{ backgroundImage: `url(${myFileUrl+background})` }">
<!-- #endif -->
<view class="cdt-top">
<!-- #ifdef MP -->
<view :style="{height: `${StatusBar}px`}"></view>
<view class="app-top" :style="{height: `${StatusBar}px`,background: topLevel===0? '#ffffff00' : `rgba(255, 255, 255,${topLevel})`}"></view>
<view class="mobile-logo" :style="{height: `${CustomBarHeight}px`,backgroundColor: `rgba(255, 255, 255,${topLevel})`}">
<!-- #endif -->
<!-- #ifndef MP -->
<view class="mobile-logo" :style="{backgroundColor: `rgba(255, 255, 255,${topLevel})`}">
<!-- #endif -->
<u-icon name="arrow-left" size="40" class="back" @click="back"
:color="topLevel===0? '#f9f9f9' : `rgba(194, 234, 4,${topLevel})`"></u-icon>
<image :src="myFileUrl+logo"></image>
<view style="width: 75rpx;"></view>
</view>
<view class="detail-content">
<u-section title="充值记录" :subTitle="`总数 ${total}`"
color="#befda1" fontSize="34" :arrow="false" subColor="#cbe7fb" />
<scroll-view :scroll-top="scrollTop" :scrollY="true" class="rechargeList"
scroll-with-animation @scroll="scroll">
<u-collapse :itemStyle="{border: '4rpx solid rgba(56,45,79,1)',borderTopRightRadius: '10rpx',
borderTopLeftRadius: '10rpx',marginTop: '30rpx'}" :arrow="false" :headStyle="{color:'#b3a0da',
backgroundColor: 'rgba(56,45,79,0.6)', borderTopLeftRadius: '10rpx',
borderTopRightRadius: '10rpx'}" :bodyStyle="{backgroundColor: 'rgba(56,45,79,1)',minHeight: '100rpx'}">
<u-collapse-item v-for="(item, index) in rechargeList" :key="item.id">
<template slot="title">
<view class="recharge-item-title">
<view class="cit-left">
{{ index+1 }}. 钻石充值
<text :class="item.result ? 'citl-green' : 'citl-red'">
{{ item.addOrSub === 'sub' ? '- ' : '+ ' }}{{ options[item.buyType-1] }}
</text>
</view>
<view class="cit-right">
{{ dateFormat(item.createTime) }}
</view>
</view>
</template>
<view class="recharge-item-content">
{{ item.orderType || '钻石充值' }} {{ options[item.buyType-1] }}钻 {{ item.amount }}¥ —{{ item.result || '支付失败' }}
</view>
</u-collapse-item>
<u-loadmore @loadmore="getMore" :status="isFinish" color="#b3a0da" marginTop="30" marginBottom="20" />
</u-collapse>
</scroll-view>
<view class="recharge-tips">
<view class="tips-green"><view class="tip-green"></view>充值成功</view>
<view class="tips-red"><view class="tip-red"></view>充值失败</view>
</view>
</view>
</view>
<view @click="goTop">
<u-back-top :scrollTop="oldScrollTop" zIndex="100" :iconStyle="{ color: '#fff' }"
:customStyle="{background: 'linear-gradient(180deg, rgba(56,45,79,1) 0%, #b3a0da 100%)',filter: 'opacity(0.96)'}"></u-back-top>
</view>
<u-toast ref="uToast"></u-toast>
</view>
</template>
<script>
import configService from '@/common/config.service.js';
export default {
data(){
return{
// #ifdef MP
// 微信小程序自定义导航栏参数
StatusBar: this.StatusBar || 0,
CustomBarHeight: this.Custom.height+(this.Custom.top-this.StatusBar)*2 || 0,
// #endif
// 基础路径
myFileUrl: configService.fileUrl + 'pixel/my/',
// 我的页面背景
background: 'background.png',
// logo图标
logo: 'logo-new.png',
// 顶部距离等级
topLevel: 0,
// 是否结束——loadmore加载更多loading加载中nomore无更多
isFinish: 'nomore',
form: {
size: 10,
current: 1
},
// 滚动顶部
scrollTop: 0,
oldScrollTop: 0,
// 充值记录
rechargeList: [],
// 总数
total: 0,
// 额度选项
options: [5,10,20,30,50,100],
}
},
// #ifndef H5
onPageScroll(e) {
const level = e.scrollTop/60;
if(level<=1) this.topLevel = level;
else this.topLevel = 1;
},
// #endif
// #ifdef H5
mounted(){
let that = this;
window.onscroll = function () {
//为了保证兼容性,这里取三个值,哪个有值取哪一个
//scrollTop就是触发滚轮事件时滚轮的高度
var scrollTop = window.pageYOffset || document.documentElement.scrollTop || document.body.scrollTop;
const level = scrollTop/60;
if(level<=1) that.topLevel = level;
else that.topLevel = 1;
}
},
onHide() {
window.onscroll = null;
},
// #endif
// 上拉刷新
onPullDownRefresh(){
try{
this.init();
}catch(e){}
finally{
uni.stopPullDownRefresh();
}
},
onLoad(options) {
this.init();
},
methods:{
// 返回
back(){
uni.navigateBack();
},
// 滚动回顶部
goTop() {
this.scrollTop = this.oldScrollTop;
this.$nextTick(()=>{
this.scrollTop = 0;
});
},
// 滚动监听
scroll(e){
this.oldScrollTop = e.detail.scrollTop;
},
// 时间格式化
dateFormat(time){
let date = new Date(time);
let month = date.getMonth()+1,
day = date.getDate(),
hour = date.getHours(),
minute = date.getMinutes(),
second = date.getSeconds();
return `${date.getFullYear()}-${month<10?'0':''}${month}-${day<10?'0':''}${day} ${hour<10?'0':''}${hour}:${minute<10?'0':''}${minute}:${second<10?'0':''}${second}`;
},
// 加载更多
getMore(){
if(this.isFinish === 'nomore') return;
this.form.current++;
this.getRechargeList();
},
// 获取充值记录列表
async getRechargeList(){
this.isFinish = 'loading';
let res = await this.$api.getOrders(this.form);
if(res?.success){
const { records, size, total, current } = res.data;
if(current === 1) this.rechargeList = records;
else this.rechargeList.push(...records);
this.isFinish = size*current >= total ? 'nomore' : 'loadmore';
this.total = total;
}else{
this.$refs.uToast.show({type:'error',title: "充值记录获取失败!"});
this.isFinish = 'loadmore';
}
},
// 初始化
init(){
this.form = {size: 10,current: 1};
// let { createtime } = JSON.parse(this.$store.state.user_message);
// this.rechargeList = [{
// id: -1,
// type: '充值钻石',
// addOrSub: 'add',
// value: '1000',
// createtime: createtime,
// description: '新用户注册赠送1000钻石。'
// }];
// this.total = 1;
this.getRechargeList();
},
}
}
</script>
<style scoped lang="scss">
.recharge-detail{
display: flex;
flex-direction: column;
min-height: 100vh;
background-size: cover;
// #ifdef APP
.app-top{
width: 100%;
position: fixed;
z-index: 81;
top: 0;
}
// #endif
.cdt-top{
// #ifdef APP || MP
.app-top{
width: 100%;
position: fixed;
z-index: 81;
top: 0;
}
// #endif
.mobile-logo{
width: 100%;
display: flex;
justify-content: space-between;
align-items: center;
.back{
margin-left: 35rpx;
margin-top: 5rpx
}
position: fixed;
z-index: 81;
padding: 15rpx 0;
image{
width: 200rpx;
height: 45rpx;
}
// .u-icon{
// }
}
}
.detail-content{
margin: 120rpx 20rpx 32rpx;
padding: 40rpx 25rpx 20rpx;
background-color: rgba(160, 160, 160, 0.1);
border-radius: 16rpx;
.rechargeList{
margin: 30rpx 0;
width: 100%;
height: 75vh;
}
.recharge-tips{
display: flex;
align-items: center;
.tips-green{
display: flex;
align-items: center;
color: #49cc90;
margin-right: 20rpx;
.tip-green{
width: 22rpx;
height: 22rpx;
margin-right: 10rpx;
background-color: #49cc90;
}
}
.tips-red{
display: flex;
align-items: center;
color: #f93e3e;
.tip-red{
width: 22rpx;
height: 22rpx;
margin-right: 10rpx;
background-color: #f93e3e;
}
}
}
}
}
.recharge-item-title{
width: 100%;
margin: 0 30rpx;
display: flex;
align-items: center;
justify-content: space-between;
.cit-left{
max-width: 50%;
overflow: hidden;
white-space: nowrap;
text-overflow: ellipsis;
text{
margin-left: 20rpx;
}
.citl-green{
color: #49cc90;
}
.citl-red{
color: #f93e3e;
}
}
}
.recharge-item-content{
margin: 10rpx 30rpx;
color: #e7eefe;
}
</style>