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

270 lines
7.3 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="create-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="create-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="createList"
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 createList" :key="item.id">
<template slot="title">
<view class="create-item-title">
<view class="cit-left">
{{ index+1 }}. {{ item.type }}
<text :class="item.addOrSub === 'sub' ? 'citl-red' : 'citl-green'">
{{ item.addOrSub === 'sub' ? '- ' : '+ ' }}{{ item.value }}¥
</text>
</view>
<view class="cit-right">
{{ dateFormat(item.createtime) }}
</view>
</view>
</template>
<view class="create-item-content">{{item.description}}</view>
</u-collapse-item>
<u-loadmore @loadmore="getMore" :status="isFinish" color="#b3a0da" marginTop="30" marginBottom="20" />
</u-collapse>
</scroll-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,
// 生成/消费记录
createList: [],
// 总数
total: 0,
}
},
// #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.getCreateList();
},
// 获取生产记录列表
async getCreateList(){
this.isFinish = 'loading';
let res = await this.$api.getConsumption(this.form);
if(res?.success){
const { records, size, total, current } = res.data;
if(current === 1) this.createList = records;
else this.createList.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};
this.getCreateList();
},
}
}
</script>
<style scoped lang="scss">
.create-detail{
display: flex;
flex-direction: column;
min-height: 100vh;
background-size: cover;
// #ifdef APP || MP
.app-top{
width: 100%;
position: fixed;
z-index: 81;
top: 0;
}
// #endif
.cdt-top{
// #ifdef APP
.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;
.createList{
margin: 30rpx 0;
width: 100%;
height: 75vh;
}
}
}
.create-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;
}
}
}
.create-item-content{
margin: 10rpx 30rpx;
color: #e7eefe;
}
</style>