From f08ceb4b498dc88bf44fffa96f0a9e16c5cfd3b9 Mon Sep 17 00:00:00 2001
From: 🍓 <lixia.zhang@yoho.cn>
Date: Fri, 15 Jul 2016 13:46:31 +0800
Subject: [PATCH] 电子发票bug

---
 template/www.yohobuy.com/actions/cart/index/order-ensure.phtml |  2 +-
 web-static/js/order/ensure.js                                  | 41 ++++++++++++++++++++++++++++++++++++++++-
 2 files changed, 41 insertions(+), 2 deletions(-)

diff --git a/template/www.yohobuy.com/actions/cart/index/order-ensure.phtml b/template/www.yohobuy.com/actions/cart/index/order-ensure.phtml
index 09d38ae..ec7039a 100644
--- a/template/www.yohobuy.com/actions/cart/index/order-ensure.phtml
+++ b/template/www.yohobuy.com/actions/cart/index/order-ensure.phtml
@@ -288,7 +288,7 @@
                     <div class="invoice-type mes">电子发票</div>
                     <div class="invoice-partment mes">个人</div>
                     <div class="invoice-kind mes">服装</div>
-                    <div class="revise mes">修改</div>
+                    <div class="revise mes curser-button">修改</div>
                 </div>
                 <div class='invoice-upload hide'>
                     <div class="invoice-upload-type"></div>
diff --git a/web-static/js/order/ensure.js b/web-static/js/order/ensure.js
index f017f49..d646305 100644
--- a/web-static/js/order/ensure.js
+++ b/web-static/js/order/ensure.js
@@ -917,7 +917,7 @@ function saveReceiptInfo() {
     if (finalReceiptMobile === receiptMobileStar) {
         finalReceiptMobile = receiptMobile;
     } else {
-        verifymobile = /[0-9]{11}/;
+        verifymobile = /[1][34578][0-9]{9}/;
         if (!verifymobile.test(finalReceiptMobile)) {
             $('.invoice-phone .enpty-input').removeClass('hide');
             if (finalReceiptMobile.length === 0) {
@@ -954,6 +954,44 @@ function saveReceiptInfo() {
     $receiptInfo.addClass('hide');
     $('.invoice-content-outter').removeClass('hide');
 }
+
+function rejustReceiptInfo() {
+    var inviceType = $('.invoice-type').html(),
+        invoicePartment = $('.invoice-partment').html(),
+        invoiceKind = $('.invoice-kind').html(),
+        invoiceMobile,
+        invoiceMobileStar;
+    if (inviceType === "电子发票") {
+        $eReceiptBtn.trigger("click");
+    } else {
+        $paperReceiptBtn.trigger("click");
+    }
+
+    if (invoicePartment === "个人") {
+        $("input[name='title']").eq(0).attr("checked","checked");
+        $('.invoice-title').addClass('invoice-title-personal-hight');
+        $('.invoice-title .input-line').addClass('hide');
+    } else {
+        $("input[name='title']").eq(1).attr("checked","checked");
+        $('.invoice-title').removeClass('invoice-title-personal-hight');
+        $('.invoice-title .input-line').removeClass('hide');
+        $('#input-organization-name').val(invoicePartment);
+    }
+
+    $("input[name='content']").each(function(){
+        if ($(this).attr('value') === invoiceKind) {
+            $(this).attr("checked","checked");
+        };
+    })
+
+    invoiceMobile = $('.invoice-upload-mobile').html()
+    invoiceMobileStar = invoiceMobile.substr(0, 3) + '****' + invoiceMobile.substr(7);
+
+    if ($('#input-mobile').val() !== invoiceMobileStar) {
+        $('#input-mobile').val(invoiceMobileStar);
+    };        
+}
+
 $receiptInfoSaveBtn.click(function(){
     saveReceiptInfo();
 });
@@ -971,6 +1009,7 @@ $receiptInfoCancelBtn.click(function(){
 
 $('.revise').click(function(){
     $receiptInfo.removeClass('hide');
+    rejustReceiptInfo();
 });
 
 $eReceiptBtn.click(function(){
--
libgit2 0.24.0