Authored by 王水玲

电子发票

... ... @@ -11,12 +11,16 @@ var $ = require('jquery'),
var $invoiceNotice = $('.invoice-notice'),
$companyArea = $('.company-area'),
$editFlag = $('.edit-flag'),
$chooseCont = $('.choose-cont'),
$tel = $('.tel');
var myreg = /^(((13[0-9]{1})|(15[0-9]{1})|(18[0-9]{1}))+\d{8})$/;
var myreg = /^(((13[0-9]{1})|(15[0-9]{1})|(18[0-9]{1}))+\d{8})$/,
linkUrl = '/cart/index/orderEnsure?cartType=ordinary';
require('../common');
//单选效果
function chooseAction(pDom, dom) {
if (dom.hasClass('icon-cb-radio')) {
return;
... ... @@ -28,12 +32,67 @@ function chooseAction(pDom, dom) {
}
}
// 确认表单事件
function confirmAction() {
var type = $('.invoice-type').find('.on').text(),
title = $('.invoice-top').find('.on').text(),
tel = $tel.data('tel'),
company = $('.company').val(),
cont = $chooseCont.html();
if ($editFlag.val() === 'true') {
if (!myreg.test($tel.data('tel'))) {
tip.show('请输入正确手机号');
$tel.focus();
return false;
} else {
dialog.showDialog({
dialogText: '确认保存修改内容?',
hasFooter: {
leftBtnText: '取消',
rightBtnText: '确定'
}
}, function() {
$.ajax({
method: 'post',
url: '/cart/index/del',
data: {
type: type,
title: title,
tel: tel,
company: title === '单位' ? company : '',
cont: cont
}
}).then(function(data) {
if (data.code === 200) {
dialog.showDialog({
dialogText: '修改成功',
autoHide: true,
fast: true
});
window.location.href = linkUrl;
} else {
tip.show(data.message);
}
}, function() {
tip.show('网络异常');
window.location.reload();
});
}, function() {
window.location.href = linkUrl;
});
}
} else {
window.location.href = linkUrl;
}
}
// 发票抬头、发票内容选择
$('.invoice-top span, .invoice-cont li').on('touchstart', function(e) {
$('.invoice-top span, .invoice-cont li').not('.invoice-cont .cont-title').on('touchstart', function(e) {
chooseAction($(this).parent(), $(this).find('.choose'));
if ($(this).parent().hasClass('invoice-cont')) {
$('.choose-cont').html($(this).text());
$chooseCont.html($(this).text());
}
if ($(this).text() === '单位') {
... ... @@ -61,10 +120,12 @@ $('.invoice-btn').on('touchstart', function() {
return false;
});
// 关闭发票须知弹框
$('.think-ok, .mask-bg').on('touchstart', function() {
$invoiceNotice.fadeOut();
});
// 电话清空
$('.istel').one('input', function() {
$(this).val('').removeClass('istel');
});
... ... @@ -74,45 +135,8 @@ $tel.on('input', function() {
$editFlag.val('true');
});
$('.confirm-btn').on('touchstart', function() {
if ($editFlag.val() === 'true') {
if (!myreg.test($tel.data('tel'))) {
tip.show('请输入正确手机号');
$tel.focus();
return false;
} else {
dialog.showDialog({
dialogText: '确认保存修改内容?',
hasFooter: {
leftBtnText: '取消',
rightBtnText: '确定'
}
}, function() {
$.ajax({
method: 'post',
url: '/cart/index/del',
data: {
type: $('.invoice-type').find('.on').text(),
title: $('.invoice-top').find('.on').text()
}
}).then(function(data) {
if (data.code === 200) {
dialog.showDialog({
dialogText: '修改成功',
autoHide: true,
fast: true
});
window.location.href = '/cart/index/orderEnsure?cartType=ordinary';
} else {
tip.show(data.message);
}
}, function() {
tip.show('网络异常');
window.location.reload();
});
}, function() {
window.location.href = '/cart/index/orderEnsure?cartType=ordinary';
});
}
}
// 确认及返回事件
$('.confirm-btn, .nav-back').on('touchstart', function(e) {
e.preventDefault();
confirmAction();
});
\ No newline at end of file
... ...
... ... @@ -189,6 +189,7 @@ function submitOrder() {
if (isSubmiting) {
return false;
}
// if (orderInfo('invoice')) {
// if (!invoiceText) {
// tip.show('请输入发票抬头');
... ... @@ -199,6 +200,7 @@ function submitOrder() {
// return;
// }
// }
if (msg) {
if (msg.length > 40) {
tip.show('留言不得超过40个汉字');
... ...
... ... @@ -26,7 +26,7 @@
</ul>
<ul class="invoice-cont">
<li>
<li class="cont-title">
<span>发票内容:</span>
<span class="choose-cont">{{invoiceCont}}</span>
</li>
... ...