167 lines
4.5 KiB
JavaScript
167 lines
4.5 KiB
JavaScript
/*
|
|
* 加载页面
|
|
*/
|
|
$(function(){
|
|
function getParameter(param){
|
|
var query = window.location.search;
|
|
var iLen = param.length;
|
|
var iStart = query.indexOf(param);
|
|
if (iStart == -1)
|
|
return "";
|
|
iStart += iLen + 1;
|
|
var iEnd = query.indexOf("&", iStart);
|
|
if (iEnd == -1)
|
|
return query.substring(iStart);
|
|
return query.substring(iStart, iEnd);
|
|
}
|
|
var voiceid = getParameter("voiceid");
|
|
getload(voiceid);
|
|
getdownload();
|
|
|
|
})
|
|
|
|
function addVideo(videopic,soundURL){
|
|
var sv = '';
|
|
// sv +='<video id="videopic" controls poster="';
|
|
// sv +=videopic;
|
|
// sv +='"class="top-video">';
|
|
// sv +='<source id="video1" src="';
|
|
// sv +=soundURL;
|
|
// sv +='" class="top_video" type="video/mp4">';
|
|
// sv +='<source src="movie.ogg" type="video/ogg">';
|
|
// sv +=' 您的浏览器不能使用最新的视频播放方式呢 ';
|
|
// sv +='</video>';
|
|
sv +='<video class="play-area" controls="controls" poster="';
|
|
sv +=videopic
|
|
sv +='">';
|
|
sv +='<source src="';
|
|
sv +=soundURL;
|
|
sv +='" type="video/mp4">';
|
|
sv +=' 您的浏览器不支持 video 标签 ';
|
|
sv +='</video>';
|
|
var $vi = $(sv);
|
|
$("#video").append($vi);
|
|
}
|
|
|
|
function addVideoInfo(result){
|
|
var videoName = result.videoName;
|
|
var description = result.description;
|
|
var difficulty = result.difficulty;
|
|
var playCount = result.playCount;
|
|
|
|
var sd = '';
|
|
sd +='<h4>';
|
|
sd +='<span class="title">'+videoName+'</span>';
|
|
sd +='<span class="play-count"><i></i>'+playCount+'次播放</span>';
|
|
sd +='</h4>';
|
|
sd +='<div class="star-bar">';
|
|
sd +='<span>难度:</span>';
|
|
sd +='<div class="star star-'+difficulty+'"></div>';
|
|
sd +='</div>';
|
|
sd +='<p class="desc">';
|
|
sd +='简介:'+description;
|
|
sd +='</p>';
|
|
var $di = $(sd);
|
|
$("#videoInfo").append($di);
|
|
}
|
|
|
|
function addPlayCountDiv(playCount){
|
|
var sp = '';
|
|
sp +='<span><i></i>播放次数:'+playCount+'次</span>';
|
|
var $span = $(sp);
|
|
$("#playCount").append($span);
|
|
}
|
|
|
|
function addAuthorInfoDiv(authorAvatar,authorName,created,likeCount){
|
|
|
|
var sp = '';
|
|
sp += '<img class="user-pic" src="'+authorAvatar+'"/>';
|
|
sp += '<div class="user-info">';
|
|
sp += '<span class="user-name">'+authorName+'</span>';
|
|
sp += '<span class="item-date">'+created+'</span>';
|
|
sp += '</div>';
|
|
sp += '<div class="like">';
|
|
sp += '<i class="count">'+likeCount+'</i>';
|
|
sp += '<i class="like-btn"></i>';
|
|
sp += '</div>';
|
|
var $p = $(sp);
|
|
$("#authorInfo").append($p);
|
|
}
|
|
|
|
function getload(voiceid){
|
|
var host = window.location.host;
|
|
var url = "http://"+host+"/3eapi/http/3e/dub/share/shareById/v1";
|
|
$.ajax({
|
|
url:url,
|
|
// url:"http://123.57.248.179:8088/3eapi/http/3e/dub/share/shareById/v1",
|
|
// url:"http://padserver.3eenglish.com/3eapi/http/3e/dub/share/shareById/v1",
|
|
type:"post",
|
|
data:{"voiceid":voiceid},
|
|
dataType:"json",
|
|
success:function(result){
|
|
if(result.code=="OK"){//成功
|
|
var videopic = result.result.videopic;
|
|
var soundURL = result.result.soundURL;
|
|
|
|
|
|
var authorAvatar = result.result.explain.authorAvatar;
|
|
var authorName = result.result.explain.authorName;
|
|
var likeCount = result.result.likeCount;
|
|
|
|
var created = result.result.created;
|
|
|
|
addVideo(videopic,soundURL);
|
|
addVideoInfo(result.result);
|
|
addAuthorInfoDiv(authorAvatar,authorName,created,likeCount);
|
|
// addPlayCountDiv(playCount);
|
|
}else{
|
|
alert(result.msg);
|
|
}
|
|
},
|
|
error:function(){
|
|
alert("连接失败!");
|
|
}
|
|
});
|
|
}
|
|
|
|
function getdownload(){
|
|
var platform = navigator.platform;
|
|
var updateurl = "";
|
|
// Windows
|
|
// Android
|
|
// iPhone
|
|
var sUserAgent = navigator.userAgent.toLowerCase();
|
|
var isIphone = sUserAgent.match(/iphone/i) == "iphone";
|
|
var isAndroid = sUserAgent.match(/android/i) == "android";
|
|
var isWin = sUserAgent.match(/windows/i) == "windows";
|
|
if(isIphone){
|
|
var sa ='<a href="https://itunes.apple.com/cn/app/3e%E5%8F%A3%E8%AF%AD/id1156383347?mt=8" class="download-butten"></a>';
|
|
var $a = $(sa);
|
|
$("#download-btn").append($a);
|
|
}
|
|
if(isAndroid){
|
|
var host = window.location.host;
|
|
var url = "http://"+host+"/3eapi/http/3e/dub/share/getDownload/v1";
|
|
$.ajax({
|
|
url:url,
|
|
// url:"http://123.57.248.179:8088/3eapi/http/3e/dub/share/getDownload/v1",
|
|
// url:"http://padserver.3eenglish.com/3eapi/http/3e/dub/share/getDownload/v1",
|
|
type:"get",
|
|
dataType:"json",
|
|
success:function(result){
|
|
if(result.code=="OK"){//成功
|
|
updateurl = result.result.updateurl;
|
|
var sa = "";
|
|
sa += '<a href="'+updateurl+'" class="download-butten"></a>';
|
|
var $a = $(sa);
|
|
$("#download-btn").append($a);
|
|
}else{
|
|
alert(result.msg);
|
|
}
|
|
},
|
|
error:function(){
|
|
alert("连接失败!");
|
|
}
|
|
});
|
|
}
|
|
} |