diff --git a/pages/user/order_detail/order_detail.js b/pages/user/order_detail/order_detail.js index ae16b54..9fa5676 100644 --- a/pages/user/order_detail/order_detail.js +++ b/pages/user/order_detail/order_detail.js @@ -8,10 +8,17 @@ Page({ iurl: os.imghost, order: null, optionIsGoup: !1, - user_note: "" + user_note: "", + conf:null, }, onLoad: function(e) { + var th=this; var r = void 0 !== e.isGoup && e.isGoup; + + getApp().getConfig2(function (e) { + th.setData({conf:e}); + }) + this.setData({ optionIsGoup: r }), this.requestOrderDetail(e.order_id), wx.removeStorageSync("order:order_detail:update"); @@ -21,7 +28,7 @@ Page({ this.requestOrderDetail(this.data.order.order_id)); }, requestOrderDetail: function(e) { - var o = this,oid=e; + var o = this,oid=e,th=this; r.get(o.data.url + "/api/weshop/order/get/"+os.stoid+"/"+e, { success: function(e) { var r = e.data.data; @@ -75,9 +82,14 @@ Page({ //----没有相关的退款记录---- if (ttd.data.data.total==0){ r['is_all_return'] = 0; + goodslist.forEach(function (ee, ii) { - if (r['order_status'] == 1 && r['pay_status'] == 1 && gtype_num>1) - goodslist[ii]['return_btn']=1; + if (r['order_status'] == 1 && r['pay_status'] == 1 && gtype_num>1){ + //是不是可以单个商品退款 + if(th.check_for_return_btn(r) ) { + goodslist[ii]['return_btn']=1; + } + } }); }else{ //--------整单退-------- @@ -348,6 +360,34 @@ Page({ }); }, + //--判断是不是可以单个商品退-- + check_for_return_btn:function (item) { + if(item.coupon_no) return false; //有用优惠券 + if(item.order_prom_id) return false; //有订单优惠 + if(item.order_status>=2) return false; //订单状态>2 + var istrue=true; + //----判断是不是有优惠活动和赠送商品---- + for (var g in item.order_goods) { + var g_item=item.order_goods[g]; + if ((g_item.prom_type == 3 && g_item.discount_amount> 0) + || (g_item.prom_type== 3 && g_item.goods_price <= 0) + ) { + istrue=false; break + } + if (g_item.prom_type== 5) { + istrue=false; break + } + } + if(!istrue) return false; + var conf=this.data.conf; + //判断是不是原路退回 + if(conf.refund_type==1) return true; + else{ + if(item.order_amount==0 || item.user_money==0) return true; + } + return false; + } + }); \ No newline at end of file diff --git a/pages/user/order_list/order_list.js b/pages/user/order_list/order_list.js index ba7fc9e..98c1682 100644 --- a/pages/user/order_list/order_list.js +++ b/pages/user/order_list/order_list.js @@ -36,7 +36,7 @@ Page({ if(t.type!=undefined) this.setData({activeCategoryId:t.type}) s.init(this, "", "orderList"); //this.requestOrderList(e), wx.removeStorageSync("order:order_list:update"); - getApp().getCeonfig2(function (e) { + getApp().getConfig2(function (e) { th.setData({conf:e}); }) }, @@ -100,7 +100,7 @@ Page({ //&& ($tpshop_config['refund_type'] eq 0 || ($tpshop_config['refund_type'] eq 1 && ($list['order_amount'] eq 0 // || $list['user_money'] eq 0))) item.goodslist=goodslist; - if(check_for_return_btn(item) ) { + if(th.check_for_return_btn(item) ) { goodslist[ii]['return_btn'] = 1; } } @@ -385,6 +385,7 @@ Page({ }, + //--判断是不是可以单个商品退-- check_for_return_btn:function (item) { if(item.coupon_no) return false; //有用优惠券 if(item.order_prom_id) return false; //有订单优惠