123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114 |
- (function($){
- getInfomation();
- function getInfomation(){
- // var infoUrl ="http://" + window.location.host+'/icss-web/kl/introduce/get_by_itemidAndType';
- // var infoUrl ="http://" + window.location.host+'/api/icss/introduceInfo/getByQuestionId';
- var infoUrl ='http://192.168.2.236:5050/api/icss/introduceInfo/getByQuestionId'
- var imageUrlPrefix = 'http://192.168.2.236:82'
- var urlParam = parseUrlParams();
- console.log(urlParam)
- var param = {
- "type": urlParam.type,
- "questionId": urlParam.questionId,
- position:2
- };
- $.ajax({
- type: 'POST',
- url: infoUrl,
- data: JSON.stringify(param),
- headers: {
- // 'Accept': 'application/json, text/plain, */*',
- 'Content-Type':'application/json; charset=utf-8'
- },
- success: function(res) {
- console.log(res)
- var str='',anchors='',item='';
- if(!res.data){
- $("h1").html("暂时没有数据");
- return;
- }
- var list = res.data.introduceDetailList;
- $("h1").html(res.data.tagName);
- //list.map((item,i) =>{
- for(var i=0;i<list.length;i++) {
- item = list[i];
- item.content = item.content.replace(/{imageUrlPrefix}/g, imageUrlPrefix)
- anchors = '<li><i></i><a href="#anchor' + i +
- '">' + item.title + '</a></li><li class="anchor-line"></li>';
- str = '<div class="title"><h2 id="anchor' + i +
- '">' + item.title +
- '</h2><div class="line"></div></div>' +
- '<div>' + item.content + '<div>';
- $(".infos").append(str);
- $(".anchors ul").append(anchors);
- //});
- }
- addLinkClickEvent();
- adjustHeight();
- }
- })
- // $.post(infoUrl,param,function(res){
- // console.log('resssss', res)
- // if(res.ret == 0){
- // var str='',anchors='',item='';
- // if(!res.data){
- // $("h1").html("暂时没有数据");
- // return;
- // }
- // var list = res.data.introduceDetailList;
- // $("h1").html(res.data.shortName);
- // //list.map((item,i) =>{
- // for(var i=0;i<list.length;i++) {
- // item = list[i];
- // anchors = '<li><i></i><a href="#anchor' + i +
- // '">' + item.title + '</a></li><li class="anchor-line"></li>';
- // str = '<div class="title"><h2 id="anchor' + i +
- // '">' + item.title +
- // '</h2><div class="line"></div></div>' +
- // '<div>' + item.description + '<div>';
- // $(".infos").append(str);
- // $(".anchors ul").append(anchors);
- // //});
- // }
- // addLinkClickEvent();
- // adjustHeight();
- // }else{
- // $(".container").html(res.msg);
- // }
- // }
- // );
- }
- function parseUrlParams(){
- var url = window.location.search;
- var params = url.substring(1).split("&");
- var tmp = '',obj = {},it={};
- //params.map((it) =>{
- for(var i=0;i<params.length;i++) {
- it = params[i];
- tmp = it.split("=");
- if (tmp[0] && tmp[1]) {
- obj[tmp[0]] = tmp[1];
- }
- }
- //});
- return obj;
- }
- function addLinkClickEvent(){
- $("li:first").addClass("active");
- $("li>a").on("click",function(){
- $(".active").removeClass('active');
- $(this).parent().addClass("active");
- });
- }
- function adjustHeight(){
- var ht = window.innerHeight;
- $(".content").height(ht-145+"px");
- }
- })(jQuery);
|