|
@@ -1,6 +1,6 @@
|
|
|
// var utils = require('/src/lib/utils.js')
|
|
|
-var utils = require('../utils')
|
|
|
-var tipsMaskTmpl = __inline('../../tpl/tips-mask.tmpl')
|
|
|
+var utils = require("../utils");
|
|
|
+var tipsMaskTmpl = __inline("../../tpl/tips-mask.tmpl");
|
|
|
class Index {
|
|
|
constructor() {
|
|
|
this.init();
|
|
@@ -13,75 +13,107 @@ class Index {
|
|
|
}
|
|
|
|
|
|
bindEvent() {
|
|
|
- var self = this
|
|
|
- $(".btn-play").on("touchend", function() {
|
|
|
- document.getElementsByTagName("video")[0].play();
|
|
|
- $('img').hide()
|
|
|
- $(this).hide();
|
|
|
- return false
|
|
|
+ var self = this;
|
|
|
+
|
|
|
+ $("body").on("click", ".mask-wrap", function() {
|
|
|
+ $(this).remove();
|
|
|
+ return false;
|
|
|
+ });
|
|
|
+
|
|
|
+ $(".btn").on("click", function(event) {
|
|
|
+ event.stopPropagation();
|
|
|
+ self.btnClick();
|
|
|
+ return false;
|
|
|
});
|
|
|
|
|
|
+ $("video")
|
|
|
+ .on("pause", function() {
|
|
|
+ $(".btn-play").show();
|
|
|
+ })
|
|
|
+ .on("play", function() {
|
|
|
+ $(".btn-play").hide();
|
|
|
+ });
|
|
|
|
|
|
- $('body').on('click', '.mask-wrap', function() {
|
|
|
- $(this).remove()
|
|
|
- return false
|
|
|
- })
|
|
|
-
|
|
|
+ var video = $("video").get(0);
|
|
|
|
|
|
- $('.btn').on('touchend',function() {
|
|
|
- self.btnClick()
|
|
|
- return false;
|
|
|
- })
|
|
|
+ $(".page-share").on("click", function() {
|
|
|
+ if (video.paused) {
|
|
|
+ video.play();
|
|
|
+ } else {
|
|
|
+ video.pause();
|
|
|
+ }
|
|
|
+ });
|
|
|
|
|
|
- $('video').on('pause', function() {
|
|
|
- $(".btn-play").show()
|
|
|
- }).on('click',function() {
|
|
|
- $(this).get(0).pause()
|
|
|
- })
|
|
|
+ $(window).on("resize", this.onResize);
|
|
|
}
|
|
|
+
|
|
|
+ onResize() {
|
|
|
+ var $video = $("video").eq(0);
|
|
|
+ $(".shade").css("visibility", "visible");
|
|
|
+ $('.btn-play').css("visibility", "visible");
|
|
|
+ $("#title").css({ left: $video.css("marginLeft") });
|
|
|
+ $(".btn").css({
|
|
|
+ right: `${parseFloat($video.css("marginRight").slice(0, -2)) +
|
|
|
+ 18}px`
|
|
|
+ });
|
|
|
+ }
|
|
|
+
|
|
|
getVideoInfo() {
|
|
|
if (!this.id) {
|
|
|
alert("无法获取ID");
|
|
|
return;
|
|
|
}
|
|
|
let API = "https://test-api-texiu.duowan.com/template/detail";
|
|
|
+ let self = this;
|
|
|
$.ajax({
|
|
|
url: API,
|
|
|
data: { id: this.id },
|
|
|
dataType: "json",
|
|
|
- success: this.requsetCb
|
|
|
+ success: function(ret) {
|
|
|
+ self.requsetCb(ret);
|
|
|
+ }
|
|
|
});
|
|
|
}
|
|
|
|
|
|
requsetCb(ret) {
|
|
|
var data = ret.data;
|
|
|
- $('img').attr('src',data.cover)
|
|
|
+ var self = this;
|
|
|
$("video")
|
|
|
.attr("poster", data.cover)
|
|
|
- .attr("src", data.url);
|
|
|
+ .attr("src", data.url)
|
|
|
+ .on("loadedmetadata", function() {
|
|
|
+ self.onResize();
|
|
|
+ });
|
|
|
$("#title").text(data.description);
|
|
|
document.title = data.name;
|
|
|
}
|
|
|
|
|
|
openApp() {
|
|
|
- var self = this
|
|
|
- var downloadLink = $('.btn').find('span').attr('href')
|
|
|
- // self.openApp('dwsupershow://toTemplateDetail?templateId=' + self.id)
|
|
|
- location.href = 'dwsupershow://toTemplateDetail?templateId=' + self.id
|
|
|
- if(downloadLink) {
|
|
|
- setTimeout(function() {
|
|
|
- if (document.hasFocus()) {
|
|
|
- location.href = downloadLink
|
|
|
- }
|
|
|
- },1500)
|
|
|
+ var self = this;
|
|
|
+ var downloadLink = $(".btn")
|
|
|
+ .find("span")
|
|
|
+ .data(utils.isMobile() ? "h5" : "pc");
|
|
|
+
|
|
|
+ if (utils.isMobile()) {
|
|
|
+ location.href =
|
|
|
+ "dwsupershow://toTemplateDetail?templateId=" + self.id;
|
|
|
+ if (downloadLink) {
|
|
|
+ setTimeout(function() {
|
|
|
+ if (document.hasFocus()) {
|
|
|
+ location.href = downloadLink;
|
|
|
+ }
|
|
|
+ }, 1500);
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ location.href = downloadLink;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
btnClick() {
|
|
|
- if( utils.isWechat()) {
|
|
|
- $('.page-share').append($(tipsMaskTmpl({isIos: utils.isIos()})))
|
|
|
+ if (utils.isWechat()) {
|
|
|
+ $(".page-share").append($(tipsMaskTmpl({ isIos: utils.isIos() })));
|
|
|
} else {
|
|
|
- this.openApp()
|
|
|
+ this.openApp();
|
|
|
}
|
|
|
}
|
|
|
}
|
|
@@ -89,4 +121,3 @@ class Index {
|
|
|
$(function() {
|
|
|
new Index();
|
|
|
});
|
|
|
-
|