Commit 1b916d55 by 李伟康

测试IOS播放音频

1 parent 9029c5f6
...@@ -68,6 +68,8 @@ ...@@ -68,6 +68,8 @@
.icon-music { .icon-music {
animation: move 3s infinite ease-in-out; animation: move 3s infinite ease-in-out;
border: 1px solid #fff;
border-radius: 100%;
} }
} }
} }
...@@ -108,6 +110,9 @@ ...@@ -108,6 +110,9 @@
z-index: 2; z-index: 2;
background: #E9E8EC; background: #E9E8EC;
box-sizing: border-box; box-sizing: border-box;
img{
object-fit: contain;
}
.line-box { .line-box {
position: absolute; position: absolute;
left: 0; left: 0;
...@@ -117,11 +122,11 @@ ...@@ -117,11 +122,11 @@
background: linear-gradient(360deg, #292929 0%, #474747 100%); background: linear-gradient(360deg, #292929 0%, #474747 100%);
.line { .line {
width: 54%; width: 73%;
height: 2px; height: 2px;
background: #fff; background: #fff;
border-radius: 1px; border-radius: 1px;
margin-left: 6px; margin-left: 4%;
} }
.duration{ .duration{
font-size: 8px; font-size: 8px;
......
...@@ -10,7 +10,7 @@ ...@@ -10,7 +10,7 @@
module.exports = { module.exports = {
title: '加载中...', title: '加载中...',
request: { request: {
baseURL: 'http://scrm.dev.glsx.com.cn', // 本地测试项目地址, baseURL: 'http://scrm.test.glsx.com.cn', // 本地测试项目地址,
// 设置超时时间 // 设置超时时间
timeout: 180000, timeout: 180000,
// 携带凭证 // 携带凭证
......
...@@ -43,7 +43,8 @@ const ua = navigator.userAgent.toLowerCase() ...@@ -43,7 +43,8 @@ const ua = navigator.userAgent.toLowerCase()
let body = document.getElementsByTagName('head')[0], let body = document.getElementsByTagName('head')[0],
WXJDK = document.createElement('script'), WXJDK = document.createElement('script'),
WWJDK = document.createElement('script'), WWJDK = document.createElement('script'),
ISWXWORK = false ISWXWORK = false,
IsIOS = /(iPhone|iPad|iPod|iOS)/i.test(navigator.userAgent)
WXJDK.src = '//res.wx.qq.com/open/js/jweixin-1.2.0.js' WXJDK.src = '//res.wx.qq.com/open/js/jweixin-1.2.0.js'
if (Boolean(ua.match(/MicroMessenger/i)) && Boolean(ua.match(/wxwork/i))) { //是否企微 if (Boolean(ua.match(/MicroMessenger/i)) && Boolean(ua.match(/wxwork/i))) { //是否企微
// WXJDK.src = '//res.wx.qq.com/open/js/jweixin-1.2.0.js' // WXJDK.src = '//res.wx.qq.com/open/js/jweixin-1.2.0.js'
...@@ -56,6 +57,8 @@ Vue.prototype.ISWXWORK = ISWXWORK ...@@ -56,6 +57,8 @@ Vue.prototype.ISWXWORK = ISWXWORK
Vue.prototype.ISMOBILE = util.isMobileDevice() Vue.prototype.ISMOBILE = util.isMobileDevice()
body.appendChild(WXJDK) body.appendChild(WXJDK)
if (WWJDK.src) body.appendChild(WWJDK) if (WWJDK.src) body.appendChild(WWJDK)
window.$IsIOS = IsIOS
Vue.prototype.IsIOS = IsIOS
const isMock = ['prod', 'production'].includes(process.env.NODE_ENV) const isMock = ['prod', 'production'].includes(process.env.NODE_ENV)
fetchConfig(!isMock).then(res => { fetchConfig(!isMock).then(res => {
// 从配置服务器获取动态配置 // 从配置服务器获取动态配置
......
export function Audio (url, callBack) { export function Audio (url, callBack) {
this.IsIOS = window.$IsIOS
this.audioContext = new (window.AudioContext || window.webkitAudioContext || window.mozAudioContext)() this.audioContext = new (window.AudioContext || window.webkitAudioContext || window.mozAudioContext)()
this.sourceNode = null this.sourceNode = null
this.buffer = null this.buffer = null
this.isPlayingBGM = false this.isPlayingBGM = false
if (this.IsIOS) {
let body = document.getElementsByTagName('body')[0]
this.audioContext = document.createElement('audio')
this.audioContext.src = url
this.audioContext.loop = true
body.appendChild(this.audioContext)
this.audioContext.ondurationchange = () => {
console.log('IOS播放——————————————')
this.audioContext.play()
}
}
this.toggleBGM = function (off) { this.toggleBGM = function (off) {
if (typeof this.sourceNode == 'object') { if (typeof this.sourceNode == 'object' && !this.IsIOS) {
if (this.isPlayingBGM || off) { if (this.isPlayingBGM || off) {
this.sourceNode.stop() this.sourceNode.stop()
this.isPlayingBGM = false this.isPlayingBGM = false
console.log('暂停——————————————', this.sourceNode) console.log('暂停——————————————', this.sourceNode)
} else this._playSourceNode() } else this._playSourceNode()
} else {
if (this.audioContext.paused) this.audioContext.play()
else this.audioContext.pause()
} }
} }
this.stopVideo = function () { this.stopVideo = function () {
if (typeof this.sourceNode == 'object') { if (typeof this.sourceNode == 'object' && !this.IsIOS) {
if (this.isPlayingBGM) { if (this.isPlayingBGM) {
this.sourceNode.stop() this.sourceNode.stop()
this.isPlayingBGM = false this.isPlayingBGM = false
console.log('暂停——————————————', this.sourceNode) console.log('暂停——————————————', this.sourceNode)
} }
} } else this.audioContext.pause()
} }
this._playSourceNode = function () { this._playSourceNode = function () {
const audioContext = this.audioContext const audioContext = this.audioContext
...@@ -34,6 +49,8 @@ export function Audio (url, callBack) { ...@@ -34,6 +49,8 @@ export function Audio (url, callBack) {
this.isPlayingBGM = true this.isPlayingBGM = true
} }
let loadAndAutoPlay = (audioUrl) => { let loadAndAutoPlay = (audioUrl) => {
alert(window.$IsIOS)
if (!this.IsIOS) {
const audioContext = this.audioContext const audioContext = this.audioContext
const xhr = new XMLHttpRequest() const xhr = new XMLHttpRequest()
let _this = this let _this = this
...@@ -59,6 +76,9 @@ export function Audio (url, callBack) { ...@@ -59,6 +76,9 @@ export function Audio (url, callBack) {
} }
} }
xhr.send() xhr.send()
} else {
callBack()
}
} }
loadAndAutoPlay(url) loadAndAutoPlay(url)
loadAndAutoPlay = null loadAndAutoPlay = null
......
...@@ -116,8 +116,8 @@ const setLocalStorage = (key, item) => { ...@@ -116,8 +116,8 @@ const setLocalStorage = (key, item) => {
} }
const getLocalStorage = key => { const getLocalStorage = key => {
let store = JSON.parse(window.localStorage.getItem(key)) let store = JSON.parse(window.localStorage.getItem(key))
if(key == 'wx_scrm_link_params') { if (key == 'wx_scrm_link_params') {
if(!store || Object.keys(store).length < 0 ){ if (!store || Object.keys(store).length < 0) {
store = getPageQuery() store = getPageQuery()
} }
} }
...@@ -245,9 +245,27 @@ const isMobileDevice = () => {//判断当前设备是否为移动端 ...@@ -245,9 +245,27 @@ const isMobileDevice = () => {//判断当前设备是否为移动端
} }
/**页面跳转 */ /**页面跳转 */
const jump = name =>{ const jump = name => {
console.log(this) console.log(this)
} }
/**秒数转天时分秒*/
const date_format = num => {
const addZero = i => i < 10 ? `0${i}` : `${i}`
//计算剩余的天数
let days = addZero(parseInt(num / 60 / 60 / 24, 10))
//计算剩余的小时
let hours = addZero(parseInt(num / 60 / 60 % 24, 10))
//计算剩余的分钟
let minutes = addZero(parseInt(num / 60 % 60, 10))
//计算剩余的秒数
let second = addZero(parseInt(num % 60, 10))
if (days == 0) {
return `${hours}:${minutes}:${second}`
}
return `${days}天${hours}:${minutes}:${second}`
}
const utils = { const utils = {
removeLocalStorage, removeLocalStorage,
setClipboardData, setClipboardData,
...@@ -269,7 +287,7 @@ const utils = { ...@@ -269,7 +287,7 @@ const utils = {
getUserInfo, getUserInfo,
hideLoading, hideLoading,
refreshPage, refreshPage,
date_format,
touchstart, touchstart,
showToast, showToast,
getParams, getParams,
......
...@@ -130,6 +130,7 @@ export default { ...@@ -130,6 +130,7 @@ export default {
if (detail.buyFlag == 2 || detail.activityStatus != 2) return if (detail.buyFlag == 2 || detail.activityStatus != 2) return
this.showModal = true this.showModal = true
}, },
/**明天继续这里添加车型 */
checkOut: util.debounce(({ obj, that }) => { checkOut: util.debounce(({ obj, that }) => {
let { detail } = that let { detail } = that
let { nickName, logo } = util.getUserInfo() let { nickName, logo } = util.getUserInfo()
......
...@@ -62,17 +62,17 @@ ...@@ -62,17 +62,17 @@
:ref="`video-${index}`" :ref="`video-${index}`"
:controls="false" :controls="false"
preload preload
@loadedmetadata="loadedmetadata($event,index)" @loadedmetadata="loadedmetadata($event)"
></video> ></video>
<div class="mask"> <div class="mask">
<img src="https://img02.glsx.com.cn/weapp/resource/h5/images/video-poster.png" /> <img :src="i.activityVideoCoverImage" />
<div :class="['sprite-icon xy-center',detail.activityVideos.length == 1 ?'icon-big-play':'icon-play']"></div> <div :class="['sprite-icon xy-center',detail.activityVideos.length == 1 ?'icon-big-play':'icon-play']"></div>
<div class="line-box flex"> <div class="line-box flex">
<div class="line"></div> <div class="line"></div>
<div <div
v-if="i.duration" v-if="i.activityVideoTime"
class="duration" class="duration"
>{{i.duration}}</div> >{{date_format(i.activityVideoTime)}}</div>
</div> </div>
</div> </div>
</div> </div>
...@@ -359,23 +359,7 @@ export default { ...@@ -359,23 +359,7 @@ export default {
}) })
}) })
}, },
loadedmetadata ({ srcElement }, index) { loadedmetadata ({ srcElement }) {
const addZero = i => i < 10 ? `0${i}` : `${i}`
function date_format (num) {
//计算剩余的天数
let days = addZero(parseInt(num / 60 / 60 / 24, 10))
//计算剩余的小时
let hours = addZero(parseInt(num / 60 / 60 % 24, 10))
//计算剩余的分钟
let minutes = addZero(parseInt(num / 60 % 60, 10))
//计算剩余的秒数
let second = addZero(parseInt(num % 60, 10))
if (days == 0) {
return `${hours}:${minutes}:${second}`
}
return `${days}天${hours}:${minutes}:${second}`
}
this.detail.activityVideos[index].duration = date_format(srcElement.duration)
srcElement.controls = false srcElement.controls = false
srcElement.addEventListener('webkitendfullscreen', () => { srcElement.addEventListener('webkitendfullscreen', () => {
let { audioFlag } = this let { audioFlag } = this
......
...@@ -41,9 +41,6 @@ export default { ...@@ -41,9 +41,6 @@ export default {
return return
} }
}, },
mounted () {
// this.drawOrderImg()
},
methods: { methods: {
drawOrderImg (orderInfo) { drawOrderImg (orderInfo) {
this.ctx = document.getElementById('canvas') this.ctx = document.getElementById('canvas')
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!