From 3f381f575589f0d81efe009b5b77ec54766d97ab Mon Sep 17 00:00:00 2001
From: wsling <shuiling.wang@yoho.cn>
Date: Wed, 15 Jun 2016 18:55:47 +0800
Subject: [PATCH] 发票

---
 static/js/cart/entry.js                                              |  1 +
 static/js/cart/invoice-info.js                                       | 65 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++--
 static/js/cart/order-ensure.js                                       | 20 ++++++++++----------
 static/sass/me/_order-detail.css                                     | 24 ++++++++++++++++++++++++
 template/m.yohobuy.com/actions/cart/index/invoice-info.phtml         | 10 ++++------
 template/m.yohobuy.com/actions/index/home/order-detail.phtml         | 22 ++++++++++++++++++++++
 yohobuy/m.yohobuy.com/application/controllers/Home.php               |  6 ++++++
 yohobuy/m.yohobuy.com/application/modules/Cart/controllers/Index.php |  3 ++-
 8 files changed, 132 insertions(+), 19 deletions(-)

diff --git a/static/js/cart/entry.js b/static/js/cart/entry.js
index 834dcc7..c886bc1 100644
--- a/static/js/cart/entry.js
+++ b/static/js/cart/entry.js
@@ -7,5 +7,6 @@
 require('./cart');
 require('./gift-advance');
 require('./order-ensure');
+require('./invoice-info');
 require('./select-coupon');
 require('./select-address');
diff --git a/static/js/cart/invoice-info.js b/static/js/cart/invoice-info.js
index 6f80743..161b8e2 100644
--- a/static/js/cart/invoice-info.js
+++ b/static/js/cart/invoice-info.js
@@ -4,10 +4,16 @@
  * @date: 2016/6/14
  */
 
-var $ = require('jquery');
+var $ = require('jquery'),
+    tip = require('../plugin/tip'),
+    dialog = require('../me/dialog');
 
 var $invoiceNotice = $('.invoice-notice'),
-    $companyArea = $('.company-area');
+    $companyArea = $('.company-area'),
+    $editFlag = $('.edit-flag'),
+    $tel = $('.tel');
+
+var myreg = /^(((13[0-9]{1})|(15[0-9]{1})|(18[0-9]{1}))+\d{8})$/;
 
 require('../common');
 
@@ -17,6 +23,8 @@ function chooseAction(pDom, dom) {
     } else {
         pDom.find('.choose').removeClass('icon-cb-radio icon-radio').addClass('icon-radio');
         dom.removeClass('icon-radio').addClass('icon-cb-radio');
+        dom.parent().addClass('on');
+        $editFlag.val('true');
     }
 }
 
@@ -43,6 +51,7 @@ $('.invoice-type span').on('touchstart', function() {
         return;
     } else {
         $(this).addClass('on').siblings().removeClass('on');
+        $editFlag.val('true');
     }
 });
 
@@ -54,4 +63,56 @@ $('.invoice-btn').on('touchstart', function() {
 
 $('.think-ok, .mask-bg').on('touchstart', function() {
     $invoiceNotice.fadeOut();
+});
+
+$('.istel').one('input', function() {
+    $(this).val('').removeClass('istel');
+});
+
+$tel.on('input', function() {
+    $(this).attr('data-tel', $(this).val());
+    $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';
+            });
+       }
+    }
 });
\ No newline at end of file
diff --git a/static/js/cart/order-ensure.js b/static/js/cart/order-ensure.js
index e7a3816..845e07f 100644
--- a/static/js/cart/order-ensure.js
+++ b/static/js/cart/order-ensure.js
@@ -189,16 +189,16 @@ function submitOrder() {
     if (isSubmiting) {
         return false;
     }
-    if (orderInfo('invoice')) {
-        if (!invoiceText) {
-            tip.show('请输入发票抬头');
-            return;
-        }
-        if (invoiceText.length > 30) {
-            tip.show('发票抬头不得超过30个汉字');
-            return;
-        }
-    }
+    // if (orderInfo('invoice')) {
+    //     if (!invoiceText) {
+    //         tip.show('请输入发票抬头');
+    //         return;
+    //     }
+    //     if (invoiceText.length > 30) {
+    //         tip.show('发票抬头不得超过30个汉字');
+    //         return;
+    //     }
+    // }
     if (msg) {
         if (msg.length > 40) {
             tip.show('留言不得超过40个汉字');
diff --git a/static/sass/me/_order-detail.css b/static/sass/me/_order-detail.css
index 082fb8b..7e39ba5 100644
--- a/static/sass/me/_order-detail.css
+++ b/static/sass/me/_order-detail.css
@@ -263,4 +263,28 @@
             }
         }
     }
+
+    .invoice-info {
+        margin: 20px 0;
+        border-top: 1px solid #e0e0e0;
+        border-bottom: 1px solid #e0e0e0;
+        background: #fff;
+        padding: 30px;
+        box-sizing: border-box;
+        overflow: hidden;
+
+        span {
+            font-size: 28px;
+            color: #444;
+            line-height: 40px;
+        }
+
+        .invoice-fr {
+            float: right;
+        }
+
+        .invoice-see {
+            color: #d0021b;
+        }
+    }
 }
diff --git a/template/m.yohobuy.com/actions/cart/index/invoice-info.phtml b/template/m.yohobuy.com/actions/cart/index/invoice-info.phtml
index 7cb5545..a9345f4 100644
--- a/template/m.yohobuy.com/actions/cart/index/invoice-info.phtml
+++ b/template/m.yohobuy.com/actions/cart/index/invoice-info.phtml
@@ -19,11 +19,7 @@
         <li>
             <span class="title">*发票人手机:</span>
             <span class="phone">
-                {{#if phone}}
-                    {{.}}
-                {{else}}
-                    <input type="text" name="tel" class="tel" value="" placeholder="可通过手机号在发票服务平台查询">
-                {{/if}}
+                <input type="text" name="tel" data-tel="{{completeTel}}" class="tel {{#phone}}istel{{/phone}}" value="{{phone}}" placeholder="可通过手机号在发票服务平台查询">
             </span>
         </li>
         <li class="company-area"><input type="text" name="company" class="company" value="" placeholder="填写单位名称"></li>
@@ -39,7 +35,7 @@
         {{/each}}
     </ul>
 
-    <div class="btn-area"><span class="confirm-btn">确认</span><div>
+    <div class="btn-area"><span class="confirm-btn">确认</span></div>
 
     <div class="invoice-notice">
         <div class="mask-bg"></div>
@@ -53,5 +49,7 @@
         </div>
     </div>
 
+    <input type="hidden" class="edit-flag" value="false" />
+
     {{> layout/footer}}
 </div>
diff --git a/template/m.yohobuy.com/actions/index/home/order-detail.phtml b/template/m.yohobuy.com/actions/index/home/order-detail.phtml
index 250d8d1..93b0fef 100644
--- a/template/m.yohobuy.com/actions/index/home/order-detail.phtml
+++ b/template/m.yohobuy.com/actions/index/home/order-detail.phtml
@@ -92,6 +92,28 @@
             </p>
         {{/if}}
 
+        {{#invoiceInfo}}
+            <ul class="invoice-info">
+                <li>
+                    <span>发票信息</span>
+                    <span class="invoice-fr">{{#if invoiceType}}电子发票{{else}}纸质发票{{/if}}</span>
+                </li>
+                <li>
+                    <span>发票抬头</span>
+                    <span class="invoice-fr">{{invoiceTop}}</span>
+                </li>
+                <li>
+                    <span>发票内容</span>
+                    <span class="invoice-fr">{{invoiceCont}}</span>
+                </li>
+                {{#if invoiceType}}
+                <li>
+                    <a href="{{invoiceSee}}"><span class="invoice-fr invoice-see">点击查看电子发票</span></a>
+                </li>
+                {{/if}}
+            </ul>
+        {{/invoiceInfo}}
+
         <div class="opt block">
             {{#unless unreceived}}
             {{#unless unpaid}}
diff --git a/yohobuy/m.yohobuy.com/application/controllers/Home.php b/yohobuy/m.yohobuy.com/application/controllers/Home.php
index 9c0f22c..181205b 100644
--- a/yohobuy/m.yohobuy.com/application/controllers/Home.php
+++ b/yohobuy/m.yohobuy.com/application/controllers/Home.php
@@ -1073,6 +1073,12 @@ class HomeController extends AbstractAction
 
         $this->_view->display('order-detail', array(
             'orderDetailPage' => true,
+            'invoiceInfo' => array(
+                'invoiceType' => true,
+                'invoiceTop' => '有货(商贸)服务有限公司',
+                'invoiceCont' => '服装',
+                'invoiceSee' => ''
+            ),
             'serviceUrl' => 'http://chat8.live800.com/live800/chatClient/chatbox.jsp?companyID=620092&configID=149091&jid=8732423409&info=',
             'orderDetail' => $orderDetail,
             'orderCode' => $orderCode,
diff --git a/yohobuy/m.yohobuy.com/application/modules/Cart/controllers/Index.php b/yohobuy/m.yohobuy.com/application/modules/Cart/controllers/Index.php
index 9175ec6..40d16f7 100644
--- a/yohobuy/m.yohobuy.com/application/modules/Cart/controllers/Index.php
+++ b/yohobuy/m.yohobuy.com/application/modules/Cart/controllers/Index.php
@@ -353,7 +353,8 @@ class IndexController extends AbstractAction
         $data = array(
             'invoiceInfoPage' => true,
             'invoiceNotice' => '发票须知',
-            'phone' => '',
+            'phone' => '150****4536',
+            'completeTel' => '15050524536',
             'invoiceCont' => '服装',
             'content' => array(
                 array(
--
libgit2 0.24.0