| | |
| | | // pages/resourceDetails/document/index.js |
| | | import Toast from 'tdesign-miniprogram/toast/index'; |
| | | const app = getApp() |
| | | import { |
| | | loginInfo |
| | | } from '../../../../assets/js/login'; |
| | | Page({ |
| | | |
| | | /** |
| | |
| | | navBarHeight: '', |
| | | barHeight: '', |
| | | activeId: '', |
| | | storeInfo: '', |
| | | bookId: '', |
| | | bookName: '', |
| | | cmsId: '', |
| | |
| | | pauseTime: 0, //暂停时间 |
| | | applyState: '', |
| | | deadline: '', |
| | | lzoomFlag: false, //定义 缩放事件 节流阀,防止一次缩放触发两次缩放事件 |
| | | distance: 0, //记录手指移动距离 |
| | | scale: 1, //定义初始化的页面缩放大小 |
| | | newScale: 1, //记录新的页面缩放大小 |
| | | }, |
| | | /** |
| | | * 生命周期函数--监听页面加载 |
| | |
| | | activeId: options.activeId, |
| | | bookId: options.bookId, |
| | | bookName: options.bookName, |
| | | storeInfo: options.storeInfo, |
| | | cmsId: options.cmsId, |
| | | parentName: options.parentName, |
| | | parentProductLinkPath: options.parentProductLinkPath, |
| | |
| | | applyState: options.applyState, |
| | | deadline: options.deadline |
| | | }) |
| | | this.resourceDetailsData() |
| | | const token = wx.getStorageSync(app.config.tokenKey) |
| | | if (!token) { |
| | | loginInfo(app, (data) => { |
| | | if (data) { |
| | | this.resourceDetailsData() |
| | | } else { |
| | | this.resourceDetailsData() |
| | | } |
| | | }) |
| | | } else { |
| | | this.resourceDetailsData() |
| | | } |
| | | |
| | | }, |
| | | |
| | | /** |
| | |
| | | /** |
| | | * 用户点击右上角分享 |
| | | */ |
| | | onShareAppMessage() { |
| | | |
| | | }, |
| | | onShareAppMessage() {}, |
| | | onShareTimeline() {}, |
| | | goBack() { |
| | | wx.navigateBack() |
| | | }, |
| | | |
| | | resourceDetailsData() { |
| | | wx.showLoading({ |
| | | title: '正在加载...', |
| | | }); |
| | | let query = { |
| | | path: '*', |
| | | queryType: '*', |
| | |
| | | start: 0, |
| | | size: 999 |
| | | } |
| | | } |
| | | if (this.data.storeInfo) { |
| | | query.storeInfo = this.data.storeInfo |
| | | } |
| | | app.MG.store.getProductDetail(query).then((res) => { |
| | | console.log(res); |
| | |
| | | //刚进来的时候调用 |
| | | handleTeachData(item) { |
| | | //图片 |
| | | console.log(item, 'item11111'); |
| | | |
| | | if (item.selectType == 'picture') { |
| | | this.setData({ |
| | | showData: item.file ? app.config.requestCtx + '/file/api/ApiDownload?md5=' + item.file : app.config.requestCtx + '/file/api/ApiDownload?md5=' + item.freeFile, |
| | | }) |
| | | console.log(this.data.showData, 'showData'); |
| | | wx.hideLoading(); |
| | | } |
| | | // 下载文件zip |
| | | if (item.selectType == 'zip') { |
| | | this.setData({ |
| | | zipData: item |
| | | }) |
| | | wx.hideLoading(); |
| | | } |
| | | //网页 |
| | | if (item.selectType == 'webpage') { |
| | | this.setData({ |
| | | webpageSrc: item.jsek_link |
| | | }) |
| | | wx.hideLoading(); |
| | | } |
| | | //文档等 |
| | | if (item.selectType == 'pdf' || item.selectType == 'document') { |
| | | app.MG.file.getPdfInfo({ |
| | | md5: item.file |
| | | }).then((res) => { |
| | | if (res && res.totalPages) { |
| | | for (let i = 0; i < res.totalPages; i++) { |
| | | let naturalResources = [] |
| | | if (res && JSON.parse(res).totalPages) { |
| | | for (let i = 0; i < JSON.parse(res).totalPages; i++) { |
| | | const src = app.config.requestCtx + '/file/GetPdfPageImage?md5=' + item.file + '&index=' + (i + 1) + '&dpi=300' |
| | | this.data.naturalResources.push(src) |
| | | // console.log(this.data.naturalResources, ' this.data.naturalResources'); |
| | | naturalResources.push(src) |
| | | } |
| | | } |
| | | this.setData({ |
| | | naturalResources |
| | | }) |
| | | wx.hideLoading(); |
| | | }) |
| | | } |
| | | |
| | | }, |
| | | |
| | | handleTap: function () { |
| | |
| | | }, |
| | | //预览图片,放大预览 |
| | | preview(event) { |
| | | console.log(event.currentTarget.dataset.src) |
| | | let currentUrl = event.currentTarget.dataset.src |
| | | let urls = [event.currentTarget.dataset.src] |
| | | wx.previewImage({ |
| | | current: currentUrl, // 当前显示图片的http链接 |
| | | // urls: this.data.showData // 需要预览的图片http链接列表 |
| | | urls: urls // 需要预览的图片http链接列表 |
| | | }) |
| | | }, |
| | | |
| | | // myTouchStart(e) { |
| | | // //---------------------记录缩放事件信息--------------------- |
| | | // // 当两根手指放上去的时候,将距离(distance)初始化。 |
| | | // let xMove = e.touches[1].clientX - e.touches[0].clientX; |
| | | // let yMove = e.touches[1].clientY - e.touches[0].clientY; |
| | | // //计算开始触发两个手指坐标的距离 |
| | | // const distance = Math.sqrt(xMove * xMove + yMove * yMove); |
| | | // this.setData({ |
| | | // distance: distance |
| | | // }) |
| | | // //---------------------记录缩放事件信息end--------------------- |
| | | // }, |
| | | // myTouchMove(e) { |
| | | // // ----------------监听手势缩小放大事件---------------- |
| | | // // 单手指缩放不做任何操作 |
| | | // if (e.touches.length != 1) { |
| | | // //双手指运动 x移动后的坐标和y移动后的坐标 |
| | | // let xMove = e.touches[1].clientX - e.touches[0].clientX; |
| | | // let yMove = e.touches[1].clientY - e.touches[0].clientY; |
| | | // //双手指运动新的 ditance |
| | | // let newDistance = Math.sqrt(xMove * xMove + yMove * yMove); |
| | | // //计算移动的过程中实际移动了多少的距离 |
| | | // let distanceDiff = newDistance - this.data.distance; |
| | | // // newScale = scale + 0.005 * distanceDiff |
| | | // console.log('移动距离', distanceDiff); |
| | | // this.setData({ |
| | | // newScale: this.data.newScale + 0.005 * distanceDiff |
| | | // }) |
| | | // // 打开缩放监听 |
| | | // // zoomFlag = true |
| | | // this.setData({ |
| | | // lzoomFlag: true |
| | | // }) |
| | | // return |
| | | // } |
| | | // // ----------------监听手势缩小放大事件end---------------- |
| | | // }, |
| | | // myTouchEnd() { |
| | | // if (this.data.lzoomFlag) { |
| | | // if (this.data.newScale > 1.3) { |
| | | // console.log("放大了", this.data.newScale); |
| | | // } else if (this.data.newScale < 0.7, this.data.newScale) { |
| | | // console.log("缩小了"); |
| | | // } |
| | | // // 关闭缩放监听 |
| | | // // zoomFlag = false |
| | | // this.setData({ |
| | | // lzoomFlag: false |
| | | // }) |
| | | // } |
| | | // }, |
| | | }) |