console.log('sasdas')
var objs = {
    pageId:getItem('QrcodeIds'),
    sourceType:'',
    organizationIds:'root',
    userId:'1000111',
    userName:'张三',
};
var base64 = new Base64(),num = 0;
$.ajax({
    url: 'http://apptest.jieweizhineng.com/api/swagger/api/page/v1/detailPage',
    type: 'get',
    dataType: 'json',
    data:objs,
    success: function (res) {
        console.log(res.data.pageItemList);
        for (var i = 0; i < res.data.pageItemList.length; i++) {
            var mnum = num++ +1;
            if (res.data.pageItemList[i].pageRelation.businessType === "TEXT" && res.data.pageItemList[i].pageRelation.zIndex == mnum) {
                var str = `<div class="m-card">
                    <div class="header"><span>${res.data.pageItemList[i].textVo.title}</span></div>
                    <div class="content">
                        <p>${base64.decode(res.data.pageItemList[i].textVo.dataContent)}</p>
                    </div>
                </div>`;
                $('#contents').append(str)
            }else if (res.data.pageItemList[i].pageRelation.businessType === "IMAGE_TEXT" && res.data.pageItemList[i].pageRelation.zIndex == mnum) {
                var str = ` <div class="m-card">
                    <div class="header"><span>${res.data.pageItemList[i].imageText.title}</span></div>
                    <div class="content">
                        <img src="${res.data.pageItemList[i].imageText.imageUrl}">
                        <p>${base64.decode(res.data.pageItemList[i].imageText.dataContent)}</p>
                    </div>
                </div>`;
                $('#contents').append(str)
            }else if (res.data.pageItemList[i].pageRelation.businessType === "PICTURE" && res.data.pageItemList[i].pageRelation.zIndex == mnum) {
                var str = `<div class="mui-content-padded">
                        <div class="swiper-container">
                            <div class="swiper-wrapper">                          
                                                        
                               
                            </div>
                            <div class="swiper-pagination"></div>
                        </div>
                    </div>`;
                $('#contents').append(str);
                for (var j = 0; j < res.data.pageItemList[i].pictureList.length; j++) {
                    var html = `<div class="swiper-slide">
                                    <a href="${res.data.pageItemList[i].pictureList[j].imageLinking}">
                                        <img src="${res.data.pageItemList[i].pictureList[j].imageUrl}">
                                        <div class="banner-tit">
                                            <p>${res.data.pageItemList[i].pictureList[j].imageTitle}</p>                                        
                                        </div>
                                    </a>
                                </div> `;
                 $('.swiper-wrapper').append(html);
                    var swiper = new Swiper('.swiper-container', {
                        // autoplay: true,
                        loop:true,
                        pagination: {
                            el: '.swiper-pagination',
                            type: 'fraction',
                        },
                        autoplay: {
                            disableOnInteraction: false
                        }
                    });
                }
            } else if (res.data.pageItemList[i].pageRelation.businessType === "FILE" && res.data.pageItemList[i].pageRelation.zIndex == mnum) {
                var str = ` <div class="m-card file_items">
                    <div class="list-header"><span>${res.data.pageItemList[i].fileList[0].title}</span></div>
                        <div class="list-content file-content">
                            <div class="m-cell file_lists">
                            </div>
                        </div>
                    </div>`;
                $('#contents').append(str);
                var html ="";
                for (var j = 0; j < res.data.pageItemList[i].fileList.length; j++) {
                    var fileTyle = res.data.pageItemList[i].fileList[j].fileName.substring(res.data.pageItemList[i].fileList[j].fileName.length-3);
                    // console.log(fileTyle,'fileTyle')；
                    if(fileTyle == 'zip'){
                        html += `<div class="item">
                                <a class="cell-item" href="javascript:;">
                                    <div class="cell-left">
                                        <span class="cell-icon"><img src="image/${fileTyle}.png" style="height:0.6rem" /></span>
                                        <div class="title">
                                            <p class="main">${res.data.pageItemList[i].fileList[j].fileName}</p>
                                            <p class="sub">${res.data.pageItemList[i].fileList[j].fileSize}</p>
                                        </div>
                                    </div>
                                    <div class="cell-right cell-arrow"></div>
                                </a>
                                <div class="See_download">
                                    <button class="download"><a href="${res.data.pageItemList[i].fileList[j].filePath}">下载</a></button>
                                </div>
                          </div>`
                    }else if (fileTyle == 'pdf') {
                        html += `<div class="item">
                                <a class="cell-item" href="javascript:;">
                                    <div class="cell-left">
                                        <span class="cell-icon"><img src="image/${fileTyle}.png" style="height:0.6rem" /></span>
                                        <div class="title">
                                            <p class="main">${res.data.pageItemList[i].fileList[j].fileName}</p>
                                            <p class="sub">${res.data.pageItemList[i].fileList[j].fileSize}</p>
                                        </div>
                                    </div>
                                    <div class="cell-right cell-arrow"></div>
                                </a>
                                <div class="See_download">
                                    <button class="download downloadPDF">
                                    <a href="${res.data.pageItemList[i].fileList[j].filePath}" target="_blank">下载</a>
                                   
</button>
                                    <button class="See"><a href="${res.data.pageItemList[i].fileList[j].filePath}" target="_blank">预览</a></button>
                                </div>
                            </div>`
                    }else if (fileTyle == 'lsx') {
                        html += `<div class="item">
                                <a class="cell-item" href="javascript:;">
                                    <div class="cell-left">
                                        <span class="cell-icon"><img src="image/${fileTyle}.png" style="height:0.6rem" /></span>
                                        <div class="title">
                                            <p class="main">${res.data.pageItemList[i].fileList[j].fileName}</p>
                                            <p class="sub">${res.data.pageItemList[i].fileList[j].fileSize}</p>
                                        </div>
                                    </div>
                                    <div class="cell-right cell-arrow"></div>
                                </a>
                                <div class="See_download">
                                    <button class="download"><a href="${res.data.pageItemList[i].fileList[j].filePath}">下载</a></button>
                                    <button class="See seeXlsx" file-Url="${res.data.pageItemList[i].fileList[j].filePath}">预览</button>
                                </div>
                            </div>`;
                    }else if (fileTyle == 'doc') {
                        html += `<div class="item">
                                <a class="cell-item" href="javascript:;">
                                    <div class="cell-left">
                                        <span class="cell-icon"><img src="image/${fileTyle}.png" style="height:0.6rem" /></span>
                                        <div class="title">
                                            <p class="main">${res.data.pageItemList[i].fileList[j].fileName}</p>
                                            <p class="sub">${res.data.pageItemList[i].fileList[j].fileSize}</p>
                                        </div>
                                    </div>
                                    <div class="cell-right cell-arrow"></div>
                                </a>
                                <div class="See_download">
                                    <button class="download"><a href="${res.data.pageItemList[i].fileList[j].filePath}">下载</a></button>
                                    <button class="See seeDoc" file-Url="${res.data.pageItemList[i].fileList[j].filePath}">预览</button>
                                </div>
                            </div>`;
                    }else if (fileTyle == 'ptx' || fileTyle == 'ppt') {
                        html += `<div class="item">
                                <a class="cell-item" href="javascript:;">
                                    <div class="cell-left">
                                        <span class="cell-icon"><img src="image/${fileTyle}.png" style="height:0.6rem" /></span>
                                        <div class="title">
                                            <p class="main">${res.data.pageItemList[i].fileList[j].fileName}</p>
                                            <p class="sub">${res.data.pageItemList[i].fileList[j].fileSize}</p>
                                        </div>
                                    </div>
                                    <div class="cell-right cell-arrow"></div>
                                </a>
                                <div class="See_download">
                                    <button class="download"><a href="${res.data.pageItemList[i].fileList[j].filePath}">下载</a></button>
                                    <button class="See seePpt" file-Url="${res.data.pageItemList[i].fileList[j].filePath}">预览</button>
                                </div>
                            </div>`;
                    }
                    $('.file_items').html(html);
                }
            }else if (res.data.pageItemList[i].pageRelation.businessType === "LINKS" && res.data.pageItemList[i].pageRelation.zIndex == mnum) {
                var str = ` <div class="m-card">
                    <div class="list-header"><span>${res.data.pageItemList[i].linksList[0].title}</span></div>
                     <div class="list-content">
                        <div class="m-cell link_items">
                            
                        </div>
                      </div>
                    </div>`;
                $('#contents').append(str);
                for (var j = 0; j < res.data.pageItemList[i].linksList.length; j++) {
                    var html=`<a class="cell-item linkList" href="javascript:;" hrefs="${res.data.pageItemList[i].linksList[j].linkUrl}">
                                <div class="cell-left">
                                    <span class="cell-icon"><img src="image/link.png" /></span>
                                    <div class="title">
                                        <p class="main">${res.data.pageItemList[i].linksList[j].linkName}</p>
                                    </div>
                                </div>
                                <div class="cell-right">
                                    <i class="icon-share2"></i>
                                </div>
                            </a>`;
                    $('.link_items').append(html);
                }
            }else if (res.data.pageItemList[i].pageRelation.businessType === "EQUIPMENT" && res.data.pageItemList[i].pageRelation.zIndex == mnum) {
                var str = `
                    <div class="m-card">
                        <div class="header"><span>${res.data.pageItemList[i].equipmentList[0].title}</span></div>
                          <div class="content">
                            <div class="m-cell mingpai">
                                <div class="cell-item" style="border-bottom: 1px solid #D9D9D9;">
                                    <div class="cell cell-header">名称</div>
                                    <div class="cell cell-header">内容</div>
                                </div>
                                <div class="mingpai_list">
                                    
                                </div>
                                </div>
                            </div>
                        </div>
                    </div>`;
                $('#contents').append(str);
                for (var j = 0; j < res.data.pageItemList[i].equipmentList.length; j++) {
                    var html = `<div class="cell-item">
                                        <div class="cell">${res.data.pageItemList[i].equipmentList[j].paramName}</div>
                                        <div class="cell">${res.data.pageItemList[i].equipmentList[j].paramContent}</div>
                                 </div>`;
                $('.mingpai_list').append(html);

                }
            }

        }
    },
    error:function () {

    }
});
$('body').on('tap','.item .cell-item',function () {
    $(this).find('.cell-arrow').toggleClass('cell-arrowIco');
    $(this).parent().find('.See_download').toggleClass('show');
});
$('body').on('tap','.seeXlsx',function () {
    var url = $(this).attr('file-Url');
    window.open('https://view.officeapps.live.com/op/view.aspx?src='+url)
});
$('body').on('tap','.seeDoc',function () {
    var url = $(this).attr('file-Url');
    window.open('https://view.officeapps.live.com/op/view.aspx?src='+url)
});
$('body').on('tap','.seePpt',function () {
    var url = $(this).attr('file-Url');
    window.open('https://view.officeapps.live.com/op/view.aspx?src='+url)
});
$('body').on('tap','.linkList',function () {
    var url = $(this).attr('hrefs');
    location.href=url
});