123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295 |
- var tab;
- layui.config({
- base : "js/"
- }).use(['form', 'layer', 'jquery', 'element', 'laypage'], function () {
- var form = layui.form(),
- layer = parent.layer === undefined ? layui.layer : parent.layer,
- laypage = layui.laypage,
- $ = layui.jquery;
- //加载页面数据
- var newsData = '';
- var txtkeywords = "";
- var myPageSize = 50;
- function LoadDataList(pageSize, page, keywords)
- {
- var index = layer.msg('查询中,请稍候', { icon: 16, time: false, shade: 0.8 });
- $.get("/BackgroundProcess.aspx?type=pushuserlist&page=" + page + "&pageSize=" + pageSize + "&keywords=" + keywords, function (data) {
- // var newArray = [];
- //正常加载信息
- var tempDataObj = JSON.parse(data);
- // console.log(data);
- // console.log(tempDataObj);
- if (tempDataObj["code"] == 200) {
- //console.log(tempDataObj["data"]);
- //执行加载数据的方法
- newsData = tempDataObj["data"];
- newsList(newsData);
- } else {
- layer.msg("加载数据失败:" + tempDataObj["info"]);
- }
- layer.close(index);
- })
- }
- LoadDataList(myPageSize, 1, "");
- //查询
- $(".search_btn").click(function () {
- txtkeywords = $(".search_input").val();
- var newArray = [];
- LoadDataList(myPageSize, 1, txtkeywords);
-
- //if($(".search_input").val() != ''){
-
-
- //}else{
- // layer.msg("请输入需要查询的内容");
- //}
- })
- function DelData(delIDs)
- {
- var index = layer.msg('正在删除,请稍候', { icon: 16, time: false, shade: 0.8 });
- $.get("/BackgroundProcess.aspx?type=delpushuser&delID=" + delIDs, function (data) {
- var tempDataObj = JSON.parse(data);
- if (tempDataObj["code"] == 200) {
- $('.news_list thead input[type="checkbox"]').prop("checked", false);
- form.render();
- layer.msg("删除成功");
- LoadDataList(myPageSize, 1, "");
- } else {
- layer.msg("删除数据失败:" + tempDataObj["info"]);
- }
- layer.close(index);
- })
- }
- //批量删除
- $(".batchDel").click(function(){
- var $checkbox = $('.news_list tbody input[type="checkbox"][name="checked"]');
- var $checked = $('.news_list tbody input[type="checkbox"][name="checked"]:checked');
- if($checkbox.is(":checked")){
- layer.confirm('确定删除选中的信息?',{icon:3, title:'提示信息'},function(index){
- var index = layer.msg('删除中,请稍候',{icon: 16,time:false,shade:0.8});
- var delIDList = "";
- //删除数据
- for (var j = 0; j < $checked.length; j++) {
- delIDList+= $checked.eq(j).parents("tr").find(".news_del").attr("data-id")+",";
- }
-
- DelData(delIDList);
- })
- }else{
- layer.msg("请选择需要删除的数据");
- }
- })
- //全选
- form.on('checkbox(allChoose)', function(data){
- var child = $(data.elem).parents('table').find('tbody input[type="checkbox"]:not([name="show"])');
- child.each(function(index, item){
- item.checked = data.elem.checked;
- });
- form.render('checkbox');
- });
- //通过判断文章是否全部选中来确定全选按钮是否选中
- form.on("checkbox(choose)",function(data){
- var child = $(data.elem).parents('table').find('tbody input[type="checkbox"]:not([name="show"])');
- var childChecked = $(data.elem).parents('table').find('tbody input[type="checkbox"]:not([name="show"]):checked')
- if(childChecked.length == child.length){
- $(data.elem).parents('table').find('thead input#allChoose').get(0).checked = true;
- }else{
- $(data.elem).parents('table').find('thead input#allChoose').get(0).checked = false;
- }
- form.render('checkbox');
- })
- //是否展示
- form.on('switch(isShow)', function(data){
- var index = layer.msg('修改中,请稍候',{icon: 16,time:false,shade:0.8});
- setTimeout(function(){
- layer.close(index);
- layer.msg("展示状态修改成功!");
- },2000);
- })
-
- //操作
- $("body").on("click", ".news_edit", function () { //编辑
-
- // let dataUrl = $(this).attr("data-url");
- // layer.alert('推送消息ID' + dataUrl, { icon: 6, title: '推送消息' });
- window.parent.addTab($(this));
- // console.log($(this))
- })
- $("body").on("click",".news_collect",function(){ //收藏.
- if($(this).text().indexOf("已收藏") > 0){
- layer.msg("取消收藏成功!");
- $(this).html("<i class='layui-icon'></i> 收藏");
- }else{
- layer.msg("收藏成功!");
- $(this).html("<i class='iconfont icon-star'></i> 已收藏");
- }
- })
- $("body").on("click",".news_del",function(){ //删除
- var _this = $(this);
- layer.confirm('确定删除此信息?',{icon:3, title:'提示信息'},function(index){
- //_this.parents("tr").remove();
- // _this.attr("data-id");
-
- layer.close(index);
- DelData(_this.attr("data-id"));
- });
- })
- function formatDate(now) {
- var year = now.getYear();
- var month = now.getMonth() + 1;
- var date = now.getDate();
- var hour = now.getHours();
- var minute = now.getMinutes();
- var second = now.getSeconds();
- return year + "-" + month + "-" + date + " " + hour + ":" + minute + ":" + second;
- }
- function formatDate2(now) {
- var year = now.getYear();
- var month = now.getMonth() + 1;
- var date = now.getDate();
- return year + "-" + month + "-" + date;
- }
- Date.prototype.format = function (format) {
- var date = {
- "M+": this.getMonth() + 1,
- "d+": this.getDate(),
- "h+": this.getHours(),
- "m+": this.getMinutes(),
- "s+": this.getSeconds(),
- "q+": Math.floor((this.getMonth() + 3) / 3),
- "S+": this.getMilliseconds()
- };
- if (/(y+)/i.test(format)) {
- format = format.replace(RegExp.$1, (this.getFullYear() + '').substr(4 - RegExp.$1.length));
- }
- for (var k in date) {
- if (new RegExp("(" + k + ")").test(format)) {
- format = format.replace(RegExp.$1, RegExp.$1.length == 1
- ? date[k] : ("00" + date[k]).substr(("" + date[k]).length));
- }
- }
- return format;
- }
- //渲染数据
- function renderDate(data,curr) {
- var dataHtml = '';
- //if(!that){
- // currData = newsData.concat().splice(curr*nums-nums, nums);
- //}else{
- // currData = that.concat().splice(curr*nums-nums, nums);
- //}
- currData = data["ListData"];
- //console.log(currData);
- if (currData.length != 0) {
- for (var i = 0; i < currData.length; i++) {
- // console.log(currData[i]);
- // console.log(currData[i].EnterpriseName);
- dataHtml += '<tr>'
- + '<td><input type="checkbox" name="checked" lay-skin="primary" lay-filter="choose"></td>'
- + '<td align="left">' + (currData[i].GTType == 0 ? "IOS" : "Android") + ' ['+currData[i].LYFZAPPID+ ']</td>'
- dataHtml += '<td>' + currData[i].GTClientID + '</td>';
- dataHtml += '<td>' + currData[i].Badge + '</td>';
- if (currData[i].GTState == 1)
- {
- if (currData[i].APPState == 1) {
- dataHtml += '<td>正常[Pro生产] V' + currData[i].AppVersion+'</td>'
- } else {
- dataHtml += '<td>正常[Dev开发] V' + currData[i].AppVersion +'</td>'
- }
- } else {
- if (currData[i].APPState == 1) {
- dataHtml += '<td>不可用[Pro生产] V' + currData[i].AppVersion +'</td>'
- } else {
- dataHtml += '<td>不可用[Dev开发] V' + currData[i].AppVersion +'</td>'
- }
- }
- //var newDate = new Date(currData[i].CreationTime);
- // newDate.toLocaleDateString()
- //newDate.format('yyyy-MM-dd h:m:s')
- dataHtml += '<td>' + new Date(currData[i].CreationTime).format('yyyy-MM-dd h:m') + '</td>'
- + '<td>' + new Date(currData[i].UpdateTime).format('yyyy-MM-dd h:m') + '</td>'
- + '<td>'
- + '<a class="layui-btn layui-btn-mini news_edit" href="javascript:;" data-url="/admin/page/GtMsgList/MsgAdd.html?uid=' + currData[i].EnterpriseID +":"+ currData[i].UserID + '&type=' + currData[i].GTType + '"><i class="iconfont icon-wenben" data-icon="icon-text"></i> <cite>推送消息</cite></a>'
- + '<a class="layui-btn layui-btn-danger layui-btn-mini news_del" data-id="' + currData[i].sid + '"><i class="layui-icon"></i> 删除</a>'
- + '</td>'
- + '</tr>';
-
- }
- } else {
- dataHtml = '<tr><td colspan="9">暂无数据</td></tr>';
- }
- $(".news_content").html(dataHtml);
- $('.news_list thead input[type="checkbox"]').prop("checked", false);
-
- form.render();
- }
- function newsList(thatData) {
- //分页
- var nums = myPageSize; //每页出现的数据量
- var TotalCount = 0;
- if (thatData)
- {
- TotalCount = thatData["TotalCount"];
- }
- $("#SumTotalCount").html(TotalCount);
- laypage({
- cont : "page",
- pages: Math.ceil(TotalCount / nums),
- jump: function (obj, first)
- {
- // console.log(first);
- // console.log(obj);
- if (first) {
- renderDate(thatData, obj.curr);
- } else {
- var index = layer.msg('查询中,请稍候', { icon: 16, time: false, shade: 0.8 });
- $.get("/BackgroundProcess.aspx?type=pushuserlist&page=" + obj.curr + "&pageSize=" + nums + "&keywords=" + txtkeywords, function (data) {
- var newArray = [];
- //正常加载信息
- var tempDataObj = JSON.parse(data);
- //console.log(data);
- if (tempDataObj["code"] == 200) {
- //执行加载数据的方法
-
- newsData = tempDataObj["data"];
- renderDate(newsData, obj.curr);
- } else {
- layer.msg("加载数据失败:" + tempDataObj["info"]);
- }
- layer.close(index);
- })
- }
- }
- })
- }
- })
|