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.

151 lines
3.5 KiB

2 months ago
<template>
<view class="" style="font-size: 0;position: relative;">
<BackButton v-if="!isHidden" />
2 months ago
<image v-if="agentInfo" @click="toWebView" class="bannerImg" mode="aspectFill" :src="showImg(agentInfo.posterUrl)"> </image>
2 months ago
</view>
</template>
<script>
import BackButton from "@/components/BackButton.vue";
export default{
components: {
BackButton,
},
data(){
return{
2 months ago
img:'',
agentId:'',
agentInfo:null,
isHidden:false,
productId:''
2 months ago
}
},
2 months ago
onLoad(e) {
1 month ago
wx.hideShareMenu()
2 months ago
this.agentId = e.id
this.isHidden = e.isHidden
this.productId = e.product
2 months ago
this.getInfo()
2 months ago
},
2 months ago
onUnload() {
console.log("页面卸载,停止音频");
this.stopCurrentAudio();
},
onHide() {
console.log("页面隐藏,停止音频");
this.stopCurrentAudio();
},
2 months ago
methods:{
2 months ago
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);
}
},
2 months ago
getInfo(){
console.log('----')
if(!this.productId){
2 months ago
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.productId,
2 months ago
"DES"
).then((res) => {
if (res.code == 200) {
this.agentInfo = res.data.agent
1 month ago
this.agentStatus = res.data.agentStatus
2 months ago
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",
});
}
});
}
2 months ago
},
2 months ago
toWebView() {
2 months ago
if(this.agentInfo.agentId==0){
uni.navigateTo({
url: "/pages/agent/index?id="+this.agentInfo.agentId
});
}else{
1 month ago
if(this.agentStatus){
2 months ago
uni.navigateTo({
url: "/pages/agent/index?id="+this.agentInfo.agentId
});
}else{
2 months ago
uni.showToast({
title: '为您跳转商品购买页~',
icon: 'none'
})
setTimeout(() =>{
uni.redirectTo({
url: "/subPackages/equityGoods/detail?id="+this.productId
2 months ago
});
},900)
2 months ago
}
}
2 months ago
},
}
}
</script>
<style lang="scss" scoped>
.bannerImg{
width: 100vw;
2 months ago
height: 100vh;
2 months ago
}
</style>