223 lines
5.1 KiB
Vue
223 lines
5.1 KiB
Vue
<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(index)">
|
||
<image :src="item.images"></image>
|
||
<view>
|
||
<text class="bok_name" style="line-height: 30rpx;">{{item.bookName}}</text>
|
||
</view>
|
||
</view>
|
||
<view style="height: 1px;"></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,
|
||
bookScreen: {
|
||
page: 1, //当前页码数
|
||
limit: 5, //单页数据数量
|
||
},
|
||
totalPage: 0,
|
||
totalCount: 0,
|
||
bookList: [],
|
||
bgiStyle: {
|
||
background: '#2ab58833'
|
||
},
|
||
iconStyle: {
|
||
fontSize: '40rpx',
|
||
fontWeight: 'bold',
|
||
color: '#54a966',
|
||
},
|
||
bokMesDet: {}
|
||
}
|
||
},
|
||
|
||
// 返回顶部
|
||
onPageScroll(e) {
|
||
this.scrollTop = e.scrollTop;
|
||
},
|
||
|
||
// 下拉刷新
|
||
onReachBottom() {
|
||
this.status = 0
|
||
if (this.bookScreen.page < this.totalPage) {
|
||
this.bookScreen.page = this.bookScreen.page + 1
|
||
setTimeout(() => {
|
||
this.$http
|
||
.post('book/bookbrowserecords/userList?userId=' + this.userInfo.id + '&page=' + this
|
||
.bookScreen.page + '&limit=' + this.bookScreen.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(e) {},
|
||
computed: {
|
||
...mapState(['userInfo'])
|
||
},
|
||
//页面显示
|
||
onShow() {
|
||
this.getData();
|
||
},
|
||
|
||
//方法
|
||
methods: {
|
||
// 获取列表数据
|
||
getData() {
|
||
this.bokMesDet.userId = this.userInfo.id
|
||
this.bookList = []
|
||
this.$http
|
||
.post('book/bookbrowserecords/userList?userId=' + this.userInfo.id + '&page=' + this.bookScreen.page +
|
||
'&limit=' + this.bookScreen.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])
|
||
}
|
||
});
|
||
},
|
||
|
||
|
||
// 电子书内容跳转
|
||
onBookJump(e) {
|
||
const that = this;
|
||
that.bokMesDet.bookId = that.bookList[e].bookId
|
||
that.bokMesDet.bookName = that.bookList[e].bookName
|
||
// 加入阅读记录
|
||
$http.request({
|
||
url: "book/bookbrowserecords/save",
|
||
method: "POST", // POST、GET、PUT、DELETE,具体说明查看官方文档
|
||
data: that.bokMesDet,
|
||
header: { //默认 无 说明:请求头
|
||
'Content-Type': 'application/json'
|
||
},
|
||
}).then(function(res) {
|
||
if (res.code == 0) {
|
||
if (res.browseRecordsId) {
|
||
$http.request({
|
||
url: "book/bookbrowserecords/update",
|
||
method: "POST", // POST、GET、PUT、DELETE,具体说明查看官方文档
|
||
data: {
|
||
'id': res.browseRecordsId
|
||
},
|
||
header: { //默认 无 说明:请求头
|
||
'Content-Type': 'application/json'
|
||
},
|
||
}).then(function(res) {
|
||
if (res.code == 0) {
|
||
// 跳转页面
|
||
let chaId = 0
|
||
if (that.bookList[e].chapterNum != null) {
|
||
chaId = that.bookList[e].chapterNum - 1
|
||
}
|
||
uni.navigateTo({
|
||
url: '../yRead/angbook?Id=' + that.bookList[e].bookId +
|
||
'&cha=' + chaId
|
||
});
|
||
}
|
||
}).catch(function(error) {
|
||
//这里只会在接口是失败状态返回,不需要去处理错误提示
|
||
console.log(error);
|
||
});
|
||
} else {
|
||
// 跳转页面
|
||
let chaId = 0
|
||
if (that.bookList[e].chapterNum != null) {
|
||
chaId = that.bookList[e].chapterNum - 1
|
||
}
|
||
uni.navigateTo({
|
||
url: '../yRead/angbook?Id=' + that.bookList[e].bookId + '&cha=' + chaId
|
||
});
|
||
}
|
||
}
|
||
}).catch(function(error) {
|
||
//这里只会在接口是失败状态返回,不需要去处理错误提示
|
||
console.log(error);
|
||
});
|
||
},
|
||
|
||
},
|
||
|
||
};
|
||
</script>
|
||
<style lang="scss" scoped>
|
||
@import '@/style/mixin.scss';
|
||
|
||
|
||
.book_list {
|
||
margin: 50rpx 30rpx 0 30rpx;
|
||
|
||
.bl_tioa {
|
||
padding: 0 25upx;
|
||
margin: 0 0 60rpx 0;
|
||
border-radius: 15rpx;
|
||
min-height: 250rpx;
|
||
width: 33%;
|
||
display: inline-block;
|
||
text-align: center;
|
||
height: 400rpx;
|
||
vertical-align: bottom;
|
||
|
||
view {
|
||
// margin: 0 0 10rpx 0;
|
||
|
||
text {
|
||
color: #9b9b9b;
|
||
font-size: 24rpx;
|
||
line-height: 36rpx;
|
||
}
|
||
|
||
.bok_name {
|
||
font-weight: bold;
|
||
color: #333;
|
||
font-size: 28rpx;
|
||
}
|
||
}
|
||
|
||
image {
|
||
width: 98%;
|
||
height: 260upx;
|
||
margin: 0 auto;
|
||
}
|
||
}
|
||
|
||
}
|
||
</style>
|