You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
148 lines
3.4 KiB
148 lines
3.4 KiB
|
|
<template>
|
|
<view class="" style="font-size: 0;position: relative;">
|
|
<BackButton />
|
|
<image v-if="agentInfo" @click="toWebView" class="bannerImg" mode="aspectFill" :src="showImg(agentInfo.posterUrl)"> </image>
|
|
|
|
</view>
|
|
</template>
|
|
|
|
<script>
|
|
import BackButton from "@/components/BackButton.vue";
|
|
export default{
|
|
components: {
|
|
BackButton,
|
|
},
|
|
data(){
|
|
return{
|
|
img:'',
|
|
agentId:'',
|
|
agentInfo:null
|
|
}
|
|
},
|
|
onLoad(e) {
|
|
wx.hideShareMenu()
|
|
this.agentId = e.id
|
|
this.getInfo()
|
|
},
|
|
onUnload() {
|
|
console.log("页面卸载,停止音频");
|
|
this.stopCurrentAudio();
|
|
},
|
|
onHide() {
|
|
console.log("页面隐藏,停止音频");
|
|
this.stopCurrentAudio();
|
|
},
|
|
methods:{
|
|
stopCurrentAudio() {
|
|
try {
|
|
const app = getApp();
|
|
// 检查是否有背景音乐实例
|
|
if (app.globalData.bgMusic) {
|
|
app.globalData.bgMusic.stop();
|
|
app.globalData.bgMusic.destroy();
|
|
app.globalData.bgMusic = null;
|
|
}
|
|
// 恢复初始音乐
|
|
if (app.globalData.initMusicSrc) {
|
|
app.updateMusicSrc(app.globalData.initMusicSrc);
|
|
app.initBackgroundMusic();
|
|
uni.$bgMusic.play(); // 播放音乐
|
|
}
|
|
console.log("音频已停止并恢复初始音乐");
|
|
} catch (error) {
|
|
console.error("停止音频时出错:", error);
|
|
}
|
|
},
|
|
getInfo(){
|
|
if(this.agentId==0){
|
|
this.Post(
|
|
{
|
|
},
|
|
"/framework/agent/"+this.agentId,
|
|
"DES"
|
|
).then((res) => {
|
|
if (res.code == 200) {
|
|
this.agentInfo = res.data
|
|
const app = getApp();
|
|
// 先停止当前音频
|
|
if (app.globalData.bgMusic) {
|
|
app.globalData.bgMusic.stop();
|
|
}
|
|
// 播放新的音频
|
|
app.updateMusicSrc(this.agentInfo.voiceUrl);
|
|
app.initBackgroundMusic(); // 初始化背景音乐
|
|
uni.$bgMusic.play(); // 播放音乐
|
|
} else {
|
|
uni.showToast({
|
|
title: res.msg,
|
|
icon: "none",
|
|
});
|
|
}
|
|
});
|
|
}else{
|
|
|
|
this.Post(
|
|
{
|
|
},
|
|
"/framework/benefitPackage/detail/"+this.agentId,
|
|
"DES"
|
|
).then((res) => {
|
|
if (res.code == 200) {
|
|
this.agentInfo = res.data.agent
|
|
this.agentStatus = res.data.agentStatus
|
|
const app = getApp();
|
|
// 先停止当前音频
|
|
if (app.globalData.bgMusic) {
|
|
app.globalData.bgMusic.stop();
|
|
}
|
|
// 播放新的音频
|
|
app.updateMusicSrc(this.agentInfo.voiceUrl);
|
|
app.initBackgroundMusic(); // 初始化背景音乐
|
|
uni.$bgMusic.play(); // 播放音乐
|
|
} else {
|
|
uni.showToast({
|
|
title: res.msg,
|
|
icon: "none",
|
|
});
|
|
}
|
|
});
|
|
}
|
|
|
|
},
|
|
toWebView() {
|
|
if(this.agentInfo.agentId==0){
|
|
uni.navigateTo({
|
|
url: "/pages/agent/index?id="+this.agentInfo.agentId
|
|
});
|
|
}else{
|
|
if(this.agentStatus){
|
|
uni.navigateTo({
|
|
url: "/pages/agent/index?id="+this.agentInfo.agentId
|
|
});
|
|
}else{
|
|
uni.showToast({
|
|
title: '为您跳转商品购买页~',
|
|
icon: 'none'
|
|
})
|
|
setTimeout(() =>{
|
|
uni.redirectTo({
|
|
url: "/subPackages/equityGoods/detail?id="+this.agentId
|
|
});
|
|
},900)
|
|
|
|
}
|
|
}
|
|
|
|
|
|
},
|
|
}
|
|
}
|
|
</script>
|
|
|
|
<style lang="scss" scoped>
|
|
.bannerImg{
|
|
width: 100vw;
|
|
height: 100vh;
|
|
}
|
|
</style>
|