Authored by biao

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

@@ -1396,5 +1396,7 @@ @@ -1396,5 +1396,7 @@
1396 'entitle' : 'LIFESTYLE', 1396 'entitle' : 'LIFESTYLE',
1397 } 1397 }
1398 ], 1398 ],
1399 - 'showYohood' : true/false 1399 + 'showYohood' : true/false,
  1400 + 'yohoodHref' : '/yohood'
1400 } 1401 }
  1402 +
@@ -303,14 +303,15 @@ class CartData @@ -303,14 +303,15 @@ class CartData
303 * @param int $paymentId 支付方式ID 303 * @param int $paymentId 支付方式ID
304 * @param int $paymentType 支付类型ID 304 * @param int $paymentType 支付类型ID
305 * @param string $remark 留言 305 * @param string $remark 留言
  306 + * @param string $couponCode 优惠券码
306 * @param mixed $yohoCoin 使用的YOHO币数量或为空 307 * @param mixed $yohoCoin 使用的YOHO币数量或为空
307 * @return array 接口返回的数据 308 * @return array 接口返回的数据
308 */ 309 */
309 - public static function orderSub($uid, $addressId, $cartType, $deliveryTime, $deliveryWay, $invoiceTitle, $invoiceId, $paymentId, $paymentType, $remark, $yohoCoin) 310 + public static function orderSub($uid, $addressId, $cartType, $deliveryTime, $deliveryWay, $invoiceTitle, $invoiceId, $paymentId, $paymentType, $remark, $couponCode, $yohoCoin)
310 { 311 {
311 $param = Yohobuy::param(); 312 $param = Yohobuy::param();
312 $param['method'] = 'app.Shopping.submit'; 313 $param['method'] = 'app.Shopping.submit';
313 - $param['addressId'] = $addressId; 314 + $param['address_id'] = $addressId;
314 $param['cart_type'] = $cartType; 315 $param['cart_type'] = $cartType;
315 $param['delivery_time'] = $deliveryTime; 316 $param['delivery_time'] = $deliveryTime;
316 $param['delivery_way'] = $deliveryWay; 317 $param['delivery_way'] = $deliveryWay;
@@ -324,6 +325,9 @@ class CartData @@ -324,6 +325,9 @@ class CartData
324 $param['payment_id'] = $paymentId; 325 $param['payment_id'] = $paymentId;
325 $param['payment_type'] = $paymentType; 326 $param['payment_type'] = $paymentType;
326 $param['remark'] = $remark; 327 $param['remark'] = $remark;
  328 + if (!empty($couponCode)) {
  329 + $param['coupon_code'] = $couponCode;
  330 + }
327 if (!empty($yohoCoin)) { 331 if (!empty($yohoCoin)) {
328 $param['use_yoho_coin'] = $yohoCoin; 332 $param['use_yoho_coin'] = $yohoCoin;
329 } 333 }
@@ -68,4 +68,16 @@ class IndexData @@ -68,4 +68,16 @@ class IndexData
68 return Yohobuy::get(Yohobuy::SERVICE_URL . 'operations/api/v5/resource/home', $param); 68 return Yohobuy::get(Yohobuy::SERVICE_URL . 'operations/api/v5/resource/home', $param);
69 } 69 }
70 70
  71 + /**
  72 + * 获取频道选择页数据
  73 + *
  74 + * @return array
  75 + */
  76 + public static function channelData()
  77 + {
  78 + $param = Yohobuy::param();
  79 + $param['client_secret'] = Sign::getSign($param);
  80 + return Yohobuy::get(Yohobuy::SERVICE_URL . 'operations/api/v5/entrance/getEntrance',$param,3600);
  81 + }
  82 +
71 } 83 }
@@ -10,9 +10,20 @@ var Swiper = require('yoho.iswiper'), @@ -10,9 +10,20 @@ var Swiper = require('yoho.iswiper'),
10 10
11 var recommendSwiper, 11 var recommendSwiper,
12 $recommendForYou = $('.recommend-for-you'), 12 $recommendForYou = $('.recommend-for-you'),
13 - preferenceUrl = $('#preferenceUrl').val(); 13 + preferenceUrl = $('#preferenceUrl').val(),
  14 + winH = $(window).height(),
  15 + end = false,
  16 + requesting = false;
14 17
15 -if (preferenceUrl) { 18 +
  19 +function request() {
  20 + if (requesting || end) {
  21 + return;
  22 + }
  23 +
  24 + requesting = true;
  25 +
  26 + if (preferenceUrl) {
16 $.get(preferenceUrl).then(function(html) { 27 $.get(preferenceUrl).then(function(html) {
17 if (html.length < 5) { 28 if (html.length < 5) {
18 $recommendForYou.css('display', 'none'); 29 $recommendForYou.css('display', 'none');
@@ -29,9 +40,21 @@ if (preferenceUrl) { @@ -29,9 +40,21 @@ if (preferenceUrl) {
29 } 40 }
30 } 41 }
31 42
32 - window.rePosFooter(); 43 + requesting = false;
  44 + end = true;
33 45
34 }).fail(function() { 46 }).fail(function() {
35 $recommendForYou.hide(); 47 $recommendForYou.hide();
36 }); 48 });
  49 + }
37 } 50 }
  51 +
  52 +function scrollHandler() {
  53 + if (!end || $(window).scrollTop() + winH >= $(document).height() - 50) {
  54 + request();
  55 + }
  56 +}
  57 +
  58 +$(window).scroll(function() {
  59 + window.requestAnimationFrame(scrollHandler);
  60 +});
@@ -15,6 +15,7 @@ var dispatchModeHammer, @@ -15,6 +15,7 @@ var dispatchModeHammer,
15 dispatchTimeHammer, 15 dispatchTimeHammer,
16 $invoice = $('.invoice'), 16 $invoice = $('.invoice'),
17 $price = $('.price-cal'), 17 $price = $('.price-cal'),
  18 + payType,
18 priceTmpl = Handlebars.compile($('#tmpl-price').html()); 19 priceTmpl = Handlebars.compile($('#tmpl-price').html());
19 20
20 lazyLoad(); 21 lazyLoad();
@@ -99,23 +100,33 @@ function submitOrder() { @@ -99,23 +100,33 @@ function submitOrder() {
99 addressId: orderInfo('addressId'), 100 addressId: orderInfo('addressId'),
100 cartType: orderInfo('cartType'), 101 cartType: orderInfo('cartType'),
101 deliveryId: orderInfo('deliveryId') || 1, 102 deliveryId: orderInfo('deliveryId') || 1,
102 - deliveryTimeId: orderInfo('deliveryTimeId') || 1,  
103 - invoiceText: orderInfo('invoiceText'),  
104 - invoiceType: orderInfo('invoiceType'),  
105 - msg: orderInfo('msg'), 103 + deliveryTimeId: orderInfo('deliveryTimeId') || 2,
  104 + invoiceText: $invoice.find('[name="invoice-title"]').val() || orderInfo('invoiceText'),
  105 + invoiceType: $invoice.find('.invoice-type').val() || orderInfo('invoiceType'),
  106 + msg: $('#msg').find('input').val() || orderInfo('msg'),
106 paymentTypeId: orderInfo('paymentTypeId'), 107 paymentTypeId: orderInfo('paymentTypeId'),
107 paymentType: orderInfo('paymentType'), //支付方式 108 paymentType: orderInfo('paymentType'), //支付方式
108 couponCode: orderInfo('couponCode'), 109 couponCode: orderInfo('couponCode'),
109 yohoCoin: orderInfo('yohoCoin') 110 yohoCoin: orderInfo('yohoCoin')
110 } 111 }
111 }).then(function(res) { 112 }).then(function(res) {
  113 + var url;
  114 +
112 if (!res) { 115 if (!res) {
113 tip.show('网络出错'); 116 tip.show('网络出错');
  117 + return;
114 } 118 }
115 - if (res.code !== 200) {  
116 - tip.show(res.message || '网络出错'); 119 + if (res.code === 200) {
  120 + if (payType === 2) {
  121 +
  122 + // 货到付款的进入订单页面
  123 + url = '/home/orderDetail?order_code=' + res.data.order_code;
117 } else { 124 } else {
118 - console.log(1); 125 + url = '/home/pay?order_code=' + res.data.order_code;
  126 + }
  127 + window.location.href = url;
  128 + } else {
  129 + tip.show(res.messege || '网络出错');
119 } 130 }
120 }).fail(function() { 131 }).fail(function() {
121 tip.show('网络出错'); 132 tip.show('网络出错');
@@ -124,7 +135,7 @@ function submitOrder() { @@ -124,7 +135,7 @@ function submitOrder() {
124 135
125 // 界面点击,状态存 cookie 136 // 界面点击,状态存 cookie
126 if (!orderInfo('addressId')) { 137 if (!orderInfo('addressId')) {
127 - orderInfo('addressId', $('.address-wrap').data('address-id')); 138 + orderInfo('addressId', $('.address-wrap').data('id'));
128 } 139 }
129 140
130 $('.dispatch-mode').on('touchend', 'li', function() { 141 $('.dispatch-mode').on('touchend', 'li', function() {
@@ -166,7 +177,10 @@ $('#msg').find('input').on('blur', function() { @@ -166,7 +177,10 @@ $('#msg').find('input').on('blur', function() {
166 }); 177 });
167 178
168 $('.pay-mode').on('click', 'li', function() { 179 $('.pay-mode').on('click', 'li', function() {
169 - orderInfo('paymentTypeId', $(this).data('pay-id'));  
170 - orderInfo('paymentType', $(this).data('pay-type')); 180 + var $this = $(this);
  181 +
  182 + orderInfo('paymentTypeId', $this.data('pay-id'));
  183 + orderInfo('paymentType', $this.data('pay-type'));
  184 + payType = $this.data('pay-type');
171 submitOrder(); 185 submitOrder();
172 }); 186 });
@@ -2,6 +2,16 @@ @@ -2,6 +2,16 @@
2 width: 100%; 2 width: 100%;
3 overflow: hidden; 3 overflow: hidden;
4 margin: 0 auto; 4 margin: 0 auto;
  5 + #yohood {
  6 + background-color: transparent;
  7 + background-image: image-url('yohood.png');
  8 + background-size: 40%;
  9 + background-repeat: no-repeat;
  10 + background-position-x: 26%;
  11 + background-position-y: 36%;
  12 + border: none;
  13 + border-bottom: 4px solid #fff;
  14 + }
5 .index-header { 15 .index-header {
6 box-sizing: border-box; 16 box-sizing: border-box;
7 padding: 0 20rem / $pxConvertRem; 17 padding: 0 20rem / $pxConvertRem;
@@ -23,7 +23,7 @@ @@ -23,7 +23,7 @@
23 <a href="{{href}}" class="list-item">{{title}} <span class="lighter">{{entitle}}</span> <span class="iconfont right-icon">&#xe614;</span></a> 23 <a href="{{href}}" class="list-item">{{title}} <span class="lighter">{{entitle}}</span> <span class="iconfont right-icon">&#xe614;</span></a>
24 {{/channelList}} 24 {{/channelList}}
25 {{#showYohood}} 25 {{#showYohood}}
26 - <a href="/yohood" id="yohood" class="list-item"> <span class="iconfont right-icon">&#xe614;</span></a> 26 + <a href="{{yohoodHref}}" id="yohood" class="list-item"> <span class="iconfont right-icon">&#xe614;</span></a>
27 {{/showYohood}} 27 {{/showYohood}}
28 </div> 28 </div>
29 </div> 29 </div>
1 {{> layout/header}} 1 {{> layout/header}}
2 <div class="order-ensure-page yoho-page"> 2 <div class="order-ensure-page yoho-page">
3 {{# orderEnsure}} 3 {{# orderEnsure}}
4 - <a class="address-wrap block" href="/shoppingCart/selectAddress" data-address-id="{{addressId}}"> 4 + <a class="address-wrap block" data-id="{{addressId}}" href="/shoppingCart/selectAddress">
5 <p class="infos"> 5 <p class="infos">
6 收货地址 6 收货地址
7 <span class="per-info">{{name}} {{phoneNum}}</span> 7 <span class="per-info">{{name}} {{phoneNum}}</span>
@@ -67,16 +67,14 @@ @@ -67,16 +67,14 @@
67 </li> 67 </li>
68 {{/if}} 68 {{/if}}
69 69
70 - {{# yohoCoin}}  
71 - <li class="coin" data-yoho-coin="{{.}}"> 70 + <li class="coin" data-yoho-coin="{{yohoCoin}}">
72 <span class="title">YOHO币</span> 71 <span class="title">YOHO币</span>
73 - <span class="desc">可抵用¥{{.}}</span> 72 + <span class="desc">可抵用¥{{yohoCoin}}</span>
74 <span class="coin-check"> 73 <span class="coin-check">
75 - <em>- ¥ {{.}}</em> 74 + <em>- ¥ {{yohoCoin}}</em>
76 <i class="iconfont checkbox icon-cb-checked"></i> 75 <i class="iconfont checkbox icon-cb-checked"></i>
77 </span> 76 </span>
78 </li> 77 </li>
79 - {{/ yohoCoin}}  
80 78
81 {{#if invoice}} 79 {{#if invoice}}
82 <li class="invoice {{#if needInvoice}}focus{{/if}}"> 80 <li class="invoice {{#if needInvoice}}focus{{/if}}">
@@ -23,16 +23,16 @@ class IndexController extends AbstractAction @@ -23,16 +23,16 @@ class IndexController extends AbstractAction
23 // 设置浏览器缓存5分钟 23 // 设置浏览器缓存5分钟
24 $this->setExpires(300); 24 $this->setExpires(300);
25 } 25 }
26 - 26 + $result = Index\HomeModel::getChannel();
  27 + $result['background'] = Index\HomeModel::getBgImage();
  28 + $result['channelPage'] = true;
  29 + $result['showDownloadApp'] = true;
  30 + $result['searchUrl'] = Helpers::url('', null, 'search');
  31 + $result['pageFooter'] = true;
27 // 渲染模板 32 // 渲染模板
28 - $this->_view->display('index', array(  
29 - 'background' => Index\HomeModel::getBgImage(),  
30 - 'channelPage' => true,  
31 - 'showDownloadApp'=>true,  
32 - 'searchUrl' => Helpers::url('', null, 'search'),  
33 - 'pageFooter' => true,  
34 - )); 33 + $this->_view->display('index', $result);
35 } 34 }
  35 +
36 /** 36 /**
37 * 设置升级公告路由 37 * 设置升级公告路由
38 * 38 *
@@ -314,8 +314,9 @@ class ShoppingCartController extends AbstractAction @@ -314,8 +314,9 @@ class ShoppingCartController extends AbstractAction
314 $paymentId = $this->post('paymentTypeId', 15); 314 $paymentId = $this->post('paymentTypeId', 15);
315 $paymentType = $this->post('paymentType', 1); // 默认在线支付 315 $paymentType = $this->post('paymentType', 1); // 默认在线支付
316 $remark = $this->post('msg', null); 316 $remark = $this->post('msg', null);
  317 + $couponCode = $this->post('couponCode', null);
317 $yohoCoin = $this->post('yohoCoin', 1); 318 $yohoCoin = $this->post('yohoCoin', 1);
318 - $result = CartModel::orderSub($uid, $addressId, $cartType, $deliveryTime, $deliveryWay, $invoiceTitle, $invoiceId, $paymentId, $paymentType, $remark, $yohoCoin); 319 + $result = CartModel::orderSub($uid, $addressId, $cartType, $deliveryTime, $deliveryWay, $invoiceTitle, $invoiceId, $paymentId, $paymentType, $remark, $couponCode, $yohoCoin);
319 } 320 }
320 321
321 if (empty($result)) { 322 if (empty($result)) {
@@ -567,17 +567,29 @@ class CartModel @@ -567,17 +567,29 @@ class CartModel
567 * @param int $paymentId 支付方式ID 567 * @param int $paymentId 支付方式ID
568 * @param int $paymentType 支付类型ID 568 * @param int $paymentType 支付类型ID
569 * @param string $remark 留言 569 * @param string $remark 留言
  570 + * @param string $couponCode 优惠券码
570 * @param mixed $yohoCoin 使用的YOHO币数量或为空 571 * @param mixed $yohoCoin 使用的YOHO币数量或为空
571 * @return array 接口返回的数据 572 * @return array 接口返回的数据
572 */ 573 */
573 - public static function orderSub($uid, $addressId, $cartType, $deliveryTime, $deliveryWay, $invoiceTitle, $invoiceId, $paymentId, $paymentType, $remark, $yohoCoin) 574 + public static function orderSub($uid, $addressId, $cartType, $deliveryTime, $deliveryWay, $invoiceTitle, $invoiceId, $paymentId, $paymentType, $remark, $couponCode, $yohoCoin)
574 { 575 {
575 - $result = array();  
576 -  
577 - $orderSubRes = CartData::orderSub($uid, $addressId, $cartType, $deliveryTime, $deliveryWay, $invoiceTitle, $invoiceId, $paymentId, $paymentType, $remark, $yohoCoin); 576 + $result = array('code' => 400, 'message' => '出错啦');
  577 +
  578 + if (empty($addressId)) {
  579 + $result['code'] = 401;
  580 + $result['message'] = '配送地址不能为空';
  581 + } elseif (empty($deliveryTime)) {
  582 + $result['code'] = 402;
  583 + $result['message'] = '请选择配送时间';
  584 + } elseif (empty($deliveryWay)) {
  585 + $result['code'] = 403;
  586 + $result['message'] = '请选择配送方式';
  587 + } else {
  588 + $orderSubRes = CartData::orderSub($uid, $addressId, $cartType, $deliveryTime, $deliveryWay, $invoiceTitle, $invoiceId, $paymentId, $paymentType, $remark, $couponCode, $yohoCoin);
578 if ($orderSubRes && isset($orderSubRes['code'])) { 589 if ($orderSubRes && isset($orderSubRes['code'])) {
579 $result = $orderSubRes; 590 $result = $orderSubRes;
580 } 591 }
  592 + }
581 593
582 return $result; 594 return $result;
583 } 595 }
@@ -319,4 +319,53 @@ class HomeModel @@ -319,4 +319,53 @@ class HomeModel
319 return $result; 319 return $result;
320 } 320 }
321 321
  322 + /**
  323 + * 获取频道选择页数据
  324 + *
  325 + * @return array
  326 + */
  327 + public static function getChannel(){
  328 + $result = array();
  329 + $result['showYohood'] = false;
  330 +
  331 + $data = IndexData::channelData();
  332 +
  333 + $channelList = array();
  334 + if(isset($data['data']['list'])){
  335 + foreach($data['data']['list'] as $key => $value){
  336 + switch ($value['channel_id']) {
  337 + case 5:
  338 + $result['showYohood'] = true;
  339 + $result['yohoodHref'] = '/yohood';
  340 + break;
  341 + case 1:
  342 + $channelList[$key]['href'] = '/boys';
  343 + $channelList[$key]['title'] = '男生';
  344 + $channelList[$key]['entitle'] = 'BOYS';
  345 + break;
  346 + case 2:
  347 + $channelList[$key]['href'] = '/girls';
  348 + $channelList[$key]['title'] = '女生';
  349 + $channelList[$key]['entitle'] = 'GIRLS';
  350 + break;
  351 + case 3:
  352 + $channelList[$key]['href'] = '/kids';
  353 + $channelList[$key]['title'] = '潮童';
  354 + $channelList[$key]['entitle'] = 'KIDS';
  355 + break;
  356 + case 4:
  357 + $channelList[$key]['href'] = '/lifestyle';
  358 + $channelList[$key]['title'] = '创意生活';
  359 + $channelList[$key]['entitle'] = 'LIFESTYLE';
  360 + break;
  361 + default:
  362 + break;
  363 + }
  364 + }
  365 + $result['channelList'] = $channelList;
  366 + }
  367 +
  368 + return $result;
  369 + }
  370 +
322 } 371 }
@@ -138,7 +138,7 @@ class BindController extends AbstractAction @@ -138,7 +138,7 @@ class BindController extends AbstractAction
138 } 138 }
139 else 139 else
140 { 140 {
141 - $data = array('code' => $res['code'], 'message' => $res['message'], 'data' => $res['data']); 141 + $data = array('code' => $res['code'], 'message' => $res['message'], 'data' => isset($res['data'])?$res['data']:'');
142 } 142 }
143 } 143 }
144 while (false); 144 while (false);