Limengbo преди 6 години
родител
ревизия
7906541f24
променени са 2 файла, в които са добавени 29 реда и са изтрити 30 реда
  1. 10 0
      index.html
  2. 19 30
      view/question.html

+ 10 - 0
index.html

@@ -13,5 +13,15 @@
         <img class="bg" src="./image/index/indexbg.jpg" alt="">
         <a href="./view/question.html" class="btn"></a>
     </div>
+    <script>
+    //获取用户信息
+     var jionData = {
+        "code": GetQueryString('code')
+     } 
+     alert(GetQueryString('code'))
+     ajaxData("https://readertest.lingjiao.cn/activity/wx/ucenter/wxlogin", '', jionData, function(userData) {
+        alert(userData.data);
+     })  
+    </script>
 </body>
 </html>

+ 19 - 30
view/question.html

@@ -18,7 +18,7 @@
         <div class="subject">
             <img class="inset" src="../image/question/inset.png" alt="inset">
             <img class="bottom" src="../image/question/bottom.png" alt="bottom">
-            <audio id="play" src="" autoplay="true">
+            <audio id="audio" src="https://efunbox.lingjiao.cn/activity/resource/201901004.mp3" autoplay="autoplay" loop="loop" style=" position: absolute;top: .5rem;left: .5rem;">
                 您的浏览器不支持 audio 标签。
             </audio>
             <div class="question-box"></div>
@@ -67,14 +67,6 @@
 </body>
 <script src="https://code.jquery.com/jquery-3.3.1.min.js"></script>
 <script>
-    //获取用户信息
-     var jionData = {
-        "code": GetQueryString('code')
-     } 
-     alert(GetQueryString('code'))
-     ajaxData("https://readertest.lingjiao.cn/activity/wx/ucenter/wxlogin", '', jionData, function(userData) {
-        alert(userData.data);
-     })  
     //获取Canvas对象(画布)
     var canvas = document.getElementById("myCanvas");
     var data = {
@@ -88,7 +80,7 @@
         ajaxData("https://readertest.lingjiao.cn/activity/activity", '7', data, function(result){
             var length = result.data.questionNum;
             if( ind >= length) {
-                $('.play').attr('src', "")
+                $('#audio').attr('src', "")
                 $('.popup').show();
                 //简单地检测当前浏览器是否支持Canvas对象,以免在一些不支持html5的浏览器中提示语法错误
                 if(canvas.getContext){  
@@ -154,7 +146,7 @@
     }
     // 渲染元素
     function renderDiv (ind, datas) {
-        $('.play').attr('src', datas.audio)
+        $('#audio').attr('src', datas.audio)
         var renders =  '<div class="audio">' + 
                         // '<audio src="'+ datas.audio +'" autoplay="autoplay" loop="loop">' +
                         //     '您的浏览器不支持 audio 标签。' +
@@ -171,11 +163,7 @@
                         '<li data-answer="C">'+ datas.optionC +'</li>' +
                     '</ul>'
         $('.question').eq(ind).prepend(renders);
-        setTimeout(function () {
-            alert(1);
-            audioAutoPlay('play');    
-        },1000)    
-         
+        // audioAutoPlay('audio');       
     }
     function canvasImg (ctx, url, x, y, w, h, success) {
         //创建新的图片对象
@@ -207,19 +195,20 @@
         };
     }
     // 解决苹果不能播放
-    function audioAutoPlay(id){
-      var audio = document.getElementById(id),
-    play = function(){
-      audio.play();
-      document.removeEventListener("touchstart",play, false);
-    };
-      document.addEventListener("WeixinJSBridgeReady", function () {//微信
-        play();
-      }, false);
-      document.addEventListener('YixinJSBridgeReady', function() {//易信
-        play();
-      }, false);
-      document.addEventListener("touchstart",play, false);
-    }
+//     function audioAutoPlay(id){
+//       var audio = document.getElementById(id),
+//     play = function(){
+//       audio.play();
+//       document.removeEventListener("touchstart",play, false);
+//     };
+//       document.addEventListener("WeixinJSBridgeReady", function () {//微信
+//         play();
+//       }, false);
+//       document.addEventListener('YixinJSBridgeReady', function() {//易信
+//         play();
+//       }, false);
+//         console.log(audio)
+//       document.addEventListener("touchstart",play, false);
+//     }
 </script>
 </html>