123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169 |
- const Config = {
- title: "陕西广电融媒体集团",
- logoUrl: "http://zyx-data-base.oss-cn-beijing.aliyuncs.com/img/logonew2.png",
- baseUrl: "http://topic.smcic.net",
- };
- document.title = Config.title;
- $(".proName").append(
- $(
- "<img src='" +
- Config.logoUrl +
- "' alt='" +
- Config.title +
- "' class='img-rounded'>"
- )
- );
- const pageName = getPageName();
- if (/skeleton/.test(pageName) && !localStorage.login) {
- location.href = "./index.html";
- }
- function getPageName() {
- const pathList = location.href.split("/");
- return pathList[pathList.length - 1];
- }
- function getsearch() {
- const searchLi = location.search.replace("?", "").split("&");
- const search = {};
- for (let i = 0; i < searchLi.length; i++) {
- const v = searchLi[i];
- const li = v.split("=");
- if (!li.length) continue;
- search[li[0]] = decodeURI(li[1]);
- }
- return search;
- }
- function showAlert(text, s) {
- let ele = $(
- "<div id='local-alert'><i class='glyphicon glyphicon-info-sign'></i>" +
- text +
- "</div>"
- );
- $(document.body).prepend(ele);
- let timeout;
- timeout = window.setTimeout(() => {
- window.clearTimeout(timeout);
- $("#local-alert").addClass("fadeOutRightBig animated infinite");
- timeout = window.setTimeout(() => {
- window.clearTimeout(timeout);
- $("#local-alert").remove();
- }, 500);
- }, s || 2000);
- }
- function createTable(ele, theadList, list) {
- $(ele + " .localtable").remove();
- const pele = $(ele);
- const table = $("<table class='table localtable'></table>");
- const thead = $("<thead></thead>");
- const tbody = $("<tbody></tbody>");
- const trHead = $("<tr></tr>");
- const theadListL = theadList || [];
- const listL = list || [];
- theadListL.map((v, i) => {
- const td = $(
- "<td class='" +
- v.className +
- " " +
- (i % 2 === 1 ? "deepBlue" : "") +
- "'>" +
- v.title +
- "</td>"
- );
- trHead.append(td);
- });
- listL.map((v, o) => {
- let className = o % 2 === 1 ? "oddRow" : "";
- const trBody = $("<tr class='" + className + "'></tr>");
- theadListL.map(titleI => {
- let val = titleI.value === "#index" ? o + 1 : v[titleI.value];
- titleI.formatValue && (val = titleI.formatValue(val));
- const td = $("<td class='" + titleI.className + "'>" + val + "</td>");
- trBody.append(td);
- });
- tbody.append(trBody);
- });
- thead.append(trHead);
- table.append(thead);
- table.append(tbody);
- pele.append(table);
- }
- function createPager(totalPage, pageIndex, pele, section) {
- $("nav.localnavigation").remove();
- let sectionReal = section || 2;
- const nav = $(
- "<nav class='localnavigation' aria-label='Page navigation'></nav>"
- );
- const ul = $(
- "<ul class='pagination'><li class='proPage'><a href='##' aria-label='Previous'><span aria-hidden='true'>«</span></a></li></ul>"
- );
- const next = $(
- '<li class="nextPage"><a href="##" aria-label="Next"><span aria-hidden="true">»</span></a></li>'
- );
- const minPage = pageIndex - sectionReal > 1 ? pageIndex - sectionReal : 1;
- const maxPage =
- pageIndex + sectionReal < totalPage ? pageIndex + sectionReal : totalPage;
- if (minPage !== 1) {
- ul.append($("<li class='inPage'><a href='##'>1</a></li>"));
- ul.append($("<li><a href='##'>...</a></li>"));
- }
- for (let i = minPage; i <= maxPage; i++) {
- let li = $(
- "<li class='inPage " +
- (i == pageIndex ? "selectPage" : "") +
- "'><a href='##'>" +
- i +
- "</a></li>"
- );
- ul.append(li);
- }
- if (maxPage !== totalPage) {
- ul.append($("<li><a href='##'>...</a></li>"));
- ul.append($("<li class='inPage'><a href='##'>" + totalPage + "</a></li>"));
- }
- ul.append(next);
- nav.append(ul);
- $(pele).append(nav);
- }
- function formatnum(text) {
- let num = text;
- if (isNaN(text)) num = 0;
- if (text >= 100000000) num = (text / 100000000).toFixed(2) - 0 + "亿";
- if (text >= 10000) num = (text / 10000).toFixed(2) - 0 + "万";
- return num;
- }
- function require(type, conf) {
- return new Promise((resolve, reject) => {
- let D = {},
- ct = "application/json";
- D = type === "POST" ? JSON.stringify(conf.data || {}) : conf.data || {};
- $.ajax({
- url: Config.baseUrl + conf.url,
- contentType: ct,
- dataType: "json",
- type: type || "GET",
- headers: {
- Authorization: localStorage.token,
- },
- cache: false,
- data: D,
- success: function (data) {
- if (data.code !== 0) {
- showAlert(data.message);
- reject(data.message);
- } else resolve(data.data);
- },
- complete() {},
- error(err) {
- showAlert(err.responseJSON ? err.responseJSON.message : "错误");
- reject(err);
- },
- });
- });
- }
|