Files
nuttyreading-html/pages/eBook/bookBuy.vue
@fawn-nine f8e1a3015b 1
2023-03-03 12:11:23 +08:00

192 lines
4.0 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>
<z-nav-bar title="电子书购买记录"></z-nav-bar>
<view class="book_list">
<view class="bl_tioa" v-for="(item,index) in bookList" @click="onBookJump(item)">
<image :src="item.image"></image>
<view style="margin:0 0 10rpx 0;">
<text class="bok_name">{{item.bookName}}</text>
</view>
<view>
<text>作者<text style="color: #333;">{{item.author}}</text></text>
</view>
<view>
<text style="line-height: 20rpx;">{{item.title}}</text>
</view>
</view>
<view style="height: 1px;"></view>
<view v-if="bookList.length==0" style="font-size: 30rpx;text-align: center;">无购买记录</view>
</view>
<view>
<view v-if="status==0" style="text-align: center;">
<u-loading-icon style="display: inline-block;"></u-loading-icon>
<font style='vertical-align: super;margin-left: 10px;font-size: 26rpx;color: #909399;'>努力加载中</font>
</view>
<view v-if="status==1">
<u-divider text="全部加载完成"></u-divider>
</view>
</view>
<view style="padding-bottom: 20rpx;">
<u-back-top :scroll-top="scrollTop" bottom="60" :customStyle='bgiStyle' :iconStyle="iconStyle"></u-back-top>
</view>
</view>
</template>
<script>
import $http from '@/config/requestConfig.js';
import {
mapState
} from 'vuex';
export default {
data() {
return {
scrollTop: 0,
status: 3,
BuyScreen: {
page: 1, //当前页码数
limit: 5, //单页数据数量
},
totalPage: 0,
totalCount: 0,
bookList: [],
bgiStyle: {
background: '#2ab58833'
},
iconStyle: {
fontSize: '40rpx',
fontWeight: 'bold',
color: '#54a966',
},
}
},
// 返回顶部
onPageScroll(e) {
this.scrollTop = e.scrollTop;
},
// 下拉刷新
onReachBottom() {
this.status = 0
if (this.BuyScreen.page < this.totalPage) {
this.BuyScreen.page = this.BuyScreen.page + 1
setTimeout(() => {
this.$http
.post('book/userebookbuy/list?userId=' + this.userInfo.id + '&page=' + this.BuyScreen
.page + '&limit=' + this.BuyScreen.limit)
.then(res => {
this.totalPage = res.page.totalPage
this.totalCount = res.page.totalCount
for (let i in res.page.list) {
this.bookList.push(res.page.list[i])
}
});
}, 1000)
} else {
this.status = 1
}
},
//第一次加载
onLoad() {
this.getData();
},
computed: {
...mapState(['userInfo'])
},
//页面显示
onShow() {
// this.getData();
},
// 下拉刷新
onPullDownRefresh() {
this.getData()
uni.stopPullDownRefresh()
},
//方法
methods: {
// 获取列表数据
getData() {
this.bookList = []
this.$http
.post('book/userebookbuy/list?userId=' + this.userInfo.id + '&page=' + this.BuyScreen
.page + '&limit=' + this.BuyScreen.limit)
.then(res => {
this.bookList = res.page.list
this.totalPage = res.page.totalPage
this.status = 3
});
},
// 电子书内容跳转
onBookJump(e) {
uni.navigateTo({
url: './bookContent?Id=' + e.bookId
});
},
},
};
</script>
<style lang="scss" scoped>
@import '@/style/mixin.scss';
.book_list {
margin: 50rpx 30rpx 0 30rpx;
.bl_tioa {
box-shadow: 0 0px 10px 1px #d3d1d133;
background-color: #fff;
position: relative;
padding: 30upx 25upx 10upx 230upx;
margin: 0 0 60rpx 0;
border-radius: 15rpx;
min-height: 300rpx;
view {
// margin: 0 0 10rpx 0;
text {
color: #9b9b9b;
font-size: 26rpx;
line-height: 36rpx;
}
.bok_name {
font-weight: bold;
color: #333;
font-size: 32rpx;
}
}
image {
position: absolute;
left: 30upx;
top: 30upx;
width: 160upx;
height: 240upx;
}
b {
display: block;
padding: 5rpx 10rpx;
border-radius: 10rpx;
text-align: center;
color: #fff;
font-weight: normal;
background: #27b386;
position: absolute;
left: -1upx;
top: -10upx;
font-size: 16rpx;
}
}
}
</style>