|
@@ -1,19 +1,22 @@
|
|
|
var utils = require("../utils");
|
|
|
var tipsMaskTmpl = __inline("../../tpl/tips-mask.tmpl");
|
|
|
+var videoTmpl = function(opts) {
|
|
|
+ return `<video preload="auto"
|
|
|
+ class="${utils.isMobile() && "full-screen"}"
|
|
|
+ src="${opts.url}"
|
|
|
+ poster="${opts.cover}"
|
|
|
+ x5-video-player-fullscreen="false"
|
|
|
+ loop
|
|
|
+ playsinline="true"
|
|
|
+ webkit-playsinline="true"
|
|
|
+ x5-video-player-type="h5">
|
|
|
+</video>`;
|
|
|
+};
|
|
|
|
|
|
class Index {
|
|
|
constructor() {
|
|
|
- this.init();
|
|
|
this.id = utils.getParam("id");
|
|
|
this.getVideoInfo();
|
|
|
- this.resize = false;
|
|
|
- if (utils.isMobile()) {
|
|
|
- this.onResize();
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- init() {
|
|
|
- this.bindEvent();
|
|
|
}
|
|
|
|
|
|
bindEvent() {
|
|
@@ -52,7 +55,6 @@ class Index {
|
|
|
}
|
|
|
|
|
|
onResize() {
|
|
|
- this.resize = true;
|
|
|
var $video = $("video").eq(0);
|
|
|
if (utils.isMobile()) {
|
|
|
$video.addClass("full-screen");
|
|
@@ -73,7 +75,7 @@ class Index {
|
|
|
alert("无法获取ID");
|
|
|
return;
|
|
|
}
|
|
|
- let API = "https://test-api-texiu.duowan.com/template/detail";
|
|
|
+ let API = "//api-texiu.duowan.com/template/detail";
|
|
|
let self = this;
|
|
|
$.ajax({
|
|
|
url: API,
|
|
@@ -88,15 +90,18 @@ class Index {
|
|
|
requsetCb(ret) {
|
|
|
var data = ret.data;
|
|
|
var self = this;
|
|
|
+ $(".page-share").prepend(videoTmpl(data));
|
|
|
+ this.bindEvent();
|
|
|
+ if (utils.isMobile()) {
|
|
|
+ this.onResize();
|
|
|
+ }
|
|
|
$("video")
|
|
|
.on("loadedmetadata", function() {
|
|
|
self.onResize();
|
|
|
})
|
|
|
.on("error", function(error) {
|
|
|
- alert(error);
|
|
|
+ alert(error.msg);
|
|
|
})
|
|
|
- .attr("poster", data.cover)
|
|
|
- .attr("src", data.url);
|
|
|
$("#title").text(data.description);
|
|
|
document.title = data.name;
|
|
|
}
|
|
@@ -122,7 +127,7 @@ class Index {
|
|
|
}
|
|
|
|
|
|
btnClick() {
|
|
|
- if (utils.isWechat()) {
|
|
|
+ if (utils.isMobileWechat()) {
|
|
|
$(".page-share").append($(tipsMaskTmpl({ isIos: utils.isIos() })));
|
|
|
} else {
|
|
|
this.openApp();
|