Sfoglia il codice sorgente

后台功能重写。

xian 5 anni fa
parent
commit
9241fe8cd7

+ 165 - 0
watero-wechat-web/src/main/webapp/common/js/base/common.js

@@ -0,0 +1,165 @@
+/**
+ * 后台公共JS封装(依赖JQuery)
+ * 古辰创智
+ * 献
+ */
+
+/**
+ * Ajax请求封装
+ * @param type              请求方式:GET、POST
+ * @param uri               请求URI
+ * @param data              请求数据
+ * @param success_Callback  请求成功时的回调地址
+ * @param faild_callback    请求失败时的回调地址
+ * @param async             是否发起异步请求
+ */
+function ajax(type, uri, data, success_Callback, faild_callback, async) {
+    if (!async) {
+        async = true;
+    }
+    type = type || "POST";
+    var index = null;
+    $.ajax({
+        type: type,
+        url: root_path + uri,
+        data: data,
+        dataType: "json",
+        async:async,
+        traditional: true,
+        beforeSend: function () {
+            /* AJAX请求前,展示加载层 */
+            index = layer.load(0, {zIndex:1989101500, isOutAnim:true, shade: [0.8,'#fff']});
+        },
+        success: function(data){
+            /* 请求成功 判断是否触发服务器逻辑的错误 */
+            if (data.error) {
+                /* 如果触发错误,则不会回调成功方法 */
+                var info = (data.error == "auth_error") ? "[权限有误] 请联系管理员分配对应权限!" : "[服务器错误]" + data.error_msg;
+                layer.msg(info,{icon: 1,time:1700});
+                return;
+            }
+            /* 回调成功的方法 */
+            success_Callback(data);
+        },
+        complete: function (xhr) {
+            /* 请求结束后 关闭加载层 */
+            layer.close(index);
+        },
+        error: function (xhr) {
+            /* 此处需要将错误,传递会服务器,以便以后分析处理 */
+            /*new Image().src = root_path + "/html_error/" + encodeURI(xhr.statusText);
+            layer.msg('请求失败,请重试!',{icon: 1,time:1000});*/
+            try {
+                var data = JSON.parse(xhr.responseText);
+                var info = (data.error == "auth_error") ? "[权限有误] 请联系管理员分配对应权限!" : "[服务器错误]" + data.error_msg;
+                layer.msg(info,{icon: 1,time:1700});
+            } catch (e) {
+                new Image().src = root_path + "/html_error/" + encodeURI(xhr.statusText);
+                layer.msg('请求失败,请重试!',{icon: 1,time:1000});
+            }
+            faild_callback(xhr);
+        }
+    });
+}
+
+/**
+ * 格式化时间日期
+ * @param date              时间对象/时间戳
+ * @param format            格式化的格式
+ * @returns {XML|string|void|*}
+ */
+function formatDate(date, format) {
+    if (!date) {
+        if (date !== 0) {
+            return;
+        }
+    }
+    if (!format) format = "yyyy-MM-dd";
+    switch(typeof date) {
+        case "string":
+            date = new Date(date.replace(/-/, "/"));
+            break;
+        case "number":
+            date = new Date(date);
+            break;
+    }
+    if (!date instanceof Date) return;
+    var dict = {
+        "yyyy": date.getFullYear(),
+        "M": date.getMonth() + 1,
+        "d": date.getDate(),
+        "H": date.getHours(),
+        "m": date.getMinutes(),
+        "s": date.getSeconds(),
+        "MM": ("" + (date.getMonth() + 101)).substr(1),
+        "dd": ("" + (date.getDate() + 100)).substr(1),
+        "HH": ("" + (date.getHours() + 100)).substr(1),
+        "mm": ("" + (date.getMinutes() + 100)).substr(1),
+        "ss": ("" + (date.getSeconds() + 100)).substr(1)
+    };
+    return format.replace(/(yyyy|MM?|dd?|HH?|ss?|mm?)/g, function() {
+        return dict[arguments[0]];
+    });
+}
+/*判断数据是否为空*/
+function isEmpty(obj) {
+    if (obj == null || obj === "" || typeof(obj) === "undefined") {
+        return true;
+    }
+    return false;
+}
+/**
+ * 校验身份证信息,函数参数必须是字符串,因为二代身份证号码是十八位,而在javascript中,十八位的数值会超出计算范围,造成不精确的结果,导致最后两位和计算的值不一致,从而该函数出现错误。
+ * @param idcode
+ * @returns {boolean}
+ */
+function checkIDCard(idcode){
+    // 加权因子
+    var weight_factor = [7,9,10,5,8,4,2,1,6,3,7,9,10,5,8,4,2];
+    // 校验码
+    var check_code = ['1', '0', 'X' , '9', '8', '7', '6', '5', '4', '3', '2'];
+    var code = idcode + "";
+    //最后一个
+    var last = idcode[17];
+    var seventeen = code.substring(0,17);
+    // ISO 7064:1983.MOD 11-2
+    // 判断最后一位校验码是否正确
+    var arr = seventeen.split("");
+    var len = arr.length;
+    var num = 0;
+    for(var i = 0; i < len; i++){
+        num = num + arr[i] * weight_factor[i];
+    }
+    // 获取余数
+    var resisue = num%11;
+    var last_no = check_code[resisue];
+    // 格式的正则
+    // 正则思路
+    /*
+    第一位不可能是0
+    第二位到第六位可以是0-9
+    第七位到第十位是年份,所以七八位为19或者20
+    十一位和十二位是月份,这两位是01-12之间的数值
+    十三位和十四位是日期,是从01-31之间的数值
+    十五,十六,十七都是数字0-9
+    十八位可能是数字0-9,也可能是X
+    */
+    var idcard_patter = /^[1-9][0-9]{5}([1][9][0-9]{2}|[2][0][0|1][0-9])([0][1-9]|[1][0|1|2])([0][1-9]|[1|2][0-9]|[3][0|1])[0-9]{3}([0-9]|[X])$/;
+    // 判断格式是否正确
+    var format = idcard_patter.test(idcode);
+    // 返回验证结果,校验码和格式同时正确才算是合法的身份证号码
+    return !!(last === last_no && format);
+}
+/* 为每个页面,增加刷新方法,便于iframe调用 */
+function refresh() {
+    location.replace(location.href);
+}
+/* 校验对象 */
+var vaild = {};
+vaild.money = function(m) {
+    //return /(^[1-9]([0-9]+)?(\.[0-9]{1,2})?$)|(^(0){1}$)|(^[0-9]\.[0-9]([0-9])?$)/.test(m);
+    return /(^([-]?)[1-9]([0-9]+)?(\.[0-9]{1,2})?$)|(^([-]?)(0){1}$)|(^([-]?)[0-9]\.[0-9]([0-9])?$)/.test(m);
+};
+vaild.number = function(n) {
+    return /^([1-9][0-9]*)$/.test(n);
+};

+ 45 - 0
watero-wechat-web/src/main/webapp/common/js/index/index.js

@@ -0,0 +1,45 @@
+// 查看用户信息
+function myselfinfo() {
+    $.post(root_path + "/admin/sys/get/my_info", function (result) {
+        layer.open({
+            type: 1,
+            area: ['400px', '300px'],
+            fix: false,
+            maxmin: true,
+            shade: 0.4,
+            title: '我的信息',
+            content: '<p/>&nbsp;&nbsp;我的名称:<b>' + result.returnMsg.admin.adminName + '</b></p>' +
+            '<p>&nbsp;&nbsp;我的性别:<b>' + (result.returnMsg.admin.adminSex == 1 ? "男" : "女") + '</b></p>' +
+            '<p>&nbsp;&nbsp;我的电话:<b>' + result.returnMsg.admin.adminTel + '</b></p>' +
+            '<p>&nbsp;&nbsp;登录账户:<b>' + result.returnMsg.admin.adminAccount + '</b></p>' +
+            '<p>&nbsp;&nbsp;我的邮箱:<b>' + result.returnMsg.admin.adminMail + '</b></p>' +
+            '<p>&nbsp;&nbsp;创建日期:<b>' + formatDate(new Date(result.returnMsg.admin.adminCreateTime), "yyyy-MM-dd") + '</b></p>'
+        });
+    });
+}
+
+function edit_myPwd(title,url){
+    layer_show(title,url,400,400);
+}
+tip();
+function tip() {
+    //捕获页
+    layer.open({
+        type: 1,
+        shade: false,
+        offset: 'rb',
+        /*closeBtn: 0, 是否展示关闭按钮*/
+        title: false,
+        content: $('.layer_notice'),
+        cancel: function(){
+
+        }
+    });
+}
+
+function notice(href) {
+    var topWindow = $(window.parent.document),
+        show_navLi = topWindow.find("#min_title_list li"),
+        iframe_box = topWindow.find("#iframe_box");
+    iframe_box.find("iframe").attr("src",href);
+}

+ 33 - 0
watero-wechat-web/src/main/webapp/common/js/sys/list_admin.js

@@ -0,0 +1,33 @@
+function editStatus(id, status, callback) {
+    $.post(root_path + "/admin/sys/edit_status",{"adminId":id, "status":status},function(result){
+        if (result.returnCode != 200) {
+            layer.msg('重置失败,请重试!',{icon: 5,time:3000});
+        } else {
+            layer.msg('修改成功!',{icon: 1,time:2000});
+            callback();
+        }
+    });
+}
+/*管理员-停用*/
+function admin_stop(obj,id){
+    layer.confirm('确认要停用吗?',function(index){
+        editStatus(id, 2, function() {
+            $(obj).parents("tr").find(".td-manage").prepend('<a onClick="admin_start(this,' + id + ')" href="javascript:;" title="启用" style="text-decoration:none"><i class="Hui-iconfont">&#xe615;</i></a>');
+            $(obj).parents("tr").find(".td-status").html('<span class="label label-default radius">已禁用</span>');
+            $(obj).remove();
+            layer.msg('已停用!',{icon: 5,time:1000});
+        });
+    });
+}
+
+/*管理员-启用*/
+function admin_start(obj,id){
+    layer.confirm('确认要启用吗?',function(index){
+        editStatus(id, 1, function() {
+            $(obj).parents("tr").find(".td-manage").prepend('<a onClick="admin_stop(this,' + id + ')" href="javascript:;" title="停用" style="text-decoration:none"><i class="Hui-iconfont">&#xe631;</i></a>');
+            $(obj).parents("tr").find(".td-status").html('<span class="label label-success radius">已启用</span>');
+            $(obj).remove();
+            layer.msg('已启用!', {icon: 6,time:1000});
+        });
+    });
+}