http://lingdu.gouwanmei.wang/web/index.php?c=site&a=entry&m=ewei_shopv2&do=web&r=commission.rank
点击保存按钮

文件 /addons/ewei_shopv2/static/js/myconfig.js

var myconfig = {
    path: '../addons/ewei_shopv2/static/js/',
    alias: {
        'jquery': 'dist/jquery/jquery-1.11.1.min',
        'jquery.form': 'dist/jquery/jquery.form',
        'jquery.gcjs': 'dist/jquery/jquery.gcjs',
        'jquery.validate': 'dist/jquery/jquery.validate.min',
        'jquery.nestable': 'dist/jquery/nestable/jquery.nestable',
        'jquery.qrcode':'../dist/jquery/jquery.qrcode.min',
        'bootstrap': 'dist/bootstrap/bootstrap.min',
        'bootstrap.suggest': 'dist/bootstrap/bootstrap-suggest.min',
        'bootbox': 'dist/bootbox/bootbox.min',
        'sweet': 'dist/sweetalert/sweetalert.min',
        'select2': 'dist/select2/select2.min',
        'jquery.confirm': 'dist/jquery/confirm/jquery-confirm',
        'jquery.contextMenu': 'dist/jquery/contextMenu/jquery.contextMenu',
        'switchery': 'dist/switchery/switchery',
        'echarts': 'dist/echarts/echarts-all',
        'echarts.min': 'dist/echarts/echarts.min',
        'toast': 'dist/jquery/toastr.min',
        'clipboard': 'dist/clipboard.min',
        'tpl': 'dist/tmodjs',
        'daterangepicker': 'dist/daterangepicker/daterangepicker',
        'datetimepicker': 'dist/datetimepicker/jquery.datetimepicker',
        'ueditor': 'dist/ueditor/ueditor.parse.min',
        'tooltipbox': 'dist/tooltipbox'
    }
}

文件 /addons/ewei_shopv2/static/js/web/form.js

define(['jquery'],
function($) {
    var form = {};
    form.init = function() {
        var modal_form = $('form.form-modal');
        var form_modal;
        if (modal_form.length > 0) {
            var form_modal = modal_form.parents('.modal');
            form_modal.on("hidden",
            function() {
                modal_form.resetForm()
            })
        }
        var form_validate = $('form.form-validate');
        if (form_validate.length > 0) {
            var validate_rule = {
                errorElement: 'span',
                errorClass: 'help-block-validate',
                focusInvalid: true,
                highlight: function(element) {
                    var parent = $(element).data('parent') || '';
                    if (parent) {
                        $(parent).addClass('has-error')
                    } else {
                        $(element).closest('.form-group').addClass('has-error')
                    }
                },
                onkeyup: function(element) {
                    $(element).valid()
                },
                onfocusout: function(element) {
                    $(element).valid()
                },
                success: function(element) {
                    var parent = $(element).data('parent') || '';
                    if (parent) {
                        $(parent).removeClass('has-error')
                    } else {
                        $(element).closest('.form-group').removeClass('has-error')
                    }
                },
                errorPlacement: function(error, element) {
                    var group = element.parents(".input-group");
                    group.length > 0 ? group.after(error) : element.after(error)
                },
                submitHandler: function(form) {
                    var cansubmit = true;
                    if ($(".form-editor-group").length > 0) {
                        $(".form-editor-group").each(function() {
                            var input = $(this).find(".form-editor-input");
                            if (input.attr('data-rule-required') && $.trim(input.val()) == '') {
                                $(this).find(".form-editor-btn").trigger('click');
                                input.focus().blur().focus();
                                cansubmit = false;
                                return false
                            }
                        })
                    }
                    if (!cansubmit) {
                        return
                    }
                    var submit_button = $("input[type='submit']", form);
                    var buttontype = 'input';
                    var html = [];
                    submit_button.each(function(index) {
                        var but = $(this);
                        html[index] = but.val()
                    });
                    if (submit_button.length <= 0) {
                        submit_button = $("button[type='submit']", form);
                        buttontype = 'button';
                        html[0] = submit_button.html()
                    }
                    if ($(form).attr('stop') == '1') {
                        return
                    }
                    var confirm = submit_button.data('confirm') || submit_button.data('confirm');
                    var handler = function() {
                        if (buttontype == 'button') {
                            submit_button.html('<i class="fa fa-spinner fa-spin"></i> ' + tip.lang.processing)
                        } else {
                            submit_button.val(tip.lang.processing)
                        }
                        var timeout = 1000 * 3600;
                        submit_button.attr('disabled', true);
                        $(form).ajaxSubmit({
                            timeout: timeout,
                            dataType: "json",
                            success: function(a) {
                                if (a.result.url) {
                                    a.result.url = a.result.url.replace(/&/ig, "&");
                                    a.result.url = a.result.url.replace('¬', "&not")
                                }
                                if (a.status != 1) {
                                    submit_button.removeAttr('disabled');
                                    submit_button.each(function(index) {
                                        buttontype == 'button' ? $(this).html(html[index]) : $(this).val(html[index])
                                    });
                                    form_modal && form_modal.modal("hide"),
                                    tip.msgbox.err(a.result.message || a.result || tip.lang.error, a.result.url)
                                } else {
                                    tip.msgbox.suc(a.result.message || tip.lang.success, a.result.url)
                                }
                            },
                            error: function(a) {
                                submit_button.removeAttr('disabled');
                                submit_button.each(function(index) {
                                    buttontype == 'button' ? $(this).html(html[index]) : $(this).val(html[index])
                                });
                                form_modal && form_modal.modal("hide");
                                tip.msgbox.err(tip.lang.error)
                            }
                        });
                        return false
                    };
                    if (confirm) {
                        tip.confirm(confirm, handler)
                    } else {
                        handler()
                    }
                }
            };
            myrequire(['jquery.form', 'jquery.validate'],
            function() {
                var cnmsg = {
                    required: "此项必须填写",
                    remote: "请修正该字段",
                    email: "请输入正确格式的电子邮件",
                    url: "请输入正确的网址",
                    date: "请输入正确的日期",
                    dateISO: "请输入合法的日期 (ISO).",
                    number: "请输入数字格式",
                    digits: "请输入整数格式",
                    creditcard: "请输入合法的信用卡号",
                    equalTo: "请再次输入相同的值",
                    accept: "请输入拥有合法后缀名的字符串",
                    maxlength: $.validator.format("请输入一个长度最多是 {0} 的字符串"),
                    minlength: $.validator.format("请输入一个长度最少是 {0} 的字符串"),
                    rangelength: $.validator.format("请输入一个长度介于 {0} 和 {1} 之间的字符串"),
                    range: $.validator.format("请输入一个介于 {0} 和 {1} 之间的值"),
                    max: $.validator.format("请输入一个最大为 {0} 的值"),
                    min: $.validator.format("请输入一个最小为 {0} 的值")
                };
                $.extend($.validator.messages, cnmsg);
                $.validator.addMethod("chinese",
                function(value, element) {
                    var chinese = /^[\u4e00-\u9fa5]+$/;
                    return this.optional(element) || (chinese.test(value))
                },
                "只能输入中文"),
                $.validator.methods.url = function(value, element) {
                    return this.optional(element) || /^((http|https|ftp):\/\/)?(\w(\:\w)?@)?([0-9a-z_-]+\.)*?([a-z]{2,6}(\.[a-z]{2})?(\:[0-9]{2,6})?)((\/[^?#<>\/\\*":]*)+(\?[^#]*)?(#.*)?)?$/i.test(value)
                };
                form_validate.each(function() {
                    var form = jQuery(this);
                    form.validate(validate_rule)
                });
                $('#page-loading').remove()
            })
        }
    };
    return form
})

{template ‘_header’} 引用模板位置 /addons/ewei_shopv2/template/web_v3/_header.html

{template ‘_footer’} 引用模板位置 /addons/ewei_shopv2/template/web_v3/_footer.html

/web/index.php?c=site&a=entry&m=ewei_shopv2&do=web&r=commission.rank页面js myrequire([‘web/init’]);
/addons/ewei_shopv2/static/js/web/init.js

define(['jquery', 'bootstrap'],
function($, bs) {
    window.redirect = function(url) {
        location.href = url
    },
    $(document).on('click', '[data-toggle=refresh]',
    function(e) {
        e && e.preventDefault();
        var url = $(e.target).data("href");
        url ? window.location = url: window.location.reload()
    }),
    $(document).on('click', '[data-toggle=back]',
    function(e) {
        e && e.preventDefault();
        var url = $(e.target).data("href");
        url ? window.location = url: window.history.back()
    });
    function _bindCssEvent(events, callback) {
        var dom = this;
        function fireCallBack(e) {
            if (e.target !== this) {
                return
            }
            callback.call(this, e);
            for (var i = 0; i < events.length; i++) {
                dom.off(events[i], fireCallBack)
            }
        }
        if (callback) {
            for (var i = 0; i < events.length; i++) {
                dom.on(events[i], fireCallBack)
            }
        }
    }
    $.fn.animationEnd = function(callback) {
        _bindCssEvent.call(this, ['webkitAnimationEnd', 'animationend'], callback);
        return this
    };
    $.fn.transitionEnd = function(callback) {
        _bindCssEvent.call(this, ['webkitTransitionEnd', 'transitionend'], callback);
        return this
    };
    $.fn.transition = function(duration) {
        if (typeof duration !== 'string') {
            duration = duration + 'ms'
        }
        for (var i = 0; i < this.length; i++) {
            var elStyle = this[i].style;
            elStyle.webkitTransitionDuration = elStyle.MozTransitionDuration = elStyle.transitionDuration = duration
        }
        return this
    };
    $.fn.transform = function(transform) {
        for (var i = 0; i < this.length; i++) {
            var elStyle = this[i].style;
            elStyle.webkitTransform = elStyle.MozTransform = elStyle.transform = transform
        }
        return this
    };
    $.toQueryPair = function(key, value) {
        if (typeof value == 'undefined') {
            return key
        }
        return key + '=' + encodeURIComponent(value === null ? '': String(value))
    };
    $.toQueryString = function(obj) {
        var ret = [];
        for (var key in obj) {
            key = encodeURIComponent(key);
            var values = obj[key];
            if (values && values.constructor == Array) {
                var queryValues = [];
                for (var i = 0,
                len = values.length,
                value; i < len; i++) {
                    value = values[i];
                    queryValues.push($.toQueryPair(key, value))
                }
                ret = concat(queryValues)
            } else {
                ret.push($.toQueryPair(key, values))
            }
        }
        return ret.join('&')
    };
    myrequire(['web/table']);
    myrequire(['jquery.gcjs']);
    myrequire(['web/tip']);
    myrequire(['tooltipbox']);
    if ($('form.form-validate').length > 0 || $('form.form-modal').length > 0) {
        myrequire(['web/form'],
        function(form) {
            form.init()
        })
    }
    myrequire(['web/biz']);
    if ($('.select2').length > 0) {
        myrequire(['select2'],
        function() {
            $('.select2').each(function() {
                $(this).select2({})
            })
        })
    }
    myrequire(['web/table']);
    if ($('.js-switch').length > 0) {
        myrequire(['switchery'],
        function() {
            $('.js-switch').switchery()
        })
    }
    if ($('.js-clip').length > 0) {
        myrequire(['clipboard'],
        function(Clipboard) {
            var clipboard = new Clipboard('.js-clip', {
                text: function(e) {
                    return $(e).data('url') || $(e).data('href')
                }
            });
            clipboard.on('success',
            function(e) {
                tip.msgbox.suc('复制成功')
            })
        })
    }
    $.fn.append2 = function(html, callback) {
        var len = $("body").html().length;
        this.append(html);
        var e = 1,
        interval = setInterval(function() {
            e++;
            var clear = function() {
                clearInterval(interval);
                callback && callback()
            };
            if (len != $("body").html().length || e > 1000) {
                clear()
            }
        },
        1)
    };
    $('[data-toggle="popover"]').popover();
    $(document).on("click", '[data-toggle="ajaxModal"]',
    function(e) {
        e.preventDefault();
        var obj = $(this),
        confirm = obj.data("confirm");
        var handler = function() {
            $("#ajaxModal").remove(),
            e.preventDefault();
            var url = obj.data("href") || obj.attr("href"),
            data = obj.data("set"),
            modal;
            $.ajax(url, {
                type: "get",
                dataType: "html",
                cache: false,
                data: data
            }).done(function(html) {
                if (html.substr(0, 8) == '{"status') {
                    json = eval("(" + html + ')');
                    if (json.status == 0) {
                        msg = typeof(json.result) == 'object' ? json.result.message: json.result;
                        tip.msgbox.err(msg || tip.lang.err);
                        return
                    }
                }
                modal = $('<div class="modal fade" id="ajaxModal"><div class="modal-body "></div></div>');
                $(document.body).append(modal),
                modal.modal('show');
                myrequire(['jquery.gcjs'],
                function() {
                    modal.append2(html,
                    function() {
                        var form_validate = $('form.form-validate', modal);
                        if (form_validate.length > 0) {
                            $("button[type='submit']", modal).length && $("button[type='submit']", modal).attr("disabled", true);
                            myrequire(['web/form'],
                            function(form) {
                                form.init();
                                $("button[type='submit']", modal).length && $("button[type='submit']", modal).removeAttr("disabled")
                            })
                        }
                    })
                })
            })
        },
        a;
        if (confirm) {
            tip.confirm(confirm, handler)
        } else {
            handler()
        }
    }),
    $(document).on("click", '[data-toggle="ajaxPost"]',
    function(e) {
        e.preventDefault();
        var obj = $(this),
        confirm = obj.data("confirm"),
        url = obj.data('href') || obj.attr('href'),
        data = obj.data('set') || {},
        html = obj.html();
        handler = function() {
            e.preventDefault();
            if (obj.attr('submitting') == '1') {
                return
            }
            obj.html('<i class="fa fa-spinner fa-spin"></i>').attr('submitting', 1);
            $.post(url, {
                data: data
            },
            function(ret) {
                ret = eval("(" + ret + ")");
                if (ret.status == 1) {
                    tip.msgbox.suc(ret.result.message || tip.lang.success, ret.result.url)
                } else {
                    tip.msgbox.err(ret.result.message || tip.lang.error, ret.result.url),
                    obj.removeAttr('submitting').html(html)
                }
            }).fail(function() {
                obj.removeAttr('submitting').html(html),
                tip.msgbox.err(tip.lang.exception)
            })
        };
        confirm && tip.confirm(confirm, handler); ! confirm && handler()
    }),
    $(document).on("click", '[data-toggle="ajaxEdit"]',
    function(e) {
        var obj = $(this),
        url = obj.data('href') || obj.attr('href'),
        data = obj.data('set') || {},
        html = $.trim(obj.text()),
        required = obj.data('required') || true,
        edit = obj.data('edit') || 'input';
        var oldval = $.trim($(this).text());
        e.preventDefault();
        submit = function() {
            e.preventDefault();
            var val = $.trim(input.val());
            if (required) {
                if (val == '') {
                    tip.msgbox.err(tip.lang.empty);
                    return
                }
            }
            if (val == html) {
                input.remove(),
                obj.html(val).show();
                return
            }
            if (url) {
                $.post(url, {
                    value: val
                },
                function(ret) {
                    ret = eval("(" + ret + ")");
                    if (ret.status == 1) {
                        obj.html(val).show()
                    } else {
                        tip.msgbox.err(ret.result.message, ret.result.url)
                    }
                    input.remove()
                }).fail(function() {
                    input.remove(),
                    tip.msgbox.err(tip.lang.exception)
                })
            } else {
                input.remove();
                obj.html(val).show()
            }
            obj.trigger('valueChange', [val, oldval])
        },
        obj.hide().html('<i class="fa fa-spinner fa-spin"></i>');
        var input = $('<input type="text" class="form-control input-sm" style="width: 80%;display: inline;" />');
        if (edit == 'textarea') {
            input = $('<textarea type="text" class="form-control" style="resize:none" rows=3 ></textarea>')
        }
        obj.after(input);
        input.val(html).select().blur(function() {
            submit(input)
        }).keypress(function(e) {
            if (e.which == 13) {
                submit(input)
            }
        })
    }),
    $(document).on("click", '[data-toggle="ajaxSwitch"]',
    function(e) {
        e.preventDefault();
        var obj = $(this),
        confirm = obj.data('msg') || obj.data('confirm'),
        othercss = obj.data('switch-css'),
        other = obj.data('switch-other'),
        refresh = obj.data('switch-refresh') || false;
        if (obj.attr('submitting') == '1') {
            return
        }
        var value = obj.data('switch-value'),
        value0 = obj.data('switch-value0'),
        value1 = obj.data('switch-value1');
        if (value === undefined || value0 === undefined || value1 === undefined) {
            return
        }
        var url, css, text, newvalue, newurl, newcss, newtext;
        value0 = value0.split('|');
        value1 = value1.split('|');
        if (value == value0[0]) {
            url = value0[3],
            css = value0[2],
            text = value0[1],
            newvalue = value1[0],
            newtext = value1[1],
            newcss = value1[2]
        } else {
            url = value1[3],
            css = value1[2],
            text = value1[1],
            newvalue = value0[0],
            newtext = value0[1],
            newcss = value0[2]
        }
        var html = obj.html();
        var submit = function() {
            $.post(url).done(function(data) {
                data = eval("(" + data + ")");
                if (data.status == 1) {
                    if (other && othercss) {
                        if (newvalue == '1') {
                            $(othercss).each(function() {
                                if ($(this).data('switch-value') == newvalue) {
                                    this.className = css;
                                    $(this).data('switch-value', value).html(text || html)
                                }
                            })
                        }
                    }
                    obj.data('switch-value', newvalue);
                    obj.html(newtext || html);
                    obj[0].className = newcss;
                    refresh && location.reload()
                } else {
                    obj.html(html),
                    tip.msgbox.err(data.result.message || tip.lang.error, data.result.url)
                }
                obj.removeAttr('submitting')
            }).fail(function() {
                obj.removeAttr('submitting');
                obj.button('reset');
                tip.msgbox.err(tip.lang.exception)
            })
        },
        a;
        if (confirm) {
            tip.confirm(confirm,
            function() {
                obj.html('<i class="fa fa-spinner fa-spin"></i>').attr('submitting', 1),
                submit()
            })
        } else {
            obj.html('<i class="fa fa-spinner fa-spin"></i>').attr('submitting', 1),
            submit()
        }
    });
    $(document).on('click', '[data-toggle="selectUrl"]',
    function() {
        $("#selectUrl").remove();
        var _input = $(this).data('input');
        var _type = $(this).data('type');
        var _full = $(this).data('full');
        var _platform = $(this).data('platform');
        var _callback = $(this).data('callback') || false;
        var _cbfunction = !_callback ? false: eval("(" + _callback + ")");
        if (!_input && !_callback) {
            return
        }
        var merch = $(".diy-phone").data("merch");
        var url = biz.url('util/selecturl', null, merch);
        var store = $(".diy-phone").data("store");
        if (store) {
            url = biz.url('store/diypage/selecturl')
        }
        if (_full) {
            url = url + "&full=1"
        }
        if (_platform) {
            url = url + "&platform=" + _platform
        }
        if (_type) {
            url = url + '&type=' + _type
        }
        if ($(_input).length > 0 && $(_input).val()) {
            url += '&url=' + encodeURIComponent($(_input).val())
        }
        $.ajax(url, {
            type: "get",
            dataType: "html",
            cache: false
        }).done(function(html) {
            modal = $('<div class="modal fade" id="selectUrl"></div>');
            $(document.body).append(modal),
            modal.modal('show');
            modal.append2(html,
            function() {
                $(document).off("click", '#selectUrl nav').on("click", '#selectUrl nav',
                function() {
                    var _href = $.trim($(this).data("href"));
                    var _data_type = $.trim($(this).data("type"));
                    if (_data_type != '' && _data_type == 'topmenu_data') {
                        var _data_condition = $.trim($(this).data("condition"));
                        var _data_tab = $.trim($(this).data("tab"));
                        if (_data_tab == 'goodsids') {
                            var _data_condition = '';
                            $("[data-name*='goodsid']").each(function(index, item) {
                                _data_condition += $(this).data('id') + ','
                            });
                            if (_data_condition == '') {
                                tip.msgbox.err('请选择商品');
                                return
                            }
                        } else if (_data_tab == 'stores') {
                            var _data_condition = '';
                            $("[data-name*='stores']").each(function(index, item) {
                                if ($(this).is(':checked')) {
                                    _data_condition += $(this).data('id') + ','
                                }
                            });
                            if (_data_condition == '') {
                                tip.msgbox.err('请选择门店');
                                return
                            }
                        }
                        $(_input).val(_data_tab + '=' + _data_condition).trigger('change');
                        if (_data_tab == 'groups' || _data_tab == 'category' || _data_tab == 'goodsids') {
                            _cbfunction(_data_tab)
                        }
                    } else {
                        if (_input) {
                            $(_input).val(_href).trigger('change')
                        } else if (_cbfunction) {
                            _cbfunction(_href)
                        }
                    }
                    modal.find(".close").click()
                })
            })
        })
    });
    $(document).on('click', '[data-toggle="selectImg"]',
    function() {
        var _input = $(this).data('input');
        var _img = $(this).data('img');
        var _full = $(this).data('full');
        var dest_dir = $('.diy-phone').length > 0 ? $('.diy-phone').data('merch') : '';
        var options = {};
        if (dest_dir) {
            options.dest_dir = 'merch/' + dest_dir
        }
        require(['jquery', 'util'],
        function($, util) {
            util.image('',
            function(data) {
                var imgurl = data.attachment;
                if (_full) {
                    imgurl = data.url
                }
                if (_input) {
                    $(_input).val(imgurl).trigger('change')
                }
                if (_img) {
                    $(_img).attr('src', data.url)
                }
            },
            options)
        })
    });
    $(document).on('click', '[data-toggle="selectIcon"]',
    function() {
        var _input = $(this).data('input');
        var _element = $(this).data('element');
        if (!_input && !_element) {
            return
        }
        var merch = $(".diy-phone").data("merch");
        var url = biz.url('util/selecticon', null, merch);
        $.ajax(url, {
            type: "get",
            dataType: "html",
            cache: false
        }).done(function(html) {
            modal = $('<div class="modal fade" id="selectIcon"></div>');
            $(document.body).append(modal),
            modal.modal('show');
            modal.append2(html,
            function() {
                $(document).off("click", '#selectIcon nav').on("click", '#selectIcon nav',
                function() {
                    var _class = $.trim($(this).data("class"));
                    if (_input) {
                        $(_input).val(_class).trigger('change')
                    }
                    if (_element) {
                        $(_element).removeAttr("class").addClass("icon " + _class)
                    }
                    modal.find(".close").click()
                })
            })
        })
    });
    $(document).on('click', '[data-toggle="selectIcon3"]',
    function() {
        var _element = $(this).data('element');
        var _input = $(this).data('input');
        if (!_input && !_element) {
            return
        }
        var url = biz.url('util/selecticon3');
        $.ajax(url, {
            type: "get",
            dataType: "html",
            cache: false
        }).done(function(html) {
            var modal3 = $("#selectIcon3");
            if (modal3.length) {
                modal3.modal('show')
            } else {
                console.log(modal3);
                $(document.body).append($('<div class="modal fade" id="selectIcon3"></div>')),
                modal3.modal('show')
            }
            modal3.append2(html,
            function() {
                $(document).off("click", '#selectIcon3 nav').on("click", '#selectIcon3 nav',
                function() {
                    var _class = $.trim($(this).data("class"));
                    if (_input) {
                        $(_input).val(_class).trigger('change')
                    }
                    if (_element) {
                        $(_element).removeAttr("class").addClass("icox " + _class)
                    }
                    modal3.find(".close").click()
                })
            })
        })
    });
    $(document).on('click', '[data-toggle="selectAudio"]',
    function() {
        var _input = $(this).data('input');
        var _full = $(this).data('full');
        require(['jquery', 'util'],
        function($, util) {
            util.audio('',
            function(data) {
                var audiourl = data.attachment;
                if (_full) {
                    audiourl = data.url
                }
                if (_input) {
                    $(_input).val(audiourl).trigger('change')
                }
            })
        })
    });
    $(document).on('click', '[data-toggle="selectVideo"]',
    function() {
        var _input = $(this).data('input');
        var _full = $(this).data('full');
        var _network = $(this).data('network');
        require(['jquery', 'util'],
        function($, util) {
            util.audio('',
            function(data) {
                var audiourl = data.attachment;
                if (_full || !data.attachment) {
                    audiourl = data.url
                }
                if (_input) {
                    $(_input).val(audiourl).trigger('change')
                }
            },
            {
                type: 'video',
                netWorkVideo: _network
            })
        })
    });
    $(document).on('click', '[data-toggle="previewVideoDel"]',
    function(e) {
        e.stopPropagation();
        var elm = $(this).data('element');
        $(elm).val('')
    });
    $(document).on('click', '[data-toggle="previewVideo"]',
    function() {
        var videoelm = $(this).data('input');
        if (!videoelm) {
            return
        }
        var video = $(videoelm).data('url') || $(videoelm).val();
        if (!video || video == '') {
            tip.msgbox.err('未选择视频');
            return
        }
        if (video.indexOf('videos/') == 0) {
            video = window.sysinfo.attachurl + video
        }
        if ($('#previewVideo').length < 1) {
            $('body').append('<div class="modal fade" id="previewVideo"><div class="modal-dialog" style="min-width: 400px !important;"><div class="modal-content"><div class="modal-header"><button data-dismiss="modal" class="close" type="button">×</button><h4 class="modal-title">视频预览</h4></div><div class="modal-body" style="padding: 0; background: #000;"><video src="' + video + '" style="height: 450px; width: 100%; display: block;" controls="controls"></video><iframe src="' + video + '" style="height: 450px; width: 100%; border: 0;"></iframe></div></div></div></div>')
        } else {
            $("#previewVideo video").attr("src", video);
            $("#previewVideo iframe").attr("src", video)
        }
        if (video.indexOf('v.qq.com/iframe/player.html') > -1) {
            $("#previewVideo video").hide();
            $("#previewVideo iframe").show()
        } else {
            $("#previewVideo video").show();
            $("#previewVideo iframe").hide()
        }
        $("#previewVideo").modal();
        $("#previewVideo").on("hidden.bs.modal",
        function() {
            $(this).find("video").attr('src', '');
            $(this).find("iframe").attr('src', '')
        })
    });
    $(window).resize(function() {
        var width = $(window).width();
        if (width <= 1440) {
            $(".wb-panel-fold").removeClass('in').html('<i class="icow icow-info"></i> 消息提醒');
            $(".wb-panel").removeClass('in');
            $('.wb-container').addClass('right-panel')
        } else {
            $(".wb-panel-fold").addClass('in').html('<i class="fa fa-angle-double-right"></i> 收起面板');
            $(".wb-panel").addClass('in');
            $('.wb-container').removeClass('right-panel')
        }
    });
    $(window).scroll(function() {
        if ($(window).scrollTop() > 200) {
            $('.fixed-header').addClass('active')
        } else {
            $('.fixed-header').removeClass('active')
        }
    });
    $('.wb-nav-fold').click(function() {
        var nav = $(this).closest(".wb-nav");
        if (nav.hasClass('fold')) {
            nav.removeClass('fold');
            $(".wb-header .logo").removeClass('small');
            $(".fast-nav").removeClass('indent');
            util.cookie.set('foldnav', 0)
        } else {
            nav.addClass('fold');
            $(".wb-header .logo").addClass('small');
            $(".fast-nav").addClass('indent');
            util.cookie.set('foldnav', 1)
        }
    });
    $('.wb-subnav-fold').click(function() {
        var subnav = $(this).closest(".wb-subnav");
        if (subnav.hasClass('fold')) {
            subnav.removeClass('fold')
        } else {
            subnav.addClass('fold')
        }
    });
    $('.menu-header').click(function() {
        if ($(this).hasClass('active')) {
            $(this).next('ul').eq(0).hide();
            $(this).find('.menu-icon').removeClass('fa-caret-down').addClass('fa-caret-right');
            $(this).removeClass('active')
        } else {
            $(this).next('ul').eq(0).show();
            $(this).find('.menu-icon').removeClass('fa-caret-right').addClass('fa-caret-down');
            $(this).addClass('active')
        }
    });
    $('.wb-header-btn').click(function() {
        if ($('.wb-topbar-search').hasClass('expand-search')) {
            $('.wb-search-box').focus();
            var keyword = $.trim($(".wb-search-box").val());
            if (keyword != '') {
                location.href = './index.php?c=site&a=entry&m=ewei_shopv2&do=web&r=search&keyword=' + keyword;
                return
            }
        } else {}
    });
    $(".wb-search-box").bind('input propertychange',
    function() {
        var keyword = $.trim($(this).val());
        var merch = $(this).data('merch') || 0;
        if (keyword == '') {
            $('.wb-search-result ul').empty();
            $('.wb-search-result').hide();
            $(".wb-search-box").val('');
            return
        }
        $.getJSON(biz.url('searchlist', null, merch), {
            keyword: keyword
        },
        function(ret) {
            var result = ret.result;
            var html = '';
            $('.wb-search-result ul').empty();
            if (result.menu.length < 1) {
                html = '<li class="empty-data"><a>暂未搜索到与“' + keyword + '”相关功能</a></li>'
            } else {
                $.each(result.menu,
                function(index, menu) {
                    html += '<li><a href="' + menu.url + '">' + menu.title + '</a></li>'
                })
            }
            $('.wb-search-result ul').html(html);
            $('.wb-search-result').show()
        })
    });
    $(".wb-header-logout").click(function() {
        var href = $(this).closest('li').data('href');
        tip.confirm("当前已登录,确认退出?",
        function() {
            location.href = href
        })
    });
    $(".wb-panel-fold").click(function() {
        $(this).toggleClass('in');
        $(".wb-panel").toggleClass('in');
        if (!$(this).hasClass('in')) {
            $(this).html('<i class="icow icow-info"></i> 消息提醒');
            util.cookie.set('foldpanel', 1);
            $('.wb-container').addClass('right-panel')
        } else {
            $(this).html('<i class="fa fa-angle-double-right"></i> 收起面板');
            util.cookie.set('foldpanel', 0);
            $('.wb-container').removeClass('right-panel')
        }
    });
    $(".wb-shortcut").click(function() {
        if ($(this).hasClass('active')) {
            $(this).removeClass('active');
            $(".fast-nav").removeClass('in')
        } else {
            $(this).addClass('active');
            $(".fast-nav").addClass('in')
        }
    });
    $(".fast-list.menu a").hover(function() {
        $(this).addClass('active').siblings().removeClass('active');
        var tab = $(this).data('tab');
        $(".fast-list.list [data-tab='" + tab + "']").addClass('in').siblings('.in').removeClass('in');
        $(".funbar-panel").hide();
        $("#funbar-name").val('');
        $("#funbar-color").val('#666666')
    });
    $(".funbar-add-btn").click(function() {
        $(".funbar-panel").show();
        $("#funbar-bold-0").prop('checked', 'checked')
    });
    $(".funbar-cancel-btn").click(function() {
        $(".funbar-panel").hide();
        $("#funbar-name").val('');
        $("#funbar-color").val('#666666')
    });
    $(".funbar-save-btn").click(function() {
        var name = $.trim($("#funbar-name").val());
        if (name == '') {
            tip.msgbox.err('请输入导航名称');
            return
        }
        var color = $("#funbar-color").val();
        var bold = $("#funbar-bold-1").is(':checked') ? 1 : 0;
        var link = $("#funbar-link").val();
        var fundata = {
            href: link,
            text: name,
            color: color,
            bold: bold
        };
        $.post(biz.url('sysset/funbar/post'), {
            funbardata: fundata
        },
        function(ret) {
            if (ret.status == 1) {
                var html = '<a href="' + link + '" style=" ';
                if (bold == 1) {
                    html += 'font-weight: bold;'
                }
                if (color != '#666666') {
                    html += 'color: ' + color + ';'
                }
                html += '">' + name + '</a>';
                $("#funbar-list").prepend(html);
                $(".funbar-panel").hide();
                $("#funbar-name").val('');
                $("#funbar-color").val('#666666')
            } else {
                tip.msgbox.err("保存失败请重试!")
            }
        },
        'json')
    });
    $("#btn-clear-history").click(function() {
        var merch = $(this).data('merch') || 0;
        tip.confirm("确认清除最近访问吗?",
        function() {
            $.post(biz.url('clearhistory', null, merch), {
                type: 0
            },
            function(ret) {
                $(".fast-list.history").remove()
            })
        })
    });
    $(document).click(function(e) {
        var btn1 = $(e.target).closest('.wb-shortcut').length;
        if (!btn1) {
            var fastNav = $(e.target).closest('.fast-nav').length;
            if (!fastNav) {
                $(".wb-shortcut").removeClass('active');
                $(".fast-nav").removeClass('in')
            }
        }
    });
    if ($(".form-editor-group").length > 0) {
        $(".form-editor-group .form-editor-btn").click(function() {
            var editor = $(this).closest(".form-editor-group");
            editor.find(".form-editor-show").hide();
            editor.find(".form-editor-edit").css('display', 'table')
        });
        $(".form-editor-group .form-editor-finish").click(function() {
            if ($(this).closest(".form-group").hasClass("has-error")) {
                return
            }
            var editor = $(this).closest(".form-editor-group");
            editor.find(".form-editor-show").show();
            editor.find(".form-editor-edit").hide();
            var input = editor.find(".form-editor-input");
            var value = $.trim(input.val());
            editor.find(".form-editor-text").text(value)
        })
    }
    $("img").error(function() {
        $(this).attr('src', '../addons/ewei_shopv2/static/images/nopic.png')
    })
});

/addons/ewei_shopv2/static/js/web/tip.js

define(['jquery'],
function($) {
    var tip = {};
    tip.lang = {
        "success": "操作成功",
        "error": "操作失败",
        "exception": "网络异常",
        "processing": "处理中..."
    };
    $('#tip-msgbox').remove();
    $("body", top.window.document).append('<div id="tip-msgbox" class="msgbox"></div>');
    window.msgbox = $("#tip-msgbox", top.window.document);
    tip.confirm = function(msg, callback, cancel_callback) {
        msg = msg.replace(/</g, "<");
        msg = msg.replace(/>/g, ">");
        myrequire(['jquery.confirm'],
        function() {
            $.confirm({
                title: '提示',
                content: msg,
                confirmButtonClass: 'btn-primary',
                cancelButtonClass: 'btn-default',
                confirmButton: '确 定',
                cancelButton: '取 消',
                animation: 'top',
                confirm: function() {
                    if (callback && typeof(callback) == 'function') {
                        callback()
                    }
                },
                cancel: function() {
                    if (cancel_callback && typeof(cancel_callback) == 'function') {
                        cancel_callback()
                    }
                }
            })
        })
    },
    tip.prompt = function(msg, options, password) {
        var callback = null;
        var maxlength = null;
        var required = false;
        var input_type = password ? 'password': 'text';
        if (typeof options == 'function') {
            callback = options
        } else if (typeof options == 'object') {
            maxlength = options.maxlength || null;
            callback = options.callback && typeof options.callback == 'function' ? options.callback: null;
            required = options.required || false
        }
        var inputid = 'prompt_' + ( + new Date());
        var max = maxlength ? " maxlength='" + maxlength + "' ": '';
        myrequire(['jquery.confirm'],
        function() {
            $.alert({
                title: '提示',
                content: "<p>" + msg + "</p><p><input id='" + inputid + "' type='" + input_type + "' class='form-control' name='confirm' placeholder='" + msg + "' " + max + " /></p>",
                confirmButtonClass: 'btn-primary',
                confirmButton: '确 定',
                closeIcon: true,
                animation: 'top',
                keyboardEnabled: true,
                onOpen: function() {
                    setTimeout(function() {
                        $('#' + inputid).focus()
                    },
                    100)
                },
                confirm: function() {
                    var value = $('#' + inputid).val();
                    if ($.trim(value) == '' && required) {
                        $('#' + inputid).focus();
                        return false
                    }
                    if (callback && typeof(callback) == 'function') {
                        callback(value)
                    }
                }
            })
        })
    },
    tip.promptlive = function(msg, options, password) {
        var callback = null;
        var maxlength = null;
        var required = false;
        var input_type = password ? 'password': 'text';
        if (typeof options == 'function') {
            callback = options
        } else if (typeof options == 'object') {
            maxlength = options.maxlength || null;
            callback = options.callback && typeof options.callback == 'function' ? options.callback: null;
            required = options.required || false
        }
        var inputid = 'prompt_' + ( + new Date());
        var max = maxlength ? " maxlength='" + maxlength + "' ": '';
        myrequire(['jquery.confirm'],
        function() {
            $.alert({
                title: '提示',
                content: "<p>" + msg + "</p><p><input id='" + inputid + "' type='" + input_type + "' class='form-control' name='confirm' placeholder='' " + max + " /></p>",
                confirmButtonClass: 'btn-primary',
                confirmButton: '确 定',
                closeIcon: true,
                animation: 'top',
                keyboardEnabled: true,
                onOpen: function() {
                    setTimeout(function() {
                        $('#' + inputid).focus()
                    },
                    100)
                },
                confirm: function() {
                    var value = $('#' + inputid).val();
                    if ($.trim(value) == '' && required) {
                        $('#' + inputid).focus();
                        return false
                    }
                    if (callback && typeof(callback) == 'function') {
                        callback(value);
                        return false
                    }
                }
            })
        })
    },
    tip.alert = function(msg, callback) {
        msg = msg.replace(/</g, "<");
        msg = msg.replace(/>/g, ">");
        myrequire(['jquery.confirm'],
        function() {
            $.alert({
                title: '提示',
                content: msg,
                confirmButtonClass: 'btn-primary',
                confirmButton: '确 定',
                animation: 'top',
                confirm: function() {
                    if (callback && typeof(callback) == 'function') {
                        callback()
                    }
                }
            })
        })
    },
    1;
    var Notify = function(element, options) {
        this.$element = $(element);
        this.options = $.extend({},
        $.fn.notify.defaults, options);
        var cls = this.options.type ? "msg-" + this.options.type: "msg-success";
        var $note = '<span class="msg ' + cls + '">' + this.options.message + '</span>';
        this.$element.html($note);
        return this
    };
    Notify.prototype.show = function() {
        this.$element.addClass('in'),
        this.$element.append(this.$note);
        var autoClose = this.options.autoClose || true;
        if (autoClose) {
            var self = this;
            setTimeout(function() {
                self.close()
            },
            this.options.delay || 2000)
        }
    },
    Notify.prototype.close = function() {
        var self = this;
        self.$element.removeClass('in').transitionEnd(function() {
            self.$element.empty();
            if (self.options.onClosed) {
                self.options.onClosed(self)
            }
        });
        if (self.options.onClose) {
            self.options.onClose(self)
        }
    },
    $.fn.notify = function(options) {
        return new Notify(this, options)
    },
    $.fn.notify.defaults = {
        type: "success",
        delay: 3000,
        message: ''
    },
    tip.msgbox = {
        show: function(options) {
            if (options.url) {
                options.url = options.url.replace(/&/ig, "&");
                options.onClose = function() {
                    redirect(options.url)
                }
            }
            if (options.message && options.message.length > 17) {
                tip.alert(options.message,
                function() {
                    if (options.url) {
                        redirect(options.url)
                    }
                });
                return
            }
            notify = window.msgbox.notify(options),
            notify.show()
        },
        suc: function(msg, url, onClose, onClosed) {
            tip.msgbox.show({
                delay: 2000,
                type: "success",
                message: msg,
                url: url,
                onClose: onClose,
                onClosed: onClosed
            })
        },
        err: function(msg, url, onClose, onClosed) {
            tip.msgbox.show({
                delay: 2000,
                type: "error",
                message: msg,
                url: url,
                onClose: onClose,
                onClosed: onClosed
            })
        }
    },
    tip.impower = function(msg, callback, cancel_callback) {
        msg = msg.replace(/</g, "<");
        msg = msg.replace(/>/g, ">");
        myrequire(['jquery.confirm'],
        function() {
            $.confirm({
                title: '  ',
                content: msg,
                confirmButtonClass: 'btn-default',
                cancelButtonClass: 'btn-primary',
                confirmButton: '重新上传',
                cancelButton: '审核完成',
                animation: 'top',
                closeIcon: true,
                confirm: function() {
                    if (callback && typeof(callback) == 'function') {
                        callback()
                    }
                },
                cancel: function() {
                    if (cancel_callback && typeof(cancel_callback) == 'function') {
                        cancel_callback()
                    }
                }
            })
        })
    };
    window.tip = tip
});

发表评论

邮箱地址不会被公开。 必填项已用*标注