Authored by cailing

Merge branch 'feature/rebuy' into release/4.8

... ... @@ -214,4 +214,20 @@ class OrderData
return Yohobuy::get(Yohobuy::API_URL, $param);
}
/** 再次购买
* @param type $uid
* @param type $orderCode
* @return type
*/
public static function reAddData($uid, $orderCode)
{
$param = Yohobuy::param();
$param['method'] = 'app.Shopping.readd';
$param['uid'] = $uid;
$param['order_code'] = $orderCode;
$param['client_secret'] = Sign::getSign($param);
return Yohobuy::get(Yohobuy::API_URL, $param);
}
}
... ...
... ... @@ -40,12 +40,3 @@ location ^~ /passport/autosign/wechat/ {
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Accept-Encoding "gzip";
}
location ^~ /product/sale/ {
proxy_redirect off;
proxy_pass http://yohobuy-node;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Accept-Encoding "gzip";
}
... ...
location ^~ /passport/autosign/wechat/ {
proxy_redirect off;
proxy_pass http://yohobuy-node;
proxy_set_header Host $host;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Accept-Encoding "gzip";
}
location ^~ /passport/login/wechat/ {
proxy_redirect off;
proxy_pass http://yohobuy-node;
proxy_set_header Host $host;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Accept-Encoding "gzip";
}
location = /product/index/getNodeContent {
proxy_redirect off;
proxy_pass http://yohobuy-node;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Accept-Encoding "gzip";
}
location ^~ /product/sale/ {
proxy_redirect off;
proxy_pass http://yohobuy-node;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Accept-Encoding "gzip";
}
location ^~ /product/outlets/ {
proxy_redirect off;
proxy_pass http://yohobuy-node;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Accept-Encoding "gzip";
}
... ...
... ... @@ -112,16 +112,20 @@
{{#if cancelOrder}}
<span class="op-item cancel-order">取消订单</span>
{{^}}
{{#if confirmReceived}}
<span class="op-item confirm-received">确认收货</span>
{{#if reBuy}}
<span class="rebuy">再次购买</span>
{{^}}
<a class="op-item{{#if payNow}} pay-now{{/if}}" href="{{href}}" target="_blank">
{{#if payNow}}
立即付款
{{^}}
{{name}}
{{/if}}
</a>
{{#if confirmReceived}}
<span class="op-item confirm-received">确认收货</span>
{{^}}
<a class="op-item{{#if payNow}} pay-now{{/if}}" href="{{href}}" target="_blank">
{{#if payNow}}
立即付款
{{^}}
{{name}}
{{/if}}
</a>
{{/if}}
{{/if}}
{{/if}}
{{/if}}
... ...
... ... @@ -130,7 +130,17 @@ $cartnewSum.one('click', 'input[type="checkbox"]', function() {
};
choiceOut(dataJSON);
});
// 滚动到第一个选中的商品
function scrollToFirst(){
var $selected = $('.pay-wapper tbody tr').find('.cart-item-check:checked');
var top = 0;
if($selected.length > 0){
$selected = $selected.eq(0);
}
top = $selected.offset().top - 50;
$('html,body').scrollTop(top);
return false;
}
function isCheck(obj, className) {
selectArray = [];
dataJSON = {};
... ... @@ -880,4 +890,5 @@ $payWapper.on('selectstart', function() {
});
$goodsDetail.on('selectstart', function() {
return false;
});
\ No newline at end of file
});
scrollToFirst();
\ No newline at end of file
... ...
... ... @@ -180,8 +180,24 @@ $('.me-orders, .order-detail').on('click', '.cancel-order', function(e) {
active = editOrder($(this).closest('.order, .order-detail').data('id'))
active.show();
newAddress(0);
}).on('click', '.rebuy', function() {
var id = $(this).closest('.order, .order-detail').data('id');
buyAgain(id);
});
//再次购买
function buyAgain(id){
$.ajax({
type: 'post',
url: '/home/orders/reAdd',
data: {orderCode: id}
}).then(function(d) {
if (d.code === 200) {
location.href = '/shopping/cart';
} else {
new dialog.Alert(d.message).show();
}
})
}
// 地址操作
function newAddress(id) {
var code, codeId;
... ... @@ -403,7 +419,7 @@ function saveAddress(id) {
$.ajax({
type: 'post',
url: '/home/orders/modifyAddress',
url: '/home/orders/modifyAddress',
data: postData
}).then(function(d) {
if (d.code === 200) {
... ...
... ... @@ -257,6 +257,16 @@
border-radius: 4px;
width: 68px;
}
.operation .rebuy{
display: inline-block;
box-sizing: border-box;
width: 68px;
height: 18px;
line-height: 18px;
border-radius: 5px;
text-align: center;
border: 1px solid #000;
}
}
}
... ...
... ... @@ -610,6 +610,10 @@ class OrderModel
if ($status >= 6 && $time < 86400 * $orderRefundLimitTime && $attribute != 3 && $isCancel == 'N') {
$operation[] = array('href' => $refundUrl, 'name' => '申请退货', 'optDis' => $opRefundStatus);
}
//再次购买
if ( $isCancel == 'Y') {
$operation[] = array( 'name' => '再次购买', 'reBuy' => true);
}
return $operation;
}
... ...
... ... @@ -274,5 +274,39 @@ class OrdersController extends WebAction
$this->echoJson($result);
}
/**
* 我的订单——再次购买
*/
public function reAddAction()
{
$result = array('code' => 401, 'message' => '商品加入购物车失败', 'data' => '');
do {
/* 判断是不是AJAX请求 */
if (!$this->isAjax()) {
break;
}
//获取相关参数
$uid = $this->getUid(true);
$orderCode = $this->post('orderCode', '');
if (!$uid || !$orderCode) {
$result = array('code' => 400, 'message' => '缺失参数', 'data' => '');
break;
}
$reAddData = OrderData::reAddData($uid, $orderCode);
if(!isset($reAddData['code']) || $reAddData['code'] != 200){
break;
}
$result = array('code' => 200, 'message' => '商品已重新加入购物车', 'data' => $reAddData['data']);
if (!isset($result['code'])) {
break;
}
}
while (false);
$this->echoJson($result);
}
}
... ...