/*
* 加载页面
*/
$(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 +='';
sv +='';
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 +='
';
sd +=''+videoName+'';
sd +=''+playCount+'次播放';
sd +='
';
sd +='';
sd +='
难度:';
sd +='
';
sd +='
';
sd +='';
sd +='简介:'+description;
sd +='
';
var $di = $(sd);
$("#videoInfo").append($di);
}
function addPlayCountDiv(playCount){
var sp = '';
sp +='播放次数:'+playCount+'次';
var $span = $(sp);
$("#playCount").append($span);
}
function addAuthorInfoDiv(authorAvatar,authorName,created,likeCount){
var sp = '';
sp += '
';
sp += '';
sp += ''+authorName+'';
sp += ''+created+'';
sp += '
';
sp += '';
sp += ''+likeCount+'';
sp += '';
sp += '
';
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 ='';
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 += '';
var $a = $(sa);
$("#download-btn").append($a);
}else{
alert(result.msg);
}
},
error:function(){
alert("连接失败!");
}
});
}
}