$(function(){ // 详情地址要变, var ipurl = "", //ip地址 folder = "/xjnj/zxzx/", //文件夹名称 strurl = folder + "hd_xjxq.shtml", //详情页 上传到cms时把html改成shtml departmentid = "b36b28ce91204159b602d612cca92622"; //传的id var newipurl = "//www.xjnj.gov.cn", new_folder = "/xjnj/zxzx/", new_strurl = '/hd/hd_xjxq'; // 根据电话号码和查询码获取信件详情 // $('.btn-info').click(function(e){ // if ( e && e.preventdefault ) { // e.preventdefault(); // } else { // window.event.returnvalue = false; // }; // //获取手机号和查询码 // var phone = $('#phone').val(), // searchcode = $('#searchcode').val(); // phone = encrypt(phone); // phone = encodeuricomponent(phone); // var url = ipurl + "/communication/api-mailbox/frontmail/detailbyphoneandsearchcode?phone=" + phone + "&searchcode=" + searchcode; // if(phone == "" || searchcode == "") { // return alert('手机号码和查询码不能为空!'); // }; // $.ajax({ // url: url, // type: "get", // success:function(data) { // if(data.status == 'success') { // var url = strurl + '?phone=' + phone + '&searchcode=' + searchcode; // window.open(url); // }; // }, // error:function(data){ // return alert('没有找到该信件,请重新输入!'); // // console.log('error:' + json.stringify(data)); // } // }); // }); //分页的回调函数 function callback(index) { maillist(index,20,departmentid); } /* divname 导航选择器 npagecount 总页数; ncurrindex 当前页码; npagesize 每页条数; npesultcount 总条数 callback 回调函数; */ function ejscreatepagehtml(divname, npagecount, ncurrindex, npagesize, npesultcount, callback) { $('#' + divname).each(function () { var active = ""; var pagination_num = []; var num = 5; var con_text = '首页上一页'; for (var i = 0; i < num; i++) { var pagination_num_txt = ncurrindex - (num - 1) / 2 + i; active = (i == (num - 1) / 2) ? "active" : ""; pagination_num[i] = "" + pagination_num_txt + ""; if (pagination_num_txt > npagecount || pagination_num_txt < 1) { pagination_num[i] = ""; } con_text += pagination_num[i]; } con_text += '下一页末页' + "\ 每页 " + npagesize + " 条\ 共 " + npesultcount + " 条\ 共 " + npagecount + " 页\ 当前第 " + ncurrindex + " 页"; $(this).html(con_text); $(this).find('.pagination-first>a').on('click', function () { var txt = $(this).text(); if (txt == "首页" && ncurrindex != 1) { callback(1); } else if (txt == "末页" && ncurrindex != npagecount) { callback(npagecount); } else if (txt == "上一页" && ncurrindex > 1) { callback(ncurrindex - 1); } else if (txt == "下一页" && ncurrindex < npagecount) { callback(ncurrindex + 1); } else if (number(txt) && ncurrindex != number(txt)) { callback(number(txt)); }; }); }); }; //新建列表接口 function maillist(index,size,id) { var url = ipurl + "/communication/api-mailbox/frontmail/maillist"; var href = strurl; var data = { "pagenum": index, "pagesize": size, "sortmap":{ "createtime": "desc" }, "params":{ "phone": "", "searchcode": "", "deptid": id } }; $.ajax({ url: url, data: json.stringify(data), datatype: "json", type: "post", contenttype: "application/json", success: function (data) { if(data.status == 'success') { var datas = data.data, rows = datas.rows, html = '', _deptname=''; length = rows.length; //console.log(datas); //清除 $(".hd_list_detail").empty(); // 生成 if(length > 0){ for (var i = 0; i < rows.length; i++) { if(rows[i].deptname=='新疆维吾尔自治区人民政府'){ _deptname='新疆政府网'; }else{ _deptname=rows[i].deptname; } html += "
  • "; html += "

    信件标题:

    " + rows[i].title + "
    "; html += "

    类型:

    " + rows[i].objectivetype + "
    "; html += "

    办理情况:

    " + rows[i].status + "
    "; html += "

    来信人:

    " + rows[i].fromname + "
    "; html += "

    来信时间:

    " + rows[i].createtime + "
    "; html += "

    承办单位:

    " + _deptname + "
    "; html += "
  • "; } }; $('.hd_list_detail').append(html); // divname 导航选择器 // npagecount 总页数; // ncurrindex 当前页码; // npagesize 每页条数; // npesultcount 总条数 // callback 回调函数; ejscreatepagehtml("page_div",datas.pagetotal,datas.pagenum,datas.pagesize,datas.total,callback); } }, error: function (data) { console.log('error:' + json.stringify(data)); } }); }; maillist(1,20,departmentid); }); // aes 加密 var key = cryptojs.enc.utf8.parse("communication123"); function encrypt(word) { var srcs = cryptojs.enc.utf8.parse(word); var encrypted = cryptojs.aes.encrypt(srcs, key, { mode: cryptojs.mode.ecb, padding: cryptojs.pad.pkcs7 }); return encrypted.tostring(); }