Commit c645bc0a by zhangquan

bug修复

1 parent cc0e3171
......@@ -2,10 +2,10 @@
.icon-down { width: 12px; height: 12px; background-position: -26px -74px;}
.icon-eye { width: 13px; height: 8px; background-position: -48px -74px;}
.icon-gift-del { width: 18px; height: 18px; background-position: -84px -30px;}
.icon-grctx { width: 16px; height: 16px; background-position: 0px -74px;}
.icon-link { width: 32px; height: 32px; background-position: -42px 0px;}
.icon-menu-active { width: 22px; height: 20px; background-position: 0px -44px;}
.icon-menu { width: 22px; height: 20px; background-position: -32px -44px;}
.icon-pdf { width: 32px; height: 34px; background-position: 0px 0px;}
.icon-PYQ { width: 21px; height: 20px; background-position: -84px 0px;}
.icon-send { width: 10px; height: 10px; background-position: -64px -44px;}
.icon-grctx { width: 16px; height: 16px; background-position: 0px -74px;}
\ No newline at end of file
.icon-send { width: 10px; height: 10px; background-position: -64px -44px;}
\ No newline at end of file
......@@ -55,7 +55,7 @@ export default {
goDetailPage(i){
this.$router.push({
path: '/psd/detail',
query: {id:i.id}
query: {id:i.id,name:i.materialName}
})
}
}
......
......@@ -22,13 +22,15 @@ export default {
shareToExternalMoments (i) {
this.sendMessage(i, true)
},
sendMessage (i, isPyq) {
async sendMessage (i, isPyq) {
const { shopmall_appid, envVersion } = window.$fetchConfig
const path = 'pages/psdView/psdView'
const { merchantId, uuid, sapCode } = this.getLocalStorage('dj_scrm_userInfo')
const { merchantId, uuid, sapCode, userName } = this.getLocalStorage('dj_scrm_userInfo')
const { entry } = this
const { materialName, id, titleUrl, materialTitle, description } = i
const { materialName, id, titleUrl, materialTitle, description, videoUrl, imageUrlList } = i
let fisrtFrame = videoUrl && await this.getVideoFirstFrame(videoUrl)
const imgUrl = 'https://img01.glsx.com.cn/weapp/resource/scrm-mobile/test/test.jpg'
let frameUrl = (imageUrlList && imageUrlList.length) ? imageUrlList[0] : (videoUrl && fisrtFrame && fisrtFrame.dataURL) ? fisrtFrame.dataURL : imgUrl
let query = `merchantId=${merchantId}&id=${id}&staffUuid=${uuid}&shareTime=${Date.now()}`
if (sapCode) query = `${query}&storeCode=${sapCode}`
......@@ -46,8 +48,8 @@ export default {
{
msgtype: 'link', // 消息类型,必填
link: {
title: materialTitle || materialName, // H5消息标题
imgUrl: titleUrl || imgUrl, // H5消息封面图片URL
title: materialTitle || `「${userName}」邀请您查看「${materialName}」` , // H5消息标题
imgUrl: titleUrl || frameUrl, // H5消息封面图片URL
url: link // H5消息页面url 必填
},
}
......@@ -62,9 +64,9 @@ export default {
} else {
let params = {
link,
title: materialTitle || materialName,
title: materialTitle || `「${userName}」邀请您查看「${materialName}」` ,
desc: description || '',
imgUrl: titleUrl || imgUrl
imgUrl: titleUrl || frameUrl
}
// if (entry != 'normal') this.sendChatMessage(params, { id, merchantId, uuid })
// else this.shareAppMessage(params, { id, merchantId, uuid })
......
......@@ -165,7 +165,43 @@ const watchPageBack = () => {
const centsToyuan = price => {
return decimal(price / 100, 2).toFixed(2)
}
const getVideoFirstFrame = (url)=> {
return new Promise(function (resolve) {
let dataURL = ''
let video = document.createElement("video")
video.setAttribute('crossOrigin', 'anonymous')//处理跨域
video.setAttribute('src', url)
video.setAttribute('autoplay', 'autoplay')
video.addEventListener('canplaythrough', function () {
video.setAttribute('width', video.videoWidth)
video.setAttribute('height', video.videoHeight)
let canvas = document.createElement("canvas"),
width = video.width, //canvas的尺寸和图片一样
height = video.height
canvas.width = width
canvas.height = height
canvas.getContext("2d").drawImage(video, 0, 0, width, height) //绘制canvas
dataURL = canvas.toDataURL('image/jpeg') //转换为base64
//转换成file
const arr = dataURL.split(",")
const mime = arr[0].match(/:(.*?);/)[1]
const bstr = window.atob(arr[1])
let n = bstr.length
const u8arr = new Uint8Array(n)
while (n--) {
u8arr[n] = bstr.charCodeAt(n)
}
const FILE = new File([u8arr], 'cover'+Date.now()+'.jpeg', { type: mime })
resolve({
dataURL, //预览路径
file:FILE, //上传的文件
})
})
})
}
const utils = {
getVideoFirstFrame,
removeLocalStorage,
setClipboardData,
jumpChildrenPage,
......
<template>
<div class="layout">
<div class="layout" v-if="loaded">
<div>
<template v-if="fileList && fileList.length">
<van-swipe @change="changeSwiper" :autoplay="autoplay" height="210" show-indicators>
<van-swipe-item v-for="(item, index) in fileList" :key="index">
<video id="swiper_video" v-if="item.type == 'video'" controls controlslist="nodownload" disablepictureinpicture playsinline="true" :src="item.url"></video>
<van-image width="100%" height="100%" fit="contain" v-if="item.type == 'image'" :src="item.url" />
<template v-if="(info.imageUrlList && info.imageUrlList.length) || info.videoUrl">
<van-swipe @change="changeSwiper" height="210" show-indicators>
<van-swipe-item v-if="info.videoUrl">
<video id="swiper_video" :autoplay="autoplay" :poster="poster" controls controlslist="nodownload" disablepictureinpicture playsinline="true" :src="info.videoUrl"></video>
</van-swipe-item>
<van-swipe-item v-for="(item, index) in info.imageUrlList" :key="index">
<van-image width="100%" height="100%" fit="cover" :src="item" />
</van-swipe-item>
<template #indicator>
<div class="custom-indicator">{{ curIdx + 1 }}/{{ fileList? fileList.length : 0 }}</div>
<div class="custom-indicator">{{ curIdx + 1 }}/{{ fileNum }}</div>
</template>
</van-swipe>
</template>
......@@ -43,28 +45,24 @@ export default {
fileList: [],
autoplay: 3000,
materialUrl: '',
info: {}
info: {},
fileNum: 0,
loaded: false,
poster: ''
}
},
beforeRouteEnter (to, from, next) {
let {query} = to
document.title = query.name || '详情'
next()
},
created() {
const { id } = this.getQuery()
// let id = 148
this.getDetail(id)
},
mounted() {
if(!this.info.videoUrl) return
const video = document.getElementById('swiper_video')
if(video){
video.addEventListener('play', ()=> {
this.autoplay = 0
})
video.addEventListener('pause', ()=> {
this.autoplay = 3000
})
video.addEventListener('ended', ()=> {
this.autoplay = 3000
}, false)
}
},
methods: {
......@@ -74,17 +72,36 @@ export default {
getDetail(id) {
marketingApi.getTextDetail({ id, flag: 0 }).then(data => {
if(data){
const fileList = []
if (data.videoUrl) {
fileList.push({ type: 'video', url: data.videoUrl })
}
if (data.imageUrlList && data.imageUrlList.length) {
data.imageUrlList.forEach(item => {
fileList.push({ type: 'image', url: item })
})
}
this.fileList = fileList
// const fileList = []
// if (data.videoUrl) {
// fileList.push({ type: 'video', url: data.videoUrl })
// }
// if (data.imageUrlList && data.imageUrlList.length) {
// data.imageUrlList.forEach(item => {
// fileList.push({ type: 'image', url: item })
// })
// }
// this.fileList = fileList
this.fileNum = data.imageUrlList && data.imageUrlList.length ? data.imageUrlList.length: 0
if(data.videoUrl) this.fileNum = this.fileNum + 1
this.info = data
this.loaded = true
if(!data.videoUrl) return;
this.getVideoFirstFrame(data.videoUrl).then(res => {
this.poster = res.dataURL
})
this.$nextTick(()=>{
const video = document.getElementById('swiper_video')
video.addEventListener('play', ()=> {
this.autoplay = 0
})
video.addEventListener('pause', ()=> {
this.autoplay = 3000
})
video.addEventListener('ended', ()=> {
this.autoplay = 3000
}, false)
})
}
})
}
......@@ -122,7 +139,7 @@ export default {
border-radius: 12px;
}
.rich-text {
margin-top: 20px;
padding-bottom: 120px;
}
.hide img {
width: 100%;
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!