|
@@ -1,70 +0,0 @@
|
|
-import {post, imageUrlPrefix,getUrlArgObject,config, throttle} from './promise.js';
|
|
|
|
-(function(){
|
|
|
|
- getInfomation();
|
|
|
|
- function getInfomation(){
|
|
|
|
-
|
|
|
|
- var param = {
|
|
|
|
- "type": getUrlArgObject('type'),
|
|
|
|
- "questionId": getUrlArgObject('questionId'),
|
|
|
|
- "position": getUrlArgObject('position')
|
|
|
|
- };
|
|
|
|
- post(config.information, param).then((res) => {
|
|
|
|
- const data = res.data.data
|
|
|
|
- var str='',anchors='',item='';
|
|
|
|
- if(!data){
|
|
|
|
- $("h1").html("暂时没有数据");
|
|
|
|
- $(".anchors").css("display", "none");
|
|
|
|
- return;
|
|
|
|
- }
|
|
|
|
- var list = data.introduceDetailList;
|
|
|
|
- $("h1").html(data.tagName);
|
|
|
|
- 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="#' + item.id +
|
|
|
|
- '">' + item.title + '</a></li><li class="anchor-line"></li>';
|
|
|
|
- str = '<div class="title"><h2 id="' + item.id +
|
|
|
|
- '">' + '【'+ item.title + '】'+
|
|
|
|
- '</h2></div>' +
|
|
|
|
- '<div class="contentBox">' + item.content + '<div>';
|
|
|
|
- $(".infos").append(str);
|
|
|
|
- $(".anchors ul").append(anchors);
|
|
|
|
- }
|
|
|
|
- addLinkClickEvent();
|
|
|
|
- adjustHeight();
|
|
|
|
-
|
|
|
|
- function addScrollEvent() {
|
|
|
|
- var scrollTop = $('.infos').scrollTop()
|
|
|
|
- var divHeight = 0;
|
|
|
|
- for (var i = 0; i < list.length; i++) {
|
|
|
|
- divHeight = divHeight + parseInt($('#' + list[i].id).css('height')) + parseInt($('#' + list[i].id).parent().next().css('height')) +40
|
|
|
|
- if(divHeight > scrollTop) {
|
|
|
|
- var anchor = 2*i
|
|
|
|
-
|
|
|
|
- $('.anchors ul').children().eq(anchor).addClass('active').siblings().removeClass('active')
|
|
|
|
- return
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- $(".infos").scroll(throttle(addScrollEvent,200))
|
|
|
|
-
|
|
|
|
- })
|
|
|
|
-
|
|
|
|
-
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
-
|
|
|
|
- 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");
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
-})();
|
|
|