|
- (function($) {
- window.tabbar = window.tabbar || {};
- var initData = {};
- var t_tabAry =[];
- window.tabbar.init = function(initData, callBack) {
- var t_index = initData['index'] ? initData['index'] : 0;
-
- var arr = [{
- title: '首页',
- img: 'url(images/tabbar/shouye_n.png)',
- sel_img: 'url(images/tabbar/shouye_s.png)'
- }, {
- title: '目的地',
- img: 'url(images/tabbar/mudidi_n.png)',
- sel_img: 'url(images/tabbar/mudidi_s.png)'
- }, {
- title: '行程',
- img: 'url(images/tabbar/xingcheng_n.png)',
- sel_img: 'url(images/tabbar/xingcheng_s.png)'
- }, {
- title: '我的',
- img: 'url(images/tabbar/wode_n.png)',
- sel_img: 'url(images/tabbar/wode_s.png)'
- }];
- t_tabAry = initData['tabAry'] ? initData['tabAry'] : arr;
- createHTML(t_tabAry);
- if(t_index > t_tabAry.length) {
- t_index = 0;
- }
- function createHTML(t_tabAry) {
- var html = '';
- t_tabAry.forEach(function(dict, index) {
- var tempHTML = '<div class="ub-f1 ub ub-ver tx-c controller ub-pc ub-ac" data-index=' + index + ' >' +
- '<div style="background-image:'+dict.img+';background-repeat: no-repeat;background-size: 100% 100%;width:0.25rem;height:0.25rem;margin-bottom:0.03rem;"></div>' +
- '<div class="select_title">' + dict.title + '</div>' +
- '</div>'
- html += tempHTML;
- })
- $('.tabbar').html(html);
- }
- $('.controller').each(function(index, domE) {
- $(this).children().eq(1).removeClass('select_title');
- $(this).children().eq(1).addClass('normal_title');
-
- if(index == t_index) {
- $(this).children().eq(0).css('background-image',t_tabAry[t_index].sel_img);
- $(this).children().eq(1).removeClass('normal_title');
- $(this).children().eq(1).addClass('select_title');
- }
- });
- $('.controller').on('click', function() {
- var c_index = $(this).attr('data-index')-0;
- if(typeof(callBack) == 'function') {
- callBack(c_index);
- }
- switch(c_index) {
- case 0:
- window.location.href = './travel_book.html';
- break;
- case 1:
- window.location.href = './end_area.html';
- break;
- case 2:
- window.location.href = './trip_list.html';
- break;
- case 3:
- window.location.href = './travel_book.html';
- break;
- default:
- break;
- }
- })
- }
-
- })(jQuery)
|