|
@@ -1,5 +1,9 @@
|
|
|
<template>
|
|
|
- <view class="product-doc hasBottom" :style="{ paddingBottom: isIphoneX ? '60rpx' : 0 }">
|
|
|
+ <view
|
|
|
+ class="product-doc "
|
|
|
+ :class="{ hasBottom: TipStatus }"
|
|
|
+ :style="{ paddingBottom: isIphoneX && TipStatus ? '60rpx' : 0 }"
|
|
|
+ >
|
|
|
<view class="category">
|
|
|
<view class="category-title">图片资料</view>
|
|
|
<view class="content">
|
|
@@ -43,14 +47,17 @@
|
|
|
<view class="cm-time">{{ $reg.formatDate('', item.addTime) }}</view>
|
|
|
<view class="cm-video-list">
|
|
|
<video
|
|
|
+ class="cm-video"
|
|
|
:id="'myVideo' + index"
|
|
|
:src="item.fileUrl"
|
|
|
+ :style="videoStyle['myVideo' + index]"
|
|
|
controls
|
|
|
show-fullscreen-btn
|
|
|
show-mute-btn
|
|
|
play-btn-position="center"
|
|
|
@play="handlePlayer('myVideo' + index)"
|
|
|
v-if="item.fileUrl"
|
|
|
+ @loadedmetadata="loadedmetadata"
|
|
|
></video>
|
|
|
<view class="cm-video-section" v-else>
|
|
|
<image class="cm-video-cover" :src="videoCover"></image>
|
|
@@ -69,11 +76,11 @@
|
|
|
<view class="section" v-for="(item, index) in fileArchiveList" :key="index">
|
|
|
<image
|
|
|
src="https://static.caimei365.com/app/img/icon2/PDF-app.png"
|
|
|
- v-if="/\.pdf$/.test(item.fileName)"
|
|
|
+ v-if="/\.pdf/.test(item.fileName)"
|
|
|
></image>
|
|
|
<image
|
|
|
src="https://static.caimei365.com/app/img/icon2/DOC-app.png"
|
|
|
- v-else-if="/\.doc$/.test(item.fileName)"
|
|
|
+ v-else-if="/\.doc/.test(item.fileName)"
|
|
|
></image>
|
|
|
<image src="https://static.caimei365.com/app/img/icon2/PPT-app.png" v-else></image>
|
|
|
<view class="cm-desc">
|
|
@@ -154,13 +161,14 @@ export default {
|
|
|
videoArchiveList: [], // 视频资料列表
|
|
|
fileArchiveList: [], // 文件资料列表
|
|
|
defaultImage: 'https://static.caimei365.com/app/img/icon2/PC-default.png', // 默认图片
|
|
|
- videoCover: 'https://static.caimei365.com/app/img/icon2/video-cover.png' //默认视频封面
|
|
|
+ videoCover: 'https://static.caimei365.com/app/img/icon2/video-cover.png', //默认视频封面
|
|
|
+ videoStyle: {}
|
|
|
}
|
|
|
},
|
|
|
computed: {
|
|
|
...mapState(['isIphoneX']),
|
|
|
//资料查看状态提示
|
|
|
- TipStatus: function() {
|
|
|
+ TipStatus() {
|
|
|
// 资料权限
|
|
|
const statusText = [
|
|
|
false, // 正常访问
|
|
@@ -168,12 +176,17 @@ export default {
|
|
|
{ text: '请升级成为会员机构后方可查看!', btn: '去升级', redirect: '/pages/login/apply' },
|
|
|
{ text: '请升级成为医美会员机构后方可查看!', btn: '去升级', redirect: '/pages/login/apply' },
|
|
|
{ text: '需抵扣100采美豆方可查看!', btn: '去查看', redirect: 10 },
|
|
|
- { text: '无权限查看!', btn: '' }
|
|
|
+ { text: '无权限查看!', btn: '确认' }
|
|
|
]
|
|
|
// 0可查看,1未登录,2需升级会员机构,3需升级医美会员机构,4需要抵扣采美豆,5无权限查看
|
|
|
return statusText[this.permission]
|
|
|
}
|
|
|
},
|
|
|
+ watch: {
|
|
|
+ TipStatus(val) {
|
|
|
+ this.$emit('tipStatus', this.TipStatus)
|
|
|
+ }
|
|
|
+ },
|
|
|
created() {
|
|
|
this.userId = uni.getStorageSync('userInfo').userId || -1
|
|
|
this.getDetail()
|
|
@@ -202,19 +215,37 @@ export default {
|
|
|
duration: 1500,
|
|
|
title: res.msg
|
|
|
})
|
|
|
- setTimeout(()=>{
|
|
|
+ setTimeout(() => {
|
|
|
//刷新资料列表
|
|
|
this.getDetail()
|
|
|
- },1500)
|
|
|
+ }, 1500)
|
|
|
})
|
|
|
.catch(err => {
|
|
|
uni.showToast({
|
|
|
- icon:'none',
|
|
|
+ icon: 'none',
|
|
|
duration: 1500,
|
|
|
title: err.msg
|
|
|
})
|
|
|
})
|
|
|
},
|
|
|
+ // 获取视频源信息
|
|
|
+ loadedmetadata(e) {
|
|
|
+ // 获取视频长宽
|
|
|
+ const w = e.detail.width //视频真实宽度
|
|
|
+ const h = e.detail.height //视频真实高度
|
|
|
+ let rw = 0 //视频展示宽度
|
|
|
+ let rh = 0 //视频展示宽度
|
|
|
+ // 视频宽大于等于高时
|
|
|
+ if (w >= h) {
|
|
|
+ rw = 702
|
|
|
+ rh = (rh * h) / w
|
|
|
+ } else {
|
|
|
+ rw = 400
|
|
|
+ rh = (rw * h) / w
|
|
|
+ }
|
|
|
+ // 使用set向videoStyle添加样式信息
|
|
|
+ this.$set(this.videoStyle, e.currentTarget.id, `width:${rw}rpx;height:${rh}rpx;`)
|
|
|
+ },
|
|
|
// 视频播放
|
|
|
handlePlayer(id) {
|
|
|
if (this.checkPermission()) {
|
|
@@ -338,23 +369,75 @@ export default {
|
|
|
// 文件预览
|
|
|
previewFile(file) {
|
|
|
if (this.checkPermission()) return
|
|
|
- //先将链接缓存
|
|
|
- uni.setStorageSync('openLink', file.fileUrl)
|
|
|
+ // 获取文件后缀
|
|
|
+ // const index = file.fileName.lastIndexOf('.')
|
|
|
+ // const suffix = file.fileName.substring(index)
|
|
|
+ this.openDocument(file)
|
|
|
+ // if (suffix === '.doc' || suffix === '.ppt' || suffix === '.pptx' || suffix === '.docx') {
|
|
|
+ // //先将链接缓存
|
|
|
+ // uni.setStorageSync('openLink', file.htmlUrl)
|
|
|
+ // this.openDocument(file.fileUrl)
|
|
|
+ // // this.$api.navigateTo('/pages/h5/article/path?key=openLink&type=1')
|
|
|
+ // } else if (suffix === '.pdf') {
|
|
|
+ // //先将链接缓存
|
|
|
+ // uni.setStorageSync('openLink', file.fileUrl)
|
|
|
+ // this.$api.navigateTo('/pages/h5/article/path?key=openLink&type=2')
|
|
|
+ // } else {
|
|
|
+ // // 不支持的文件
|
|
|
+ // return uni.showModal({
|
|
|
+ // content: `${suffix}类型文件暂不支持预览`,
|
|
|
+ // cancelColor: '#666',
|
|
|
+ // confirmColor: '#E15616'
|
|
|
+ // })
|
|
|
+ // }
|
|
|
+ },
|
|
|
+ // 打开文档
|
|
|
+ openDocument(file) {
|
|
|
+ uni.showLoading({
|
|
|
+ title:'加载中'
|
|
|
+ })
|
|
|
// 获取文件后缀
|
|
|
const index = file.fileName.lastIndexOf('.')
|
|
|
- const suffix = file.fileName.substring(index)
|
|
|
- if (suffix === '.doc' || suffix === '.ppt') {
|
|
|
- this.$api.navigateTo('/pages/h5/article/path?key=openLink&type=1')
|
|
|
- } else if (suffix === '.pdf') {
|
|
|
- this.$api.navigateTo('/pages/h5/article/path?key=openLink&type=2')
|
|
|
- } else {
|
|
|
- // 不支持的文件
|
|
|
- return uni.showModal({
|
|
|
- content: `${suffix}类型文件暂不支持预览`,
|
|
|
- cancelColor: '#666',
|
|
|
- confirmColor: '#E15616'
|
|
|
- })
|
|
|
- }
|
|
|
+ const suffix = file.fileName.substring(index + 1)
|
|
|
+ // 下载文件
|
|
|
+ uni.downloadFile({
|
|
|
+ url: file.fileUrl,
|
|
|
+ success(res) {
|
|
|
+ const filePath = res.tempFilePath
|
|
|
+ console.log(filePath)
|
|
|
+ // 打开文件
|
|
|
+ uni.openDocument({
|
|
|
+ filePath: filePath,
|
|
|
+ fileType: suffix,
|
|
|
+ success(res) {
|
|
|
+ uni.showToast({
|
|
|
+ icon:'success',
|
|
|
+ title:'打开成功',
|
|
|
+ duration: 1200
|
|
|
+ })
|
|
|
+ uni.hideLoading()
|
|
|
+ },
|
|
|
+ fail(err) {
|
|
|
+ if(err.errMsg.indexOf('fail filetype not supported')){
|
|
|
+ uni.showModal({
|
|
|
+ content: '不支持的文件预览',
|
|
|
+ cancelColor: '#666',
|
|
|
+ confirmColor: '#E15616'
|
|
|
+ })
|
|
|
+ }
|
|
|
+ uni.hideLoading()
|
|
|
+ }
|
|
|
+ })
|
|
|
+ },
|
|
|
+ fail(err){
|
|
|
+ uni.showToast({
|
|
|
+ title: JSON.stringify(err),
|
|
|
+ icon:'none',
|
|
|
+ duration: 5000
|
|
|
+ })
|
|
|
+ uni.hideLoading()
|
|
|
+ },
|
|
|
+ })
|
|
|
}
|
|
|
}
|
|
|
}
|
|
@@ -380,6 +463,7 @@ export default {
|
|
|
background: #ffe6dc;
|
|
|
border-radius: 16px;
|
|
|
box-sizing: border-box;
|
|
|
+ z-index: 9;
|
|
|
&.maxBottom {
|
|
|
bottom: 175rpx;
|
|
|
}
|
|
@@ -525,18 +609,20 @@ export default {
|
|
|
}
|
|
|
.cm-video-list {
|
|
|
margin-top: 18rpx;
|
|
|
- width: 702rpx;
|
|
|
- height: 420rpx;
|
|
|
- video {
|
|
|
- width: 100% !important;
|
|
|
- max-width: 100%;
|
|
|
- min-width: 100%;
|
|
|
- display: flex;
|
|
|
- max-height: 420rpx;
|
|
|
- // width: 100%;
|
|
|
- // height: 100%;
|
|
|
- background: #000;
|
|
|
- }
|
|
|
+ // // width: 702rpx;
|
|
|
+ // // height: 420rpx;
|
|
|
+ // width: 544rpx;
|
|
|
+ // height: 960rpx;
|
|
|
+ // .cm-video {
|
|
|
+ // width: 100% !important;
|
|
|
+ // max-width: 100%;
|
|
|
+ // min-width: 100%;
|
|
|
+ // display: flex;
|
|
|
+ // // max-height: 420rpx;
|
|
|
+ // // width: 100%;
|
|
|
+ // height: 100%;
|
|
|
+ // background: #000;
|
|
|
+ // }
|
|
|
}
|
|
|
}
|
|
|
}
|