Authored by cailing

Merge branch 'feature/rebuy' into release/4.8

@@ -214,4 +214,20 @@ class OrderData @@ -214,4 +214,20 @@ class OrderData
214 214
215 return Yohobuy::get(Yohobuy::API_URL, $param); 215 return Yohobuy::get(Yohobuy::API_URL, $param);
216 } 216 }
  217 +
  218 + /** 再次购买
  219 + * @param type $uid
  220 + * @param type $orderCode
  221 + * @return type
  222 + */
  223 + public static function reAddData($uid, $orderCode)
  224 + {
  225 + $param = Yohobuy::param();
  226 + $param['method'] = 'app.Shopping.readd';
  227 + $param['uid'] = $uid;
  228 + $param['order_code'] = $orderCode;
  229 + $param['client_secret'] = Sign::getSign($param);
  230 +
  231 + return Yohobuy::get(Yohobuy::API_URL, $param);
  232 + }
217 } 233 }
@@ -40,12 +40,3 @@ location ^~ /passport/autosign/wechat/ { @@ -40,12 +40,3 @@ location ^~ /passport/autosign/wechat/ {
40 proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; 40 proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
41 proxy_set_header Accept-Encoding "gzip"; 41 proxy_set_header Accept-Encoding "gzip";
42 } 42 }
43 -  
44 - location ^~ /product/sale/ {  
45 - proxy_redirect off;  
46 - proxy_pass http://yohobuy-node;  
47 - proxy_set_header Host $host;  
48 - proxy_set_header X-Real-IP $remote_addr;  
49 - proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;  
50 - proxy_set_header Accept-Encoding "gzip";  
51 - }  
  1 +location ^~ /passport/autosign/wechat/ {
  2 + proxy_redirect off;
  3 + proxy_pass http://yohobuy-node;
  4 + proxy_set_header Host $host;
  5 + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
  6 + proxy_set_header Accept-Encoding "gzip";
  7 + }
  8 +
  9 + location ^~ /passport/login/wechat/ {
  10 + proxy_redirect off;
  11 + proxy_pass http://yohobuy-node;
  12 + proxy_set_header Host $host;
  13 + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
  14 + proxy_set_header Accept-Encoding "gzip";
  15 + }
  16 +
  17 + location = /product/index/getNodeContent {
  18 + proxy_redirect off;
  19 + proxy_pass http://yohobuy-node;
  20 + proxy_set_header Host $host;
  21 + proxy_set_header X-Real-IP $remote_addr;
  22 + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
  23 + proxy_set_header Accept-Encoding "gzip";
  24 + }
  25 +
  26 + location ^~ /product/sale/ {
  27 + proxy_redirect off;
  28 + proxy_pass http://yohobuy-node;
  29 + proxy_set_header Host $host;
  30 + proxy_set_header X-Real-IP $remote_addr;
  31 + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
  32 + proxy_set_header Accept-Encoding "gzip";
  33 + }
  34 +
  35 + location ^~ /product/outlets/ {
  36 + proxy_redirect off;
  37 + proxy_pass http://yohobuy-node;
  38 + proxy_set_header Host $host;
  39 + proxy_set_header X-Real-IP $remote_addr;
  40 + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
  41 + proxy_set_header Accept-Encoding "gzip";
  42 + }
  43 +
@@ -112,16 +112,20 @@ @@ -112,16 +112,20 @@
112 {{#if cancelOrder}} 112 {{#if cancelOrder}}
113 <span class="op-item cancel-order">取消订单</span> 113 <span class="op-item cancel-order">取消订单</span>
114 {{^}} 114 {{^}}
115 - {{#if confirmReceived}}  
116 - <span class="op-item confirm-received">确认收货</span> 115 + {{#if reBuy}}
  116 + <span class="rebuy">再次购买</span>
117 {{^}} 117 {{^}}
118 - <a class="op-item{{#if payNow}} pay-now{{/if}}" href="{{href}}" target="_blank">  
119 - {{#if payNow}}  
120 - 立即付款  
121 - {{^}}  
122 - {{name}}  
123 - {{/if}}  
124 - </a> 118 + {{#if confirmReceived}}
  119 + <span class="op-item confirm-received">确认收货</span>
  120 + {{^}}
  121 + <a class="op-item{{#if payNow}} pay-now{{/if}}" href="{{href}}" target="_blank">
  122 + {{#if payNow}}
  123 + 立即付款
  124 + {{^}}
  125 + {{name}}
  126 + {{/if}}
  127 + </a>
  128 + {{/if}}
125 {{/if}} 129 {{/if}}
126 {{/if}} 130 {{/if}}
127 {{/if}} 131 {{/if}}
@@ -130,7 +130,17 @@ $cartnewSum.one('click', 'input[type="checkbox"]', function() { @@ -130,7 +130,17 @@ $cartnewSum.one('click', 'input[type="checkbox"]', function() {
130 }; 130 };
131 choiceOut(dataJSON); 131 choiceOut(dataJSON);
132 }); 132 });
133 - 133 +// 滚动到第一个选中的商品
  134 +function scrollToFirst(){
  135 + var $selected = $('.pay-wapper tbody tr').find('.cart-item-check:checked');
  136 + var top = 0;
  137 + if($selected.length > 0){
  138 + $selected = $selected.eq(0);
  139 + }
  140 + top = $selected.offset().top - 50;
  141 + $('html,body').scrollTop(top);
  142 + return false;
  143 +}
134 function isCheck(obj, className) { 144 function isCheck(obj, className) {
135 selectArray = []; 145 selectArray = [];
136 dataJSON = {}; 146 dataJSON = {};
@@ -880,4 +890,5 @@ $payWapper.on('selectstart', function() { @@ -880,4 +890,5 @@ $payWapper.on('selectstart', function() {
880 }); 890 });
881 $goodsDetail.on('selectstart', function() { 891 $goodsDetail.on('selectstart', function() {
882 return false; 892 return false;
883 -});  
  893 +});
  894 +scrollToFirst();
@@ -180,8 +180,24 @@ $('.me-orders, .order-detail').on('click', '.cancel-order', function(e) { @@ -180,8 +180,24 @@ $('.me-orders, .order-detail').on('click', '.cancel-order', function(e) {
180 active = editOrder($(this).closest('.order, .order-detail').data('id')) 180 active = editOrder($(this).closest('.order, .order-detail').data('id'))
181 active.show(); 181 active.show();
182 newAddress(0); 182 newAddress(0);
  183 +}).on('click', '.rebuy', function() {
  184 + var id = $(this).closest('.order, .order-detail').data('id');
  185 + buyAgain(id);
183 }); 186 });
184 - 187 +//再次购买
  188 +function buyAgain(id){
  189 + $.ajax({
  190 + type: 'post',
  191 + url: '/home/orders/reAdd',
  192 + data: {orderCode: id}
  193 + }).then(function(d) {
  194 + if (d.code === 200) {
  195 + location.href = '/shopping/cart';
  196 + } else {
  197 + new dialog.Alert(d.message).show();
  198 + }
  199 + })
  200 +}
185 // 地址操作 201 // 地址操作
186 function newAddress(id) { 202 function newAddress(id) {
187 var code, codeId; 203 var code, codeId;
@@ -403,7 +419,7 @@ function saveAddress(id) { @@ -403,7 +419,7 @@ function saveAddress(id) {
403 419
404 $.ajax({ 420 $.ajax({
405 type: 'post', 421 type: 'post',
406 - url: '/home/orders/modifyAddress', 422 + url: '/home/orders/modifyAddress',
407 data: postData 423 data: postData
408 }).then(function(d) { 424 }).then(function(d) {
409 if (d.code === 200) { 425 if (d.code === 200) {
@@ -257,6 +257,16 @@ @@ -257,6 +257,16 @@
257 border-radius: 4px; 257 border-radius: 4px;
258 width: 68px; 258 width: 68px;
259 } 259 }
  260 + .operation .rebuy{
  261 + display: inline-block;
  262 + box-sizing: border-box;
  263 + width: 68px;
  264 + height: 18px;
  265 + line-height: 18px;
  266 + border-radius: 5px;
  267 + text-align: center;
  268 + border: 1px solid #000;
  269 + }
260 } 270 }
261 } 271 }
262 272
@@ -610,6 +610,10 @@ class OrderModel @@ -610,6 +610,10 @@ class OrderModel
610 if ($status >= 6 && $time < 86400 * $orderRefundLimitTime && $attribute != 3 && $isCancel == 'N') { 610 if ($status >= 6 && $time < 86400 * $orderRefundLimitTime && $attribute != 3 && $isCancel == 'N') {
611 $operation[] = array('href' => $refundUrl, 'name' => '申请退货', 'optDis' => $opRefundStatus); 611 $operation[] = array('href' => $refundUrl, 'name' => '申请退货', 'optDis' => $opRefundStatus);
612 } 612 }
  613 + //再次购买
  614 + if ( $isCancel == 'Y') {
  615 + $operation[] = array( 'name' => '再次购买', 'reBuy' => true);
  616 + }
613 return $operation; 617 return $operation;
614 } 618 }
615 619
@@ -274,5 +274,39 @@ class OrdersController extends WebAction @@ -274,5 +274,39 @@ class OrdersController extends WebAction
274 274
275 $this->echoJson($result); 275 $this->echoJson($result);
276 } 276 }
  277 +
  278 + /**
  279 + * 我的订单——再次购买
  280 + */
  281 + public function reAddAction()
  282 + {
  283 + $result = array('code' => 401, 'message' => '商品加入购物车失败', 'data' => '');
  284 +
  285 + do {
  286 + /* 判断是不是AJAX请求 */
  287 + if (!$this->isAjax()) {
  288 + break;
  289 + }
  290 + //获取相关参数
  291 + $uid = $this->getUid(true);
  292 + $orderCode = $this->post('orderCode', '');
  293 + if (!$uid || !$orderCode) {
  294 + $result = array('code' => 400, 'message' => '缺失参数', 'data' => '');
  295 + break;
  296 + }
  297 + $reAddData = OrderData::reAddData($uid, $orderCode);
  298 + if(!isset($reAddData['code']) || $reAddData['code'] != 200){
  299 + break;
  300 + }
  301 + $result = array('code' => 200, 'message' => '商品已重新加入购物车', 'data' => $reAddData['data']);
  302 +
  303 + if (!isset($result['code'])) {
  304 + break;
  305 + }
  306 + }
  307 + while (false);
  308 +
  309 + $this->echoJson($result);
  310 + }
277 311
278 } 312 }