|
|
@@ -2,7 +2,8 @@
|
|
|
<view class="index-box box-border-box flex-common-css" @click.stop="play()">
|
|
|
<view class="flex-justify-space box-border-box plr-32">
|
|
|
<image class="logo-img" src="@/static/img/c-logo.png" mode="scaleToFill"></image>
|
|
|
- <image class="music-img" :class="isPlay?'music-anumation':''" src="@/static/img/c-music.png" mode="scaleToFill" @click.stop="musicPause()"></image>
|
|
|
+ <image class="music-img" v-if="!isIos" :class="isPlay?'music-anumation':'music-anumation'" src="@/static/img/c-music.png" mode="scaleToFill" @click.stop="musicPause()"></image>
|
|
|
+ <mumu-music v-else ref="musicObj" musicSrc='https://jhxcnc.oss-cn-chengdu.aliyuncs.com/mp3/4272600974.mp3'></mumu-music>
|
|
|
</view>
|
|
|
<swiper class="swiper" :vertical='true' @change="swiperChange">
|
|
|
<!-- 邀请函 -->
|
|
|
@@ -201,6 +202,7 @@
|
|
|
} from '@/api/user.js';
|
|
|
import tools from "@/service/tools";
|
|
|
import wxJs from "jweixin-module"
|
|
|
+ import { useBgMusic } from '@/uni_modules/y-bg-music/js_sdk';
|
|
|
export default {
|
|
|
components: {},
|
|
|
data() {
|
|
|
@@ -219,6 +221,7 @@
|
|
|
audioServe: undefined,
|
|
|
isPlay: false,
|
|
|
isAutoPlay: false,
|
|
|
+ isIos: true,
|
|
|
}
|
|
|
},
|
|
|
onshow() {
|
|
|
@@ -231,39 +234,64 @@
|
|
|
this.getJsConfig()
|
|
|
}
|
|
|
// this.musicPlay()
|
|
|
+ const isiOS = /iPad|iPhone|iPod/.test(navigator.userAgent) && !window.MSStream;
|
|
|
+ this.isIos=isiOS
|
|
|
+ if (isiOS) {
|
|
|
+ console.log('This is an iOS device');
|
|
|
+ } else {
|
|
|
+ this.audioServe = useBgMusic({
|
|
|
+ src: './static/mp3/4272600974.mp3',
|
|
|
+ loop: 999, // 循环次数
|
|
|
+ controls:false // 显示右上角控制元素
|
|
|
+ });
|
|
|
+ }
|
|
|
},
|
|
|
methods: {
|
|
|
musicPlay() {
|
|
|
- if (!this.audioServe) {
|
|
|
- this.audioServe = uni.createInnerAudioContext();
|
|
|
- this.audioServe.autoplay = true;
|
|
|
- this.audioServe.loop = true;
|
|
|
- this.audioServe.obeyMuteSwitch = true;
|
|
|
- this.audioServe.src = 'https://jhnewshop.oss-cn-chengdu.aliyuncs.com/RockHouseJail.mp3';
|
|
|
- }
|
|
|
- this.audioServe.play();
|
|
|
- this.audioServe.onPlay(() => {
|
|
|
- this.isPlay = true;
|
|
|
- this.isAutoPlay = true
|
|
|
- })
|
|
|
-
|
|
|
- },
|
|
|
+ // if (!this.audioServe) {
|
|
|
+ // this.audioServe = uni.createInnerAudioContext();
|
|
|
+ // this.audioServe.autoplay = true;
|
|
|
+ // this.audioServe.loop = true;
|
|
|
+ // this.audioServe.obeyMuteSwitch = true;
|
|
|
+ // this.audioServe.src = 'https://jhxcnc.oss-cn-chengdu.aliyuncs.com/mp3/4272600974.mp3';
|
|
|
+ // }
|
|
|
+ // this.audioServe.play();
|
|
|
+ // this.audioServe.onPlay(() => {
|
|
|
+ // this.isPlay = true;
|
|
|
+ // this.isAutoPlay = true
|
|
|
+ // })
|
|
|
+
|
|
|
+ // 创建bgAudioManager对象
|
|
|
+// const bgAudioManager = uni.getBackgroundAudioManager();
|
|
|
+// bgAudioManager.src = 'https://jhxcnc.oss-cn-chengdu.aliyuncs.com/mp3/4272600974.mp3';
|
|
|
+// // 开始播放的回调函数
|
|
|
+// bgAudioManager.onPlay(() => {
|
|
|
+// console.log('开始播放');
|
|
|
+// });
|
|
|
+// // 播放报错的事件监听
|
|
|
+// bgAudioManager.onError((res) => {
|
|
|
+// console.log(res.errMsg);
|
|
|
+// console.log(res.errCode);
|
|
|
+// });
|
|
|
+
|
|
|
+
|
|
|
+ },
|
|
|
play() {
|
|
|
- if (!this.isPlay && this.audioServe) {
|
|
|
- this.audioServe.play();
|
|
|
- this.audioServe.onPlay(() => {
|
|
|
- this.isPlay = true;
|
|
|
- this.isAutoPlay = true
|
|
|
- })
|
|
|
+ if (!this.isPlay && this.audioServe ) {
|
|
|
+ // this.audioServe.play();
|
|
|
+ // this.audioServe.onPlay(() => {
|
|
|
+ // this.isPlay = true;
|
|
|
+ // this.isAutoPlay = true
|
|
|
+ // })
|
|
|
}
|
|
|
},
|
|
|
musicPause() {
|
|
|
- if (this.audioServe) {
|
|
|
- this.audioServe.pause();
|
|
|
- this.audioServe.onPause(() => {
|
|
|
- this.isPlay = false;
|
|
|
- });
|
|
|
- }
|
|
|
+ // if (this.audioServe) {
|
|
|
+ // this.audioServe.pause();
|
|
|
+ // this.audioServe.onPause(() => {
|
|
|
+ // this.isPlay = false;
|
|
|
+ // });
|
|
|
+ // }
|
|
|
|
|
|
},
|
|
|
getJsConfig() {
|
|
|
@@ -282,12 +310,13 @@
|
|
|
jsApiList: ['updateAppMessageShareData', 'updateTimelineShareData']
|
|
|
})
|
|
|
wxJs.ready(() => {
|
|
|
+
|
|
|
//自定义“分享给朋友”
|
|
|
// this.musicPlay()
|
|
|
wxJs.updateAppMessageShareData({
|
|
|
title: '振合网“实体联盟”招商说明会-邀请函',
|
|
|
desc: '10月20日我们不见不散!',
|
|
|
- link: "https://enroll.jhcs888.com/#/", // 分享链接,该链接域名或路径必须与当前页面对应的公众号 JS 安全域名一致
|
|
|
+ link: "https://enroll.jhcs888.com", // 分享链接,该链接域名或路径必须与当前页面对应的公众号 JS 安全域名一致
|
|
|
imgUrl: 'https://jhnewshop.oss-cn-chengdu.aliyuncs.com/storage/attest/20210927/949e48fb7c286836097efdd4ba4d0bd9.jpg', // 分享图标
|
|
|
success: function() {
|
|
|
// 设置成功
|
|
|
@@ -297,12 +326,17 @@
|
|
|
wxJs.updateTimelineShareData({
|
|
|
title: '振合网“实体联盟”招商说明会-邀请函',
|
|
|
desc: '10月20日我们不见不散!',
|
|
|
- link: "https://enroll.jhcs888.com/#/", // 分享链接,该链接域名或路径必须与当前页面对应的公众号 JS 安全域名一致
|
|
|
+ link: "https://enroll.jhcs888.com", // 分享链接,该链接域名或路径必须与当前页面对应的公众号 JS 安全域名一致
|
|
|
imgUrl: 'https://jhnewshop.oss-cn-chengdu.aliyuncs.com/storage/attest/20210927/949e48fb7c286836097efdd4ba4d0bd9.jpg', // 分享图标
|
|
|
success: function() {
|
|
|
// 设置成功
|
|
|
}
|
|
|
})
|
|
|
+ if(this.audioServe){
|
|
|
+ this.audioServe.play();
|
|
|
+ }else if (!this.isIos){
|
|
|
+ this.$refs.musicObj.playTo()
|
|
|
+ }
|
|
|
});
|
|
|
}
|
|
|
})
|
|
|
@@ -314,6 +348,7 @@
|
|
|
},
|
|
|
|
|
|
swiperChange(e) {
|
|
|
+ console.log('aaaaaaaaaaaaaaaaaaaaaaaaaaaa')
|
|
|
this.play()
|
|
|
if (e.detail.current != this.index) {
|
|
|
this.index = e.detail.current;
|