Browse Source

:twisted_rightwards_arrows: merge branch 'dev_base' into dev_training

zhanghe 6 years ago
parent
commit
57d8a57bc2

+ 5 - 4
src/stage/index/scene/LessonScene.js

@@ -1,5 +1,6 @@
-import APIClient from '../../../util/API/APIClient'
-import Consts from '../../../util/Consts'
+import APIClient from '../../../util/API/APIClient';
+import Consts from '../../../util/Consts';
+import Utils from '../../../util/Utils';
 import HlsVideoPlugin from '../../../util/HlsVideoPlugin';
 import {CommandBus, CMD_TYPE} from '../../../util/CommandBus';
 
@@ -141,7 +142,7 @@ class LessonScene extends scene {
     		case Consts.TYPE_VIDEO:
     			let playUrl = '';
     			if (list && list.length >= 1) {
-    				playUrl = list[0].url;
+    				playUrl = Utils.videoUrlFormat(list[0].url);
     			}
     			let videoViewDom =
                 `
@@ -232,7 +233,7 @@ class LessonScene extends scene {
     		case Consts.TYPE_VIDEO:
     			let playUrl = '';
     			if (list && list.length >= 1) {
-    				playUrl = list[0].url;
+    				playUrl = Utils.videoUrlFormat(list[0].url);
     			}
     			let videoViewDom =
                 `

+ 2 - 1
src/stage/index/scene/VideoWareFullScreenScene.js

@@ -1,4 +1,5 @@
 import Consts from '../../../util/Consts';
+import Utils from '../../../util/Utils';
 import HlsVideoPlugin from '../../../util/HlsVideoPlugin';
 
 class VideoWareFullScreenScene extends scene {
@@ -86,7 +87,7 @@ class VideoWareFullScreenScene extends scene {
         const { list, type, title } = wareItem;
         let playUrl = '';
         if (list.length > 0) {
-          playUrl = list[0].url;
+          playUrl = Utils.videoUrlFormat(list[0].url);
         }
         if (window.efunbox) {
         	window.efunbox.initAndroidPlayer(

+ 2 - 2
src/util/Consts.js

@@ -11,8 +11,8 @@ class Consts {
 }
 
 //图片/视频资源域名
-Consts.IMG_PATH = 'http://ljimgs.ai160.com';
-Consts.VIDEO_PATH = 'http://ljvideo.ai160.com/vs2m';
+Consts.IMG_PATH = 'https://efunimgs.ai160.com';
+Consts.VIDEO_PATH = 'https://efunvideo.ai160.com';
 
 //图片/视频资源类型代号
 Consts.TYPE_VIDEO = 0;

+ 25 - 14
src/util/Utils.js

@@ -152,13 +152,13 @@ class Utils {
        return format;
     }
 
-  static trimJsonStr(src){
-    //所有"'" 替换为"\""
-    if(typeof(src) == "string"){
-      return src.replace(new RegExp("'","gm"), "\"");
+    static trimJsonStr(src){
+        //所有"'" 替换为"\""
+        if(typeof(src) == "string"){
+            return src.replace(new RegExp("'","gm"), "\"");
+        }
+        return src;
     }
-    return src;
-  }
 
 	/**
 	 * @desc uuid生成器
@@ -187,14 +187,25 @@ class Utils {
 		return uuid.join('');
 	}
 
-  static getUuidForWeb() {
-    const uuid = Utils.uuid(32);
-    const start = uuid.slice(0,8);
-    const next = uuid.slice(8,12);
-    const nextNext = uuid.slice(13,17);
-    const last = uuid.slice(17,32);
-    return `${start}-${next}-${nextNext}-${last}`;
-  }
+    static getUuidForWeb() {
+        const uuid = Utils.uuid(32);
+        const start = uuid.slice(0,8);
+        const next = uuid.slice(8,12);
+        const nextNext = uuid.slice(13,17);
+        const last = uuid.slice(17,32);
+        return `${start}-${next}-${nextNext}-${last}`;
+    }
+
+    static videoUrlFormat(url) {
+        if (!url) { return; }
+        if (url.startsWith('http')) {
+            return url.replace('http://ljvideo.ai160.com', Consts.VIDEO_PATH);
+        } else if (url.startsWith('https')) {
+            return url;
+        } else {
+            return url;
+        }
+    }
 }
 
 export default Utils;