PageSourceSearch

https://www.baiyinqu.gov.cn/cms_files/default/script/ajax/page/page.js

js baiyinqu.gov.cn collected 2026-10-02 05:34:58 UTC 10,703 bytes, 329 lines download raw bytes

1var laypage = layui.laypage
2if (/Android|webOS|iPhone|iPod|BlackBerry/i.test(navigator.userAgent)) {
3	var queryDataStr = $('.pagination').attr('queryData')
4	queryDataStr = queryDataStr.replace(/'/g, '"')
5	var queryData = JSON.parse(queryDataStr)
6	var pageNo = $('.pagination').attr('pageNo')
7	var rows = $('.pagination').attr('rows')
8	var unitid = $('.pagination').attr('unitid')
9	var count = $('.pagination').attr('count')
10	var cmsUrl = $('.pagination').attr('unitUrl')
11	var loading = false
12	if (parseInt(count) !== parseInt(rows) && parseInt(count) > parseInt(rows)) {
13		$('.pagination').html('<div class="more" style="height: 50px;line-height: 50px; text-align: center;">加载更多</div>')
14	}
15	var paramJson = {
16		pageNo: parseInt(pageNo),
17		pageSize: rows
18	}
19	$('.more').click(function () {
20		if (!loading) {
21			loading = true
22			checktoken()
23            count = $('.pagination').attr('count')
24			$(this).html('<i class="layui-icon layui-icon-loading layui-anim layui-anim-rotate layui-anim-loop"></i>')
25			paramJson.pageNo += 1
26			queryData.paramJson = JSON.stringify(paramJson)
27			ajaxDataIphone(queryData, cmsUrl, unitid)
28		}
29	})
30} else {
31	var pageNo = $('.pagination').attr('pageNo')
32	var rows = $('.pagination').attr('rows') // 初始条数
33	var rows1 = $('.pagination').attr('rows') // 记录初始条数用于全功能分页展示
34	var unitid = $('.pagination').attr('unitid')
35	var count = $('.pagination').attr('count')
36	var queryDataStr = $('.pagination').attr('queryData')
37	queryDataStr = queryDataStr.replace(/'/g, '"')
38	var queryData = JSON.parse(queryDataStr)
39	var cmsUrl = $('.pagination').attr('unitUrl')
40	layui.use('laypage', function () {
41		$('.pagination').each(function () {
42			var pageStyle = 'pageUpDown'
43			var pageColor = '#0C60FE'
44			if ($(this).attr('pagestyle') && $(this).attr('pagecolor')) {
45				var pageStyle = $(this).attr('pagestyle')
46				var pageColor = $(this).attr('pagecolor')
47			}
48			var layout = []
49			if (!pageColor) {
50				pageColor = '#0C60FE'
51			}
52			if (!pageStyle) {
53				pageStyle = 'simple'
54			}
55			if (pageStyle === 'simple') {
56				layout = ['prev', 'page', 'next']
57			} else if (pageStyle === 'pageUpDown') {
58				layout = ['prev', 'next']
59			} else if (pageStyle === 'all') {
60				layout = ['count', 'prev', 'page', 'next', 'limit', 'refresh', 'skip']
61			} else if (pageStyle === 'custom') {
62				layout = []
63			}
64			if (count > 0) {
65				if (pageStyle !== 'custom' && pageStyle !== 'noAroundPage') {
66					laypage.render({
67						elem: $('#' + unitid + ' .pagination'),
68						count: count,
69						limit: rows,
70						limits: [rows1, rows1 * 2, rows1 * 3, rows1 * 4, rows1 * 5],
71						curr: pageNo,
72						layout: layout,
73						theme: pageColor,
74						jump: function (obj, first) {
75							if (!first) {
76								checktoken()
77								var paramJson = {
78									pageNo: obj.curr
79								}
80								if (pageStyle === 'all') {
81									paramJson.pageSize = obj.limit
82									rows = obj.limit
83									pageNo = obj.curr
84								} else {
85									pageNo = obj.curr
86									paramJson.pageSize = rows
87								}
88								queryData.paramJson = JSON.stringify(paramJson)
89								ajaxDataPc(queryData, cmsUrl, unitid)
90							}
91						}
92					})
93				} else if ( pageStyle === 'noAroundPage' ){
94                    laypage.render({
95                        elem: $('#' + unitid + ' .pagination'),
96                        count: count,
97                        limit: rows,
98                        limits: [rows1, rows1 * 2, rows1 * 3, rows1 * 4, rows1 * 5],
99                        curr: pageNo,
100                        theme: pageColor,
101                        first: false,
102                        last: false,
103                        jump: function (obj, first) {
104                            if (!first) {
105                                checktoken()
106                                var paramJson = {
107                                    pageNo: obj.curr
108                                }
109                                if (pageStyle === 'all') {
110                                    paramJson.pageSize = obj.limit
111                                    rows = obj.limit
112                                    pageNo = obj.curr
113                                } else {
114                                    pageNo = obj.curr
115                                    paramJson.pageSize = rows
116                                }
117                                queryData.paramJson = JSON.stringify(paramJson)
118                                ajaxDataPc(queryData, cmsUrl, unitid)
119                            }
120                        }
121                    })
122				} else {
123					laypage.render({
124						elem: $('#' + unitid + ' .pagination'),
125						count: count,
126						limit: rows,
127						curr: pageNo,
128						first: '首页',
129						last: '尾页',
130						prev: '<em>←</em>',
131						next: '<em>→</em>',
132						layout: ['prev', 'page', 'next'],
133						theme: pageColor,
134						jump: function (obj, first) {
135							if (!first) {
136								checktoken()
137								var paramJson = {
138									pageNo: obj.curr,
139									pageSize: rows
140								}
141								queryData.paramJson = JSON.stringify(paramJson)
142								ajaxDataPc(queryData, cmsUrl, unitid)
143							}
144						}
145					})
146				}
147			} else {
148				if ($('#' + unitid + ' .page-none').length > 0) {
149					$('#' + unitid + ' .page-none').html('当前栏目暂无信息!')
150				} else {
151					$('#' + unitid + ' .page-content').after('<div class="page-none" style="margin: 120px;text-align: center;font-size: 22px;color: gray;">当前栏目暂无信息!</div>')
152				}
153			}
154		})
155	})
156}
157
158function checktoken () {
159	if (typeof isLogin === 'function') {
160		isLogin(false)
161	}
162}
163
164function ajaxDataIphone (queryData, url, unitid) {
165	$.ajax({
166		url: url,
167		type: 'get',
168		data: queryData,
169		success: function (result) {
170			var html = $('#' + unitid + ' .page-content').html() + $(result.data.html).children('.page-content').html()
171			$('#' + unitid + ' .page-content').html(html)
172			loading = false
173			if (paramJson.pageNo * paramJson.pageSize >= count) {
174				$('.pagination').html('')
175			} else {
176				$('.more').html('加载更多')
177			}
178            if (isOpenTran()) {
179                zh_tranBody()
180            }
181		},
182		error: function (error) {
183			loading = false
184			$('.more').html('加载失败')
185		}
186	})
187}
188
189function ajaxDataPc (queryData, url, unitid) {
190	$.ajax({
191		url: url,
192		type: 'get',
193		data: queryData,
194		success: function (result) {
195			$('#' + unitid + ' .page-content').load('#' + unitid + ' .page-content', function () {
196				$('#' + unitid + ' .page-content').html($(result.data.html).find('.page-content').html())
197				if (isOpenTran()) {
198				    zh_tranBody()
199				}
200				setTimeout(function () {
201					expiration();
202					dateReplace();
203				},0)
204			})
205		},
206		error: function (error) {}
207	})
208}
209
210// 获取cookie中数据
211function getCookie(a) {
212    var b = a + "=";
213    if (document.cookie.length > 0) {
214        offset = document.cookie.indexOf(b);
215        if (offset != -1) {
216            offset += b.length;
217            end = document.cookie.indexOf(";", offset);
218            if (end == -1) {
219                end = document.cookie.length
220            }
221            return unescape(document.cookie.substring(offset, end))
222        } else {
223            return ""
224        }
225    }
226}
227// 判断是否开启简繁体
228function isOpenTran() {
229  if (typeof String.prototype.tran === 'function') {
230	  var a = $("meta[name=WebId]").attr('content');
231	  var choose = getCookie("zh_choose_" + a)
232	  if (choose && choose !== 'n') {
233		  return true;
234	  }
235  }
236  return false;
237}
238// 信息前后缀根据有效期显示
239function expiration() {
240  var list = document.getElementsByClassName('prefixContent')
241  var listsuf = document.getElementsByClassName('suffixContent')
242  var now = new Date();
243  var startOfDay = new Date(now.getFullYear(), now.getMonth(), now.getDate(), 0, 0, 0, 0).getTime();
244  // let prefixContentlist = [...list, ...listsuf]
245	var prefixContentlist = []
246	for (var i = 0; i < list.length; i++) {
247		prefixContentlist.push(list[i])
248	}
249	for (var i = 0; i < listsuf.length; i++) {
250		prefixContentlist.push(listsuf[i])
251	}
252	for (var i = 0; i < prefixContentlist.length; i++) {
253		var overTime;
254    var origintime;
255		if (prefixContentlist[i].attributes && prefixContentlist[i].attributes.overtime) {
256			overTime = prefixContentlist[i].attributes.overtime.value
257		}
258		if (prefixContentlist[i].attributes && prefixContentlist[i].attributes.origintime) {
259			origintime = prefixContentlist[i].attributes.origintime.value
260		}
261    if (overTime && origintime) {
262      overTime = overTime * 1
263      origintime = origintime * 1
264      var value = prefixContentlist[i].style.display;
265      if (overTime > 0) {
266        let overDate = overTime * 86400000 + origintime
267        // 兼容历史数据
268        if(value === 'none'){
269            if (startOfDay <= overDate) {
270							prefixContentlist[i].style.display = "";
271            }
272        }else{
273            if (startOfDay > overDate) {
274							prefixContentlist[i].parentNode.removeChild(prefixContentlist[i])
275          }
276        }
277      }else if(overTime === -1){
278           if(value === 'none'){
279            prefixContentlist[i].style.display = "";
280           }else{
281            prefixContentlist[i].parentNode.removeChild(prefixContentlist[i])
282           }
283      }
284    }
285	}
286}
287// 日期替换今天、昨天、前天
288function dateReplace() {
289  var spans = document.getElementsByClassName('date-replace');
290  // 获取当前时间的Date对象
291  const currentDate = new Date();
292  // 获取今天的年月日
293  const today = new Date(currentDate.getFullYear(), currentDate.getMonth(), currentDate.getDate());
294  // 获取昨天的日期
295  const yesterday = new Date(currentDate.getFullYear(), currentDate.getMonth(), currentDate.getDate() - 1);
296  // 获取前天的日期
297  const beforeYesterday = new Date(currentDate.getFullYear(), currentDate.getMonth(), currentDate.getDate() - 2);
298
299  for(var i = 0; i < spans.length; i++) {
300    var item = spans[i]
301    // let timestamp = item.attributes.time.value
302		var timestamp
303		if (item.attributes && item.attributes.time) {
304			timestamp = item.attributes.time.value
305		}
306    if(timestamp){
307      // 将13位时间戳转换为JavaScript Date对象
308      const inputDate = new Date(timestamp*1);
309      // 比较并返回结果
310      let result = ''
311    if (inputDate >= today) {
312        result =  "今天";
313    } else if (inputDate >= yesterday && inputDate < today) {
314        result =  "昨天";
315    } else if (inputDate >= beforeYesterday && inputDate < yesterday) {
316        result =  "前天";
317    }
318    if(result !== ''){
319      // 替换每个元素的内容
320      spans[i].innerText = result;
321    }
322  }
323 }
324}
325// 模板重新渲染执行
326setTimeout(function () {
327	expiration();
328	dateReplace();
329}, 0)

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.