withdrew.js 3.29 KB
/**
 * 提现 操作
 */
! function($) {
    "use strict";

    var config = {
        selectCb: function() {} //选中回调
    };

    /**
     * 初始化下拉控件
     * @param  {[type]}   $ele [元素]
     * @param  {Function} cb   [选中回调]
     */
    function initSlect($ele, cb) {
        var $select_form = $(".select-form", $ele);
        var $current = $(".current", $ele);

        $ele.on("click", ".change", function openForm() {
            $select_form.show();
            $(".change", $ele).hide();
        });

        $ele.on("click", ".current", function openForm() {
            $select_form.show();
            $(".change", $ele).hide();
        });

        $ele.on("click", ".select-form .banks li", function openForm() {
            $(".change", $ele).show();
            $select_form.hide();
            var cardId = Number($(this).attr('data-cardid'));
            $current.html($.clone($(this)[0]));
            if (typeof cb === "function") {
                cb(cardId);
            }
        });

        $('body').on('click', function(e) {
            var $dropmenu = $(".dropmenu");
            var target = $(e.target);
            if (target.closest('html').length && !target.closest('.current').length && !target.closest('.select-form .banks li').length && $(".select-form", $ele).is(":visible")) {
                $(".change", $ele).show();
                $select_form.hide();
            }
        });
    }

    function init() {
        // 初始化下拉选择
        initSlect($(".modal-select"), config.selectCb);
        // 业务事件
        bindEvent();
    }

    function on_btn_addbank() {
        $('.modal-select').hide();
        $("#ids_addbankbox").show();
        return false;
    }

    function on_btn_reback_select() {
        on_btn_reback2add();
        $('.modal-select').show();
        $("#ids_addbankbox").hide();
    }

    function on_btns_selectbank2add() {
        $("#btns_selectbank2add").hide();
        $("#ids_addbankform").show();
    }

    function on_btn_reback2add() {
        $("#ids_addbankform").hide();
        $("#btns_selectbank2add").show();
    }


    function bindEvent() {
        $("#btn_addbank").click(on_btn_addbank);
        $("#btn_reback_select").click(on_btn_reback_select);
        $("#btns_selectbank2add").on('click', 'a', on_btns_selectbank2add);
        $("#btn_reback2add").click(on_btn_reback2add);
    }

    if (!window.withdrew) {
        window.withdrew = {
            init: init,
            config: function(key, value) {
                if (!/\w+/.test(key)) {
                    return false;
                }
                if (typeof value !== "undefined") {
                    config[key] = value;
                } else {
                    return config[key];
                }
            }
        };
    }
}(jQuery);

//apply
$(function() {

    withdrew.config('selectCb', function(id) {
        console.log(id);
    });

    withdrew.init();
});


define(function(require, exports, module) {
  var Miniclock = require('miniclock');
  require('fancybox');

    $('.fancy').fancybox({

    });

    $('.timer').on({
      click: function(){
        new Miniclock(this, {
          SD: "重新发送",
          WT: "s",
          ban: "disabled",
          callback: function(){

          }
        });
      }
    })
});