ticket-ensure.js 1.27 KB
/**
 * @description: 订单保存
 * @time: 2015/12/21
 */

var $ = require('yoho.jquery');

var dialog = require('../common/dialog');

//立即购买-门票
var TicketCat = {
    el: {
        $showTicketMobile: $('.show-ticket-mobile'),
        $ticketMobile: $('.ticket-mobile'),
        $ticketModifyBtn: $('.ticket-modify-btn'),
        $setTicketMobile: $('.set-ticket-mobile'),
        $ticketMobileBtn: $('.ticket-mobile-btn'),
        $ticketMobileInput: $('.ticket-mobile-input')
    },
    init: function() {
        var el = this.el;

        //修改手机号按钮
        el.$ticketModifyBtn.click(function() {
            el.$showTicketMobile.addClass('hide');
            el.$setTicketMobile.removeClass('hide');
        });

        //保存手机号按钮
        el.$ticketMobileBtn.click(function() {
            var val = el.$ticketMobileInput.val(),
                phoneReg = /^(13[0-9]|15[012356789]|17[678]|18[0-9]|14[57])[0-9]{8}$/;

            if (!phoneReg.test(val)) {
                new dialog.Alert('请输入正确的手机号!').show();
                return;
            }
            el.$showTicketMobile.removeClass('hide');
            el.$setTicketMobile.addClass('hide');
            el.$ticketMobile.text(val);
        });
    }
};

TicketCat.init();