|
|
@ -121,7 +121,7 @@ export default { |
|
|
|
touchStart(event) { |
|
|
|
this.startX = event.touches[0].pageX; |
|
|
|
this.startY = event.touches[0].pageY; |
|
|
|
console.log('开始触摸:', this.startX, this.startY); |
|
|
|
// console.log('开始触摸:', this.startX, this.startY); |
|
|
|
}, |
|
|
|
touchMove(event) { |
|
|
|
let currentX = event.touches[0].pageX; |
|
|
@ -152,10 +152,10 @@ export default { |
|
|
|
this.like_state = state; |
|
|
|
this.moveX = moveX; |
|
|
|
this.moveY = moveY; |
|
|
|
console.log('开始滑动:', this.moveX, this.moveY, this.like_state); |
|
|
|
// console.log('开始滑动:', this.moveX, this.moveY, this.like_state); |
|
|
|
}, |
|
|
|
touchEnd(event) { |
|
|
|
console.log(`移动距离:${Math.abs(this.moveX)}`); |
|
|
|
// console.log(`移动距离:${Math.abs(this.moveX)}`); |
|
|
|
// if (Math.abs(this.moveX) > 60 ) { |
|
|
|
// if (this.like_state == 1) { |
|
|
|
// this.itemIndex++; |
|
|
@ -198,27 +198,43 @@ export default { |
|
|
|
changIndex() { |
|
|
|
const _this = this; |
|
|
|
innerAudioContext.destroy(); |
|
|
|
_this.linkUrl = ''; |
|
|
|
console.log(this.itemLength) |
|
|
|
// 资源素材加载到最后一张时 - 下一页 |
|
|
|
if (_this.itemIndex == this.show_materials.length) { |
|
|
|
// clearInterval(_this.timer); |
|
|
|
console.log('最后一页啦') |
|
|
|
this.itemIndex = 0; |
|
|
|
this.flagIndex = 0; |
|
|
|
this.contentIndex = 0; |
|
|
|
} |
|
|
|
// 资源加载到第一张时 - 上一页 |
|
|
|
if (this.itemIndex == -1) { |
|
|
|
this.itemIndex = this.show_materials.length - 1; |
|
|
|
this.contentIndex = this.itemLength.length - 1; |
|
|
|
this.flagIndex = this.itemLength[this.contentIndex]; |
|
|
|
} |
|
|
|
if (this.flagIndex == 0) { |
|
|
|
if (this.flagIndex == -1) { |
|
|
|
// if(this.contentIndex == -1){ |
|
|
|
// this.contentIndex = this.itemLength.length - 1; |
|
|
|
// } |
|
|
|
// console.log('itemIndex',this.itemIndex) |
|
|
|
// console.log('flagIndex',this.flagIndex) |
|
|
|
// console.log('contentIndex',this.contentIndex) |
|
|
|
// console.log(this.materialsCont[this.contentIndex]) |
|
|
|
this.contentIndex--; |
|
|
|
this.flagIndex = this.itemLength[this.contentIndex]; |
|
|
|
} |
|
|
|
// 图片播放时间 |
|
|
|
_this.duration = this.show_materials[this.itemIndex].duration; |
|
|
|
// 资源地址-图片/视频 |
|
|
|
_this.linkUrl = this.show_materials[this.itemIndex].deposit_url; |
|
|
|
// 优先判断图片自带音频 |
|
|
|
if (this.show_materials[this.itemIndex].bgm_url) { |
|
|
|
_this.audioSrc = this.show_materials[this.itemIndex].bgm_url; |
|
|
|
_this.audioName = this.show_materials[this.itemIndex].bgm_name; |
|
|
|
} else { |
|
|
|
// 不同发布节点 |
|
|
|
if (this.contentIndex == this.itemLength.length) { |
|
|
|
this.flagIndex = 0; |
|
|
|
this.contentIndex = 0; |
|
|
@ -227,18 +243,25 @@ export default { |
|
|
|
if (this.flagIndex == this.itemLength[this.contentIndex]) { |
|
|
|
this.flagIndex = 0; |
|
|
|
this.contentIndex++; |
|
|
|
if (this.contentIndex == this.itemLength.length || _this.itemIndex == this.show_materials.length) { |
|
|
|
this.contentIndex = this.itemLength.length-1; |
|
|
|
this.flagIndex = this.itemLength[this.contentIndex]; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
// 图片无自带 - 再判断是否有BGM - main |
|
|
|
if (this.materialsCont[this.contentIndex].bgm_main) { |
|
|
|
this.audioSrc = this.materialsCont[this.contentIndex].bgm_main; |
|
|
|
this.audioName = this.materialsCont[this.contentIndex].bgm_name; |
|
|
|
} |
|
|
|
} |
|
|
|
// 当前资源是 - 视频 - 时,即销毁音频(防止干扰) |
|
|
|
if (this.show_materials[this.itemIndex].material_type == 1) { |
|
|
|
innerAudioContext.destroy() |
|
|
|
innerAudioContext.src = '' |
|
|
|
} |
|
|
|
// 销毁-创建音频-播放音频 |
|
|
|
innerAudioContext = uni.createInnerAudioContext(); |
|
|
|
this.playVoice(this.audioSrc); |
|
|
|
}, |
|
|
@ -306,34 +329,33 @@ export default { |
|
|
|
innerAudioContext.stop(); |
|
|
|
} |
|
|
|
innerAudioContext = uni.createInnerAudioContext(); |
|
|
|
// #ifdef APP-PLUS |
|
|
|
innerAudioContext.stop(); |
|
|
|
innerAudioContext.src = src; |
|
|
|
innerAudioContext.autoplay = true; |
|
|
|
innerAudioContext.loop = true; |
|
|
|
innerAudioContext.onPlay(() => { |
|
|
|
this.infoTxt = ''; |
|
|
|
this.infoTxt = '开始播放'; |
|
|
|
console.log('开始播放'); |
|
|
|
this.infoTxt = '音频开始播放'; |
|
|
|
// console.log('开始播放'); |
|
|
|
}); |
|
|
|
innerAudioContext.onError(res => { |
|
|
|
console.log(res.errMsg); |
|
|
|
console.log(res.errCode); |
|
|
|
if(this.show_materials[this.itemIndex].material_type != 1){ |
|
|
|
console.log(res.errMsg); |
|
|
|
console.log(res.errCode); |
|
|
|
innerAudioContext.destroy(); |
|
|
|
} |
|
|
|
// innerAudioContext.stop(); |
|
|
|
}); |
|
|
|
innerAudioContext.onPause(function() { |
|
|
|
console.log('onPause'); |
|
|
|
}); |
|
|
|
innerAudioContext.onStop(() => { |
|
|
|
//暂停监听 |
|
|
|
this.infoTxt = '停止'; |
|
|
|
console.log('停止'); |
|
|
|
this.infoTxt = '音频停止'; |
|
|
|
// console.log('停止'); |
|
|
|
}); |
|
|
|
innerAudioContext.onEnded(() => { |
|
|
|
this.infoTxt = '音频自然播放结束事件'; |
|
|
|
console.log('音频自然播放结束事件'); |
|
|
|
// console.log('音频自然播放结束事件'); |
|
|
|
}); |
|
|
|
// #endif |
|
|
|
}, |
|
|
|
countdown() { |
|
|
|
this.count = 6; |
|
|
|