Authored by 梁志锋

Merge branch 'develop' of http://git.dev.yoho.cn/web/yohobuy into develop

@@ -23,15 +23,17 @@ class Yohobuy @@ -23,15 +23,17 @@ class Yohobuy
23 // const SERVICE_URL = 'http://service.api.yohobuy.com/'; 23 // const SERVICE_URL = 'http://service.api.yohobuy.com/';
24 // const YOHOBUY_URL = 'http://www.yohobuy.com/'; 24 // const YOHOBUY_URL = 'http://www.yohobuy.com/';
25 25
26 - const API_URL = 'http://apih5.yoho.cn/';  
27 - const API_URL2 = 'http://apih5.yoho.cn/';  
28 - const SERVICE_URL = 'http://serviceh5.yoho.cn/';  
29 - const YOHOBUY_URL = 'http://www.yohobuy.com/'; 26 +// const API_URL = 'http://apih5.yoho.cn/';
  27 +// const API_URL2 = 'http://apih5.yoho.cn/';
  28 +// const SERVICE_URL = 'http://serviceh5.yoho.cn/';
  29 +// const YOHOBUY_URL = 'http://www.yohobuy.com/';
  30 +// const API_OLD = 'http://api2.open.yohobuy.com/';
30 31
31 /* 测试环境 */ 32 /* 测试环境 */
32 - // const API_URL = 'http://testapi.yoho.cn:28078/';  
33 - // const SERVICE_URL = 'http://testservice.yoho.cn:28077/';  
34 - // const YOHOBUY_URL = 'http://www.yohobuy.com/'; 33 + const API_URL = 'http://testapi.yoho.cn:28078/';
  34 + const SERVICE_URL = 'http://testservice.yoho.cn:28077/';
  35 + const YOHOBUY_URL = 'http://www.yohobuy.com/';
  36 + const API_OLD = 'http://test2.open.yohobuy.com/';
35 37
36 38
37 /** 39 /**
@@ -38,7 +38,7 @@ class HelpData @@ -38,7 +38,7 @@ class HelpData
38 $param['code'] = $code; 38 $param['code'] = $code;
39 $param['return_type'] = 'html'; 39 $param['return_type'] = 'html';
40 $param['client_secret'] = Sign::getSign($param); 40 $param['client_secret'] = Sign::getSign($param);
41 - return Yohobuy::post(Yohobuy::API_URL, $param, true); 41 + return Yohobuy::post(Yohobuy::API_OLD, $param, true);
42 } 42 }
43 43
44 44
@@ -129,7 +129,7 @@ class Helpers @@ -129,7 +129,7 @@ class Helpers
129 */ 129 */
130 public static function getShoppingKeyByCookie() 130 public static function getShoppingKeyByCookie()
131 { 131 {
132 - $cookie = isset($_COOKIE['_Spk']) ? $_COOKIE['_Spk'] : ''; 132 + $cookie = isset($_COOKIE['_SPK']) ? $_COOKIE['_SPK'] : '';
133 133
134 return $cookie; 134 return $cookie;
135 } 135 }
@@ -9,6 +9,7 @@ var $ = require('jquery'), @@ -9,6 +9,7 @@ var $ = require('jquery'),
9 Hammer = require('yoho.hammer'); 9 Hammer = require('yoho.hammer');
10 10
11 var chosePanel = require('./chose-panel'), 11 var chosePanel = require('./chose-panel'),
  12 + dialog = require('../me/dialog'),
12 tip = require('../plugin/tip'); 13 tip = require('../plugin/tip');
13 14
14 var $cartContent = $('.cart-content'); 15 var $cartContent = $('.cart-content');
@@ -20,6 +21,48 @@ var navHammer, @@ -20,6 +21,48 @@ var navHammer,
20 21
21 var hasChecked = $('.cart-content:not(.hide) .icon-cb-checked').length > 0 ? true : false; //是否有选中商品 22 var hasChecked = $('.cart-content:not(.hide) .icon-cb-checked').length > 0 ? true : false; //是否有选中商品
22 23
  24 +function shouldSelectGift() {
  25 + var $freebie = $('.freebie');
  26 +
  27 + if ($freebie.length <= 0) {
  28 + return false;
  29 + }
  30 +
  31 + return true;
  32 +}
  33 +
  34 +function shouldLowStocks() {
  35 + var $lowStocks = $('.low-stocks'),
  36 + result = false;
  37 +
  38 + if ($lowStocks.length <= 0) {
  39 + return result;
  40 + }
  41 +
  42 + $lowStocks.each(function(idx, item) {
  43 + if ($(item).parent().parent().parent().siblings('.checkbox').hasClass('icon-cb-checked')) {
  44 + result = true;
  45 + return false;
  46 + }
  47 + });
  48 +
  49 + return result;
  50 +}
  51 +
  52 +function showChooseGifDialog() {
  53 + dialog.showDialog({
  54 + dialogText: '您还未选择赠品,是否去选择赠品',
  55 + hasFooter: {
  56 + leftBtnText: '我不要赠品',
  57 + rightBtnText: '去选择'
  58 + }
  59 + }, function() {
  60 + window.location.href = $('.freebie').find('a').attr('href');
  61 + }, function() {
  62 + window.location.href = '/cart/index/orderEnsure?cartType=' + cartType;
  63 + });
  64 +}
  65 +
23 require('./good'); 66 require('./good');
24 67
25 lazyLoad($('img.lazy')); 68 lazyLoad($('img.lazy'));
@@ -87,7 +130,11 @@ if ($('.freebie').length > 0) { @@ -87,7 +130,11 @@ if ($('.freebie').length > 0) {
87 //}); 130 //});
88 131
89 $('.btn-balance').on('touchend', function() { 132 $('.btn-balance').on('touchend', function() {
90 - if ($('.low-stocks').length > 0) { 133 + if (shouldSelectGift()) {
  134 + showChooseGifDialog();
  135 + return false;
  136 + }
  137 + if (shouldLowStocks()) {
91 tip.show('库存不足无法结算'); 138 tip.show('库存不足无法结算');
92 return false; 139 return false;
93 } 140 }
@@ -103,7 +150,7 @@ $('.chose').on('touchend', function() { @@ -103,7 +150,7 @@ $('.chose').on('touchend', function() {
103 chosePanel.show(); 150 chosePanel.show();
104 }); 151 });
105 152
106 -if ($('.cart-zero').length > 0) { 153 +if ($('.shopping-cart-good').length <= 0) {
107 require('../product/recommend-for-you'); 154 require('../product/recommend-for-you');
108 } 155 }
109 156
@@ -23,7 +23,8 @@ var dispatchModeHammer, @@ -23,7 +23,8 @@ var dispatchModeHammer,
23 payType, 23 payType,
24 priceTmpl = Handlebars.compile($('#tmpl-price').html()), 24 priceTmpl = Handlebars.compile($('#tmpl-price').html()),
25 queryString = $.queryString(), 25 queryString = $.queryString(),
26 - orderInfo = order.orderInfo; 26 + orderInfo = order.orderInfo,
  27 + isSubmiting;
27 28
28 lazyLoad(); 29 lazyLoad();
29 30
@@ -127,6 +128,9 @@ function submitOrder() { @@ -127,6 +128,9 @@ function submitOrder() {
127 var invoiceText = $invoice.find('[name="invoice-title"]').val() || orderInfo('invoiceText'), 128 var invoiceText = $invoice.find('[name="invoice-title"]').val() || orderInfo('invoiceText'),
128 msg = $('#msg').find('input').val() || orderInfo('msg'); 129 msg = $('#msg').find('input').val() || orderInfo('msg');
129 130
  131 + if (isSubmiting) {
  132 + return false;
  133 + }
130 if (orderInfo('invoice')) { 134 if (orderInfo('invoice')) {
131 if (!invoiceText) { 135 if (!invoiceText) {
132 tip.show('请输入发票抬头'); 136 tip.show('请输入发票抬头');
@@ -144,6 +148,7 @@ function submitOrder() { @@ -144,6 +148,7 @@ function submitOrder() {
144 } 148 }
145 } 149 }
146 loading.showLoadingMask(); 150 loading.showLoadingMask();
  151 + isSubmiting = true;
147 $.ajax({ 152 $.ajax({
148 method: 'POST', 153 method: 'POST',
149 url: '/cart/index/orderSub', 154 url: '/cart/index/orderSub',
@@ -184,6 +189,7 @@ function submitOrder() { @@ -184,6 +189,7 @@ function submitOrder() {
184 }).fail(function() { 189 }).fail(function() {
185 tip.show('网络出错'); 190 tip.show('网络出错');
186 }).always(function() { 191 }).always(function() {
  192 + isSubmiting = false;
187 loading.hideLoadingMask(); 193 loading.hideLoadingMask();
188 }); 194 });
189 } 195 }
@@ -191,8 +191,8 @@ function getCouponDate() { @@ -191,8 +191,8 @@ function getCouponDate() {
191 191
192 getCouponDate(); 192 getCouponDate();
193 193
194 -$(window).scroll(function() {  
195 - if ($(window).scrollTop() + $(window).height() > $('body').height() * 0.9) {  
196 - getCouponDate();  
197 - }  
198 -}); 194 +// $(window).scroll(function() {
  195 +// if ($(window).scrollTop() + $(window).height() > $('body').height() * 0.9) {
  196 +// getCouponDate();
  197 +// }
  198 +// });
@@ -33,7 +33,7 @@ dialogTpl = '<div id="dialog-wrapper" class="dialog-wrapper">' + @@ -33,7 +33,7 @@ dialogTpl = '<div id="dialog-wrapper" class="dialog-wrapper">' +
33 33
34 dialogTemplate = Handlebars.compile(dialogTpl); 34 dialogTemplate = Handlebars.compile(dialogTpl);
35 35
36 -exports.showDialog = function(data, callback) { 36 +exports.showDialog = function(data, callback, callbackForLeft) {
37 37
38 var dialogStr = dialogTemplate(data), 38 var dialogStr = dialogTemplate(data),
39 $dialogBox, 39 $dialogBox,
@@ -76,6 +76,9 @@ exports.showDialog = function(data, callback) { @@ -76,6 +76,9 @@ exports.showDialog = function(data, callback) {
76 dialogWrapperHammer.on('tap', function(event) { 76 dialogWrapperHammer.on('tap', function(event) {
77 77
78 if ($(event.target).hasClass('dialog-left-btn')) { 78 if ($(event.target).hasClass('dialog-left-btn')) {
  79 + if (typeof callbackForLeft === 'function') {
  80 + callbackForLeft();
  81 + }
79 $dialogWrapper.fadeOut(); 82 $dialogWrapper.fadeOut();
80 } else if ($(event.target).hasClass('dialog-right-btn')) { 83 } else if ($(event.target).hasClass('dialog-right-btn')) {
81 callback(); 84 callback();
@@ -19,6 +19,9 @@ $.ajax({ @@ -19,6 +19,9 @@ $.ajax({
19 if (count > 99) { 19 if (count > 99) {
20 count = '99+'; 20 count = '99+';
21 } 21 }
  22 + if (count === 0) {
  23 + $('.cart-count').remove();
  24 + }
22 $cart.find('.cart-count').html(count).removeClass('hide'); 25 $cart.find('.cart-count').html(count).removeClass('hide');
23 } 26 }
24 } 27 }
@@ -185,7 +185,7 @@ @@ -185,7 +185,7 @@
185 height: pxToRem(60px); 185 height: pxToRem(60px);
186 color: #444; 186 color: #444;
187 background: #efefef; 187 background: #efefef;
188 - font-size: pxToRem(16px); 188 + font-size: pxToRem(24px);
189 line-height: 1; 189 line-height: 1;
190 outline: 0; 190 outline: 0;
191 border: 0; 191 border: 0;
@@ -61,7 +61,7 @@ @@ -61,7 +61,7 @@
61 position: relative; 61 position: relative;
62 margin-top: pxToRem(30px); 62 margin-top: pxToRem(30px);
63 margin-bottom: pxToRem(30px); 63 margin-bottom: pxToRem(30px);
64 - font-size: pxToRem(14px); 64 + font-size: pxToRem(28px);
65 line-height: 2; 65 line-height: 2;
66 color: #b0b0b0; 66 color: #b0b0b0;
67 text-align: center; 67 text-align: center;
@@ -32,4 +32,10 @@ @@ -32,4 +32,10 @@
32 } 32 }
33 } 33 }
34 } 34 }
  35 +}
  36 +.deal_main{
  37 + margin: .5rem 3%;
  38 + font-size:1.2em;
  39 + widows: 94%;
  40 + overflow: hidden;
35 } 41 }
@@ -46,6 +46,9 @@ @@ -46,6 +46,9 @@
46 {{#if isAdvanceBuy}} 46 {{#if isAdvanceBuy}}
47 <span class="sale-price">¥{{salesPrice}}</span> 47 <span class="sale-price">¥{{salesPrice}}</span>
48 {{/if}} 48 {{/if}}
  49 + {{#if isGift}}
  50 + <span class="sale-price">¥{{salesPrice}}</span>
  51 + {{/if}}
49 </p> 52 </p>
50 {{#if isVipPrice}} 53 {{#if isVipPrice}}
51 <span class="vip"> 54 <span class="vip">
@@ -640,16 +640,13 @@ class HomeController extends AbstractAction @@ -640,16 +640,13 @@ class HomeController extends AbstractAction
640 * 我的订单页面,获得nav导航条焦点。并且异步请求订单详情列表页(getOrders) 640 * 我的订单页面,获得nav导航条焦点。并且异步请求订单详情列表页(getOrders)
641 * 641 *
642 */ 642 */
643 -  
644 public function ordersAction() 643 public function ordersAction()
645 { 644 {
646 // 审判跳转登录页 645 // 审判跳转登录页
647 $this->auditJumpLogin(); 646 $this->auditJumpLogin();
648 647
649 - $backUrl = Helpers::url('/home');  
650 -  
651 $this->setTitle('我的订单'); 648 $this->setTitle('我的订单');
652 - $this->setNavHeader('我的订单', $backUrl); 649 + $this->setNavHeader('我的订单', Helpers::url('/home') );
653 650
654 $order = array(); 651 $order = array();
655 //获得type值,type:1=>全部,2=>待付款,3=>待发货,4=>待收货,5=>待评论 652 //获得type值,type:1=>全部,2=>待付款,3=>待发货,4=>待收货,5=>待评论
@@ -887,7 +884,7 @@ class HomeController extends AbstractAction @@ -887,7 +884,7 @@ class HomeController extends AbstractAction
887 $this->setTitle($caption); 884 $this->setTitle($caption);
888 $this->setNavHeader($caption); 885 $this->setNavHeader($caption);
889 886
890 - $this->_view->display('helpDetail', array( 887 + $this->_view->display('help-detail', array(
891 'iHelp' => Home\HelpModel::serviceDetail($code), 888 'iHelp' => Home\HelpModel::serviceDetail($code),
892 )); 889 ));
893 } 890 }
@@ -71,7 +71,7 @@ class HomeModel @@ -71,7 +71,7 @@ class HomeModel
71 71
72 /** 72 /**
73 * 设置选择的频道保存到浏览器COOKIE 73 * 设置选择的频道保存到浏览器COOKIE
74 - * (已废弃,改成JS设置) 74 + * (已废弃,改成JS设置)
75 * 75 *
76 * @param string $cookie 76 * @param string $cookie
77 * @return void 77 * @return void
@@ -289,7 +289,6 @@ class IndexController extends AbstractAction @@ -289,7 +289,6 @@ class IndexController extends AbstractAction
289 $this->go(Helpers::url('/cart/index/index')); 289 $this->go(Helpers::url('/cart/index/index'));
290 } 290 }
291 291
292 -  
293 $cookieData = $this->getCookie('order-info', null); 292 $cookieData = $this->getCookie('order-info', null);
294 $uid = $this->getUid(true); 293 $uid = $this->getUid(true);
295 $data = array( 294 $data = array(
@@ -457,8 +456,8 @@ class IndexController extends AbstractAction @@ -457,8 +456,8 @@ class IndexController extends AbstractAction
457 $result = CartModel::addToCart($productSku, $buyNumber, $goodsType, $isEdit, $promotionId, $uid, $shoppingKey); 456 $result = CartModel::addToCart($productSku, $buyNumber, $goodsType, $isEdit, $promotionId, $uid, $shoppingKey);
458 457
459 // 设置加入购物车凭证到客户端浏览器 458 // 设置加入购物车凭证到客户端浏览器
460 - if (!$shoppingKey && isset($result['data']['shopping_key'])) {  
461 - $this->setCookie('_Spk', $result['data']['shopping_key']); 459 + if (empty($shoppingKey) && isset($result['data']['shopping_key'])) {
  460 + $this->setCookie('_SPK', $result['data']['shopping_key'], time() + 86400 * 360);
462 } 461 }
463 } 462 }
464 463
@@ -17,6 +17,10 @@ class LoginController extends AbstractAction @@ -17,6 +17,10 @@ class LoginController extends AbstractAction
17 */ 17 */
18 public function indexAction() 18 public function indexAction()
19 { 19 {
  20 + // 清除客户端
  21 + $this->setCookie('_UID', '');
  22 + $this->setCookie('_TOKEN', '');
  23 +
20 $refer = $this->get('refer'); 24 $refer = $this->get('refer');
21 if (!empty($refer)) { 25 if (!empty($refer)) {
22 $this->setCookie('refer', $refer); 26 $this->setCookie('refer', $refer);
@@ -61,7 +65,6 @@ class LoginController extends AbstractAction @@ -61,7 +65,6 @@ class LoginController extends AbstractAction
61 $data['isPassportPage'] = true; // 模板中模块标识 65 $data['isPassportPage'] = true; // 模板中模块标识
62 $data['areaCode'] = '+86'; // 默认区号 66 $data['areaCode'] = '+86'; // 默认区号
63 $data['countrys'] = RegData::getAreasData(); // 地区信息列表 67 $data['countrys'] = RegData::getAreasData(); // 地区信息列表
64 -  
65 // 渲染模板 68 // 渲染模板
66 $this->_view->display('international', $data); 69 $this->_view->display('international', $data);
67 } 70 }
@@ -74,6 +77,7 @@ class LoginController extends AbstractAction @@ -74,6 +77,7 @@ class LoginController extends AbstractAction
74 // 清除客户端 77 // 清除客户端
75 $this->setCookie('_UID', ''); 78 $this->setCookie('_UID', '');
76 $this->setCookie('_TOKEN', ''); 79 $this->setCookie('_TOKEN', '');
  80 + $this->setCookie('_SPK', '');
77 // 清除服务端会话 81 // 清除服务端会话
78 $this->setSession('_TOKEN', ''); 82 $this->setSession('_TOKEN', '');
79 83
@@ -148,7 +152,7 @@ class LoginController extends AbstractAction @@ -148,7 +152,7 @@ class LoginController extends AbstractAction
148 public function alipayAction() 152 public function alipayAction()
149 { 153 {
150 $this->setSession('_TOKEN', ''); 154 $this->setSession('_TOKEN', '');
151 - 155 +
152 Factory::create('alipay')->getAuthorizeUrl(); 156 Factory::create('alipay')->getAuthorizeUrl();
153 157
154 exit(); 158 exit();
@@ -160,7 +164,7 @@ class LoginController extends AbstractAction @@ -160,7 +164,7 @@ class LoginController extends AbstractAction
160 public function qqAction() 164 public function qqAction()
161 { 165 {
162 $this->setSession('_TOKEN', ''); 166 $this->setSession('_TOKEN', '');
163 - 167 +
164 Factory::create('qqconnect')->getAuthorizeUrl(); 168 Factory::create('qqconnect')->getAuthorizeUrl();
165 169
166 exit(); 170 exit();
@@ -172,7 +176,7 @@ class LoginController extends AbstractAction @@ -172,7 +176,7 @@ class LoginController extends AbstractAction
172 public function sinaAction() 176 public function sinaAction()
173 { 177 {
174 $this->setSession('_TOKEN', ''); 178 $this->setSession('_TOKEN', '');
175 - 179 +
176 $this->go(Factory::create('sinaweibo')->getAuthorizeUrl()); 180 $this->go(Factory::create('sinaweibo')->getAuthorizeUrl());
177 } 181 }
178 182