othersetTmp.js 3.92 KB
var urlarr = JSON.parse(sessionStorage.getItem("threemenulist"));
console.log(urlarr)
var _html = '';
for(var i=0;i<urlarr.length;i++){
    if(i==0){
        _html  += '<li data-url="'+urlarr[i].url+'" id="button-'+urlarr[i].url+'" class="ITD-topbar-clickactive"><a href="#/'+urlarr[i].url+'"><div >'+urlarr[i].name+'</div></a></li>'
    }else{
        _html  += '<li data-url="'+urlarr[i].url+'" id="button-'+urlarr[i].url+'" ><a href="#/'+urlarr[i].url+'"><div >'+urlarr[i].name+'</div></a></li>'
    }
}
$('#button-btn').html(_html);
function Router(){
    this.routes = {};
    this.curUrl = '';

    this.route = function(path, callback){
        this.routes[path] = callback || function(){};
    };

    this.refresh = function(){
        this.curUrl = location.hash.slice(1) || '/'+urlarr[0].url;
        console.log(this.curUrl)
        this.routes[this.curUrl]();
    };

    this.init = function(){
        window.addEventListener('load', this.refresh.bind(this), false);
        window.addEventListener('hashchange', this.refresh.bind(this), false);
    }
}
var R = new Router();
R.init();
var res = $('#main-con');
R.route('/discountrule', function() {
    $("#pageCssLink").attr("href",'../../assets/pages/scripts/otherSetting/disCount/discountrule.css');
    res.load('../../assets/pages/scripts/otherSetting/disCount/discountrule.html');
    $('.ITD-topbar-wrap li').removeClass('ITD-topbar-clickactive');
    $('#button-discountrule').addClass('ITD-topbar-clickactive');
});
R.route('/whitelist', function() {
    $("#pageCssLink").attr("href",'../../assets/pages/scripts/otherSetting/whiteList/whitelist.css');
    res.load('../../assets/pages/scripts/otherSetting/whiteList/whitelist.html');
    $('.ITD-topbar-wrap li').removeClass('ITD-topbar-clickactive');
    $('#button-whitelist').addClass('ITD-topbar-clickactive');

});
R.route('/settlerule', function() {
    $("#pageCssLink").attr("href",'../../assets/pages/scripts/otherSetting/settleRule/settlerule.css');
    res.load('../../assets/pages/scripts/otherSetting/settleRule/settlerule.html');
    $('.ITD-topbar-wrap li').removeClass('ITD-topbar-clickactive');
    $('#button-settlerule').addClass('ITD-topbar-clickactive');

});
R.route('/apprelease', function() {
    $("#pageCssLink").attr("href",'../../assets/pages/scripts/otherSetting/apprel/apprelease.css');
    res.load('../../assets/pages/scripts/otherSetting/apprel/apprelease.html');
    $('.ITD-topbar-wrap li').removeClass('ITD-topbar-clickactive');
    $('#button-apprelease').addClass('ITD-topbar-clickactive');

});
R.route('/couponsetting', function() {
    $("#pageCssLink").attr("href",'../../assets/pages/scripts/otherSetting/couponFile/couponsetting.css');
    res.load('../../assets/pages/scripts/otherSetting/couponFile/couponsetting.html');
    $('.ITD-topbar-wrap li').removeClass('ITD-topbar-clickactive');
    $('#button-couponsetting').addClass('ITD-topbar-clickactive');

});
R.route('/giftrules', function() {
    $("#pageCssLink").attr("href",'../../assets/pages/scripts/otherSetting/giftRule/giftrules.css');
    res.load('../../assets/pages/scripts/otherSetting/giftRule/giftrules.html');
    $('.ITD-topbar-wrap li').removeClass('ITD-topbar-clickactive');
    $('#button-giftrules').addClass('ITD-topbar-clickactive');

});
R.route('/undercoupon', function() {
    $("#pageCssLink").attr("href",'../../assets/pages/scripts/otherSetting/xxcoupon/undercoupon.css');
    res.load('../../assets/pages/scripts/otherSetting/xxcoupon/undercoupon.html');
    $('.ITD-topbar-wrap li').removeClass('ITD-topbar-clickactive');
    $('#button-undercoupon').addClass('ITD-topbar-clickactive');

});
R.route('/appactivity', function() {
    $("#pageCssLink").attr("href",'../../assets/pages/scripts/otherSetting/appactive/appactivity.css');
    res.load('../../assets/pages/scripts/otherSetting/appactive/appactivity.html');
    $('.ITD-topbar-wrap li').removeClass('ITD-topbar-clickactive');
    $('#button-appactivity').addClass('ITD-topbar-clickactive');

});