USER-20230908AJ\Administrator 2 tahun lalu
induk
melakukan
1b51690988
1 mengubah file dengan 28 tambahan dan 0 penghapusan
  1. 28 0
      pages/index/index.vue

+ 28 - 0
pages/index/index.vue

@@ -125,6 +125,9 @@ import wxJs from "jweixin-module"
 				},
 				isAJAX:false,
 				index:0,
+        audioServe:undefined,
+        isPlay:false,
+        isAutoPlay:false,
 			}
 		},
 		onshow() {
@@ -136,8 +139,33 @@ import wxJs from "jweixin-module"
       if(isWeiXin){
         this.getJsConfig()
       }
+      this.musicPlay()
 		},
 		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
+        })
+
+      },
+      musicPause() {
+        if (this.audioServe) {
+          this.audioServe.pause();
+          this.audioServe.onPause(() => {
+            this.isPlay = false;
+          });
+        }
+
+      },
       getJsConfig(){
         console.log(window.location)
         let url = window.location.href.split('#')[0];