|
|
@ -1,12 +1,11 @@ |
|
|
|
<template> |
|
|
|
<view class="box" style="position: relative"> |
|
|
|
<!-- <image class="back" src='../../imgs/back.png' mode="widthFix" @click="handleBack"></image> --> |
|
|
|
<image class="logo" src="../../imgs/logo.png" mode="widthFix"></image> |
|
|
|
<view class="box-cent"> |
|
|
|
<view class="box-cent1"> |
|
|
|
<view class="view-pdf"> |
|
|
|
<pdf |
|
|
|
v-for="i in numPages" |
|
|
|
v-for="i in loadedPages" |
|
|
|
:key="i" |
|
|
|
:src="filePdfUrl" |
|
|
|
:page="i" |
|
|
@ -22,23 +21,9 @@ |
|
|
|
@confirm="handleOut" |
|
|
|
></u-modal> |
|
|
|
</view> |
|
|
|
<!-- 底部背景图 --> |
|
|
|
<view class="view-backimg"> |
|
|
|
<view class="view-backimg-top"></view> |
|
|
|
<!-- <view class="view-backimg-bottom"></view> --> |
|
|
|
</view> |
|
|
|
<!-- <div class="tools"> |
|
|
|
<view style="width:50vw;display: flex;margin: auto;"> |
|
|
|
<button :theme="'default'" type="submit" @click.stop="prePage" class="mr10"> |
|
|
|
上一页 |
|
|
|
</button> |
|
|
|
<div class="page">{{pageNum}}/{{pageTotalNum}}</div> |
|
|
|
<button :theme="'default'" type="submit" @click.stop="nextPage" class="mr10"> |
|
|
|
下一页 |
|
|
|
</button> |
|
|
|
</view> |
|
|
|
</div> --> |
|
|
|
<!-- 头像 - 头像 --> |
|
|
|
<view class="avatarobx"> |
|
|
|
<view class="name">{{ userName }}</view> |
|
|
|
<image |
|
|
@ -58,88 +43,102 @@ |
|
|
|
</template> |
|
|
|
|
|
|
|
<script> |
|
|
|
import pdf from 'vue-pdf'; |
|
|
|
import pdf from "vue-pdf"; |
|
|
|
export default { |
|
|
|
name: 'MeetingList', |
|
|
|
props: ['infos'], |
|
|
|
name: "MeetingList", |
|
|
|
props: ["infos"], |
|
|
|
components: { |
|
|
|
pdf, |
|
|
|
}, |
|
|
|
data() { |
|
|
|
return { |
|
|
|
filePdfUrl: '', |
|
|
|
userName: uni.getStorageSync('userName'), |
|
|
|
detailsId: '', |
|
|
|
numPages: '', |
|
|
|
filePdfUrl: "", |
|
|
|
userName: uni.getStorageSync("userName"), |
|
|
|
detailsId: "", |
|
|
|
numPages: 0, |
|
|
|
show: false, |
|
|
|
loadedPages: [], |
|
|
|
currentPage: 1, |
|
|
|
loadInterval: null, |
|
|
|
loadCount: 5, // 默认每次加载5页 |
|
|
|
}; |
|
|
|
}, |
|
|
|
created() { |
|
|
|
let routes = getCurrentPages(); // 获取当前打开过的页面路由数组 |
|
|
|
let curParam = routes[routes.length - 1].options; //获取路由参数 |
|
|
|
let routes = getCurrentPages(); |
|
|
|
let curParam = routes[routes.length - 1].options; |
|
|
|
this.detailsId = curParam.detailsId; |
|
|
|
this.filePdfUrl = curParam.filePdfUrl; |
|
|
|
this.getNumPages(this.filePdfUrl); |
|
|
|
}, |
|
|
|
beforeDestroy() { |
|
|
|
if (this.loadInterval) { |
|
|
|
clearInterval(this.loadInterval); |
|
|
|
} |
|
|
|
}, |
|
|
|
methods: { |
|
|
|
getNumPages(url) { |
|
|
|
this.pdfSrc = url; |
|
|
|
this.pdfSrc = pdf.createLoadingTask(this.pdfSrc); |
|
|
|
this.pdfSrc.promise.then((pdf) => { |
|
|
|
this.numPages = pdf.numPages; |
|
|
|
console.log('this.numPages', this.numPages); |
|
|
|
this.startLoadingPages(); |
|
|
|
}); |
|
|
|
}, |
|
|
|
// logo 回到首页 |
|
|
|
|
|
|
|
startLoadingPages() { |
|
|
|
this.loadInterval = setInterval(() => { |
|
|
|
if (this.currentPage <= this.numPages) { |
|
|
|
// 每次加载loadCount页 |
|
|
|
const endPage = Math.min( |
|
|
|
this.currentPage + this.loadCount - 1, |
|
|
|
this.numPages |
|
|
|
); |
|
|
|
for (let i = this.currentPage; i <= endPage; i++) { |
|
|
|
this.loadedPages.push(i); |
|
|
|
} |
|
|
|
this.currentPage = endPage + 1; |
|
|
|
} else { |
|
|
|
clearInterval(this.loadInterval); |
|
|
|
} |
|
|
|
}, 500); |
|
|
|
}, |
|
|
|
handleBack() { |
|
|
|
uni.navigateTo({ |
|
|
|
url: `/pages/index/details?id=${this.detailsId}`, |
|
|
|
}); |
|
|
|
// uni.navigateBack({ |
|
|
|
// delta: 1 |
|
|
|
// }); |
|
|
|
}, |
|
|
|
// 退出登录 |
|
|
|
handleOut() { |
|
|
|
uni.clearStorage(); |
|
|
|
uni.reLaunch({ |
|
|
|
url: '/pages/user/login', |
|
|
|
url: "/pages/user/login", |
|
|
|
}); |
|
|
|
}, |
|
|
|
// logo 回到首页 |
|
|
|
handleLogo() { |
|
|
|
uni.navigateTo({ |
|
|
|
url: `/pages/index/index`, |
|
|
|
}); |
|
|
|
}, |
|
|
|
|
|
|
|
// 关闭弹窗 |
|
|
|
handleClose() { |
|
|
|
this.pdfId = ''; |
|
|
|
this.pdfId = ""; |
|
|
|
this.show = false; |
|
|
|
}, |
|
|
|
// 上一页函数, |
|
|
|
prePage() { |
|
|
|
var page = this.pageNum; |
|
|
|
page = page > 1 ? page - 1 : this.pageTotalNum; |
|
|
|
this.pageNum = page; |
|
|
|
}, |
|
|
|
// 下一页函数 |
|
|
|
nextPage() { |
|
|
|
var page = this.pageNum; |
|
|
|
page = page < this.pageTotalNum ? page + 1 : 1; |
|
|
|
this.pageNum = page; |
|
|
|
}, |
|
|
|
// 页面加载回调函数,其中e为当前页数 |
|
|
|
pageLoaded(e) { |
|
|
|
this.curPageNum = e; |
|
|
|
}, |
|
|
|
// 其他的一些回调函数。 |
|
|
|
pdfError(error) { |
|
|
|
console.error(error); |
|
|
|
}, |
|
|
|
}, |
|
|
|
// 页面显示调用接口 |
|
|
|
onLoad() {}, |
|
|
|
}; |
|
|
|
</script> |
|
|
|