index.js 1.2 KB
/**
 * index
 * 默认依赖
 */
'use strict';

var $ = require('jquery');

require('yoho.bootstrap');

/**
 * 左侧导航
 */
$('#sidebar .nav .has-sub>a').click(function() {
    var child = $(this).parent().find('.sub-menu');

    $('#sidebar .nav .has-sub>a').each(function() {
        $(this).find('.sub-menu').slideUp('fast');
        $(this).removeClass('active');
    });

    if (!child.is(':visible')) {
        child.slideDown('fast');
        if (!child.parent().hasClass('active'))
            child.parent().addClass('active');
    } else {
        child.slideUp('fast');
        child.parent().removeClass('active');
    }
    return false;
});

/**
 * 左侧最小化
 */
$(".sidebar-minify-btn").click(function(){
    $("#page-container").toggleClass("page-sidebar-minified");
});

/**
 * 切换店铺
 */
$('.shops_id').click(function(){
    var shop_id = $(this).attr('data-shopid');
    $.getJSON('/index/ajaxshop?shops_id='+shop_id, function (data){
        if(data.code == 200){
            window.location.href="/";
        }else{
            alert(data.message);
        }
    })
});
/*过滤特殊字符*/
$(document).on("keyup",":text",function(){
    $(this).val($(this).val().replace(/\W/g,''))
});