detail.js 8.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241
  1. $(function(){
  2. var searchVal=window.location.search;
  3. if(searchVal && searchVal!=''){
  4. var tag=searchVal.indexOf("id=");
  5. if(tag>=0){
  6. var idArr=searchVal.split("=");
  7. var active_id=idArr[1];
  8. preLoadingInit();
  9. getCourseDetailData(active_id);
  10. }
  11. }
  12. })
  13. function preLoadingInit(){
  14. var clientHeight=$(window).height();
  15. var loadingheight=clientHeight-100;
  16. var text='<div style="height:'+loadingheight+'px;">'
  17. +'<div class="col-sm-2">'
  18. +'<div class="sp sp-circle"></div>'
  19. +'<h5 class="preloading">努力加载中...</h5>'
  20. +'</div>'
  21. +'</div>';
  22. $("#root").html(text);
  23. }
  24. function getCourseDetailData(target){
  25. var totalURL=gobalData.link;
  26. var requestURL=totalURL.course_detail;
  27. $.ajax({
  28. url:requestURL,
  29. type:'POST',
  30. dataType:'json',
  31. data:{
  32. spec_id:target
  33. },
  34. success:function(res){
  35. if(res.code=='1'){
  36. var _data=res.data;
  37. courseDetailInit(target,_data);
  38. }
  39. }
  40. });
  41. }
  42. function courseDetailInit(target,data){
  43. $("#root").empty();
  44. var deatilBrief='';
  45. if(data.brief!=''){
  46. deatilBrief=data.brief;
  47. }else{
  48. deatilBrief='<div style="width:100%;text-align:center;font-size:14px;color:#606266;">暂无简介</div>';
  49. }
  50. //console.log(data);
  51. var text='<div style="padding-bottom:10px;border-bottom:solid #DCDFE6 1px;">'
  52. +'<div style="margin-bottom:5px;width:100%;height:160px;border:solid #EBEEF5 1px;">'
  53. +'<img src="'+data.course_img+'" alt="" style="width:100%;height:100%;"/>'
  54. +'</div>'
  55. +'<div class="courseInfoItem">课程名称:'+data.course_name+'</div>'
  56. +'<div class="courseInfoItem">责任教师:'+data.teacher_name+'</div>'
  57. +'<div class="courseInfoItem">单位机构:'+data.teacher_organization+'</div>'
  58. +'</div>'
  59. //团队
  60. +'<div style="padding-bottom:10px;border-bottom:solid #DCDFE6 1px;">'
  61. +'<div style="font-size:14px;color:#303133;padding-top:10px;">课程安排</div>'
  62. +'<div style="width:100%;font-size:14px;color:#303133;padding:10px 0px 5px 0px;">'
  63. +'<table id="companyModel" border style="width:100%;">'
  64. +'<tr style="width:100%;">'
  65. +'<td style="width:15%;text-align:center;">时间</td>'
  66. +'<td style="width:60%;text-align:center;">授课内容</td>'
  67. +'<td style="width:25%;text-align:center;">授课教师</td>'
  68. +'</tr>'
  69. +'</table>'
  70. +'</div>'
  71. +'</div>'
  72. //内容简介
  73. +'<div style="padding:10px 0px 10px 0px;border-bottom:solid #DCDFE6 1px;font-size:14px;color:#606266;">'
  74. +deatilBrief
  75. +'</div>'
  76. //章节显示
  77. +'<div id="chapterModel" style="padding-top:5px;">'
  78. //+chapterText
  79. +'<div style="clear:both;"></div>'
  80. +'</div>'
  81. +'<div style="clear:both;"></div>';
  82. $("#root").html(text);
  83. getCompanyData(target);
  84. getChapterData(target);
  85. $("#closeVideo").on("tap",function(){
  86. $("#videoModel").empty();
  87. $("#closeVideo").hide();
  88. $("#videoModelWrapper").css({
  89. height:'0px'
  90. });
  91. });
  92. }
  93. function getChapterData(target){
  94. var totalURL=gobalData.link;
  95. var requestURL=totalURL.course_chapter;
  96. $.ajax({
  97. url:requestURL,
  98. type:'POST',
  99. dataType:'json',
  100. data:{
  101. spec_id:target,
  102. page:1,
  103. limit:10000
  104. },
  105. success:function(res){
  106. if(res.code=='1'){
  107. var _data=res.data;
  108. var text='';
  109. var len=_data.length;
  110. gobalData.chapterData=_data;
  111. if(len>0){
  112. for(var i=0;i<len;i++){
  113. var num=i+1;
  114. var chapterItem=_data[i];
  115. var chapterTitle=chapterItem.zj_name;
  116. text+='<div style="width:50%;float:left;padding:5px 0px 5px 0px;">'
  117. +'<div id="chapterItem_'+chapterItem.zj_id+'" '
  118. +'onclick="handleChapterItem(chapterItem_'+chapterItem.zj_id+')"'
  119. +'style="width:96%;margin:0 auto;">'
  120. +'<div style="width:100%;height:100px;border:solid #DCDFE6 1px;">'
  121. +'<img src="'+chapterItem.zj_img+'" alt="" '
  122. +'style="width:100%;height:100px;"/>'
  123. +'</div>'
  124. +'<div style="padding-top:5px;font-size:13px;color:#606266;">'
  125. +chapterTitle
  126. +'</div>'
  127. +'</div>'
  128. +'</div>';
  129. if(num%2==0){
  130. text+='<div style="clear:both;"></div>';
  131. }
  132. if(i==len-1){
  133. $("#chapterModel").append(text);
  134. }
  135. }
  136. }else{
  137. gobalData.chapterLoading = false;
  138. text='<div style="width:100%;text-align:center;font-size:14px;color:#606266;padding-top:10px;">'
  139. +'暂无章节'
  140. +'</div>';
  141. $("#chapterModel").append(text);
  142. }
  143. }
  144. }
  145. });
  146. }
  147. function getCompanyData(target){
  148. var totalURL=gobalData.link;
  149. var requestURL=totalURL.course_company;
  150. $.ajax({
  151. url:requestURL,
  152. type:'POST',
  153. dataType:'json',
  154. data:{
  155. spec_id:target,
  156. data_type:"json",
  157. page:1,
  158. limit:10000
  159. },
  160. success:function(res){
  161. if(res.code=='1'){
  162. var _data=res.data;
  163. var len=_data.length;
  164. var text='';
  165. if(len>0){
  166. for(var i=0;i<len;i++){
  167. var item=_data[i];
  168. text+='<tr style="width:100%;font-size:13px;color:#606266;">'
  169. +'<td style="width:15%;text-align:center;">'+item.name+'</td>'
  170. +'<td style="width:60%;text-align:center;">'+item.organization+'</td>'
  171. +'<td style="width:25%;text-align:center;">'+item.subject+'</td>'
  172. +'</tr>';
  173. if(i==len-1){
  174. $("#companyModel").append(text);
  175. }
  176. }
  177. }else{
  178. text='<tr style="width:100%;font-size:13px;color:#606266;">'
  179. +'<td colspan=3 align="center">'
  180. +'暂无数据'
  181. +'</td>'
  182. +'</tr>';
  183. $("#companyModel").append(text);
  184. }
  185. }
  186. }
  187. });
  188. }
  189. function handleChapterItem(target){
  190. var _id=target.id;
  191. var tag=_id.indexOf("_");
  192. if(tag>=0){
  193. var _idArr=_id.split("_");
  194. var activeId=_idArr[1];
  195. var _chapterData=gobalData.chapterData;
  196. for(var i in _chapterData){
  197. var item=_chapterData[i];
  198. if(item.zj_id==activeId){
  199. //console.log(item);
  200. $("#videoModel").empty();
  201. var videoLink=item.zj_video;
  202. var _videoLink=videoLink.trim();
  203. if(_videoLink!=''){
  204. var text='<video controls="controls" controlsList="nodownload" '
  205. +'x5-video-player-type="h5" x5-video-orientation="landscape"'
  206. +'poster="'+item.zj_img+'"'
  207. +'style="width:100%;height:100%;">'
  208. +'<source src="'+_videoLink+'" type="video/mp4">'
  209. +'您的浏览器不支持Video'
  210. +'</video>';
  211. var clientHeight=$(window).height();
  212. $("#videoModelWrapper").css({
  213. height:clientHeight+'px'
  214. });
  215. $("#videoModel").append(text);
  216. $("#closeVideo").show();
  217. //mui('#popover').popover('show');
  218. }else{
  219. mui.toast('此章节暂无视频',{ duration:'short', type:'div' });
  220. }
  221. }
  222. }
  223. }
  224. }