order_detail.js
7.29 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
var e = getApp(), r = e.request,rq=r,t = require("../../../utils/util.js"), o = require("../../../utils/common.js"),oo=e.globalData,os=oo.setting;
Page({
data: {
url: os.url,
resourceUrl: os.imghost,
iurl: os.imghost,
order: null,
optionIsGoup: !1,
user_note: ""
},
onLoad: function(e) {
var r = void 0 !== e.isGoup && e.isGoup;
this.setData({
optionIsGoup: r
}), this.requestOrderDetail(e.order_id), wx.removeStorageSync("order:order_detail:update");
},
onShow: function() {
wx.getStorageSync("order:order_detail:update") && (wx.removeStorageSync("order:order_detail:update"),
this.requestOrderDetail(this.data.order.order_id));
},
requestOrderDetail: function(e) {
var o = this,oid=e;
r.get(o.data.url + "/api/weshop/order/get/"+os.stoid+"/"+e, {
success: function(e) {
var r = e.data.data;
r.addTimeFormat = t.format(r.add_time);
if (r.order_status == 0 && r.pay_status==0 ){
r.order_status_detail="待支付"; r.pay_btn=1;
}
if (r.order_status == 1 && r.pay_status == 1 && r.shipping_status== 0)
r.order_status_detail = "待发货";
if (r.order_status == 1 && r.pay_status == 1 && r.shipping_status == 1){
r.order_status_detail = "待收货";r.receive_btn=1;
if (r.exp_type == 0) r.shipping_btn=1;
}
if (r.order_status == 1 && r.pay_status == 1 && r.shipping_status == 2){
r.order_status_detail = "待收货"; r.receive_btn = 1;
if (r.exp_type == 0) r.shipping_btn = 1;
}
if (r.order_status == 2){
r.order_status_detail = "待评价"; if (r.exp_type == 0) r.shipping_btn = 1;
}
if (r.order_status == 3)
r.order_status_detail = "已取消";
if (r.order_status == 4){
r.order_status_detail = "已完成"; if (r.exp_type == 0) r.shipping_btn = 1;
}
if (r.order_status == 5)
r.order_status_detail = "已作废";
if (r.order_status == 6)
r.order_status_detail = "退款完成";
//------获取订单商品-------
rq.get("/api/weshop/ordergoods/list",{
data: { store_id: os.stoid, order_id: oid},
success: function (eb) {
r.order_goods=eb.data.data.pageData;
//--------获取门店-----------
rq.get("/api/weshop/pickup/get/" + os.stoid + "/" + r.pickup_id, {
success: function (ebb) {
r.pickname = ebb.data.data.pickup_name;
o.setData({
order: r,
});
}
})
}
})
}
});
},
/*-----联系客户------*/
contactService: function() {
e.getConfig(function(t) {
if (t.store_tel == undefined) {
getApp().request.get("/api/weshop/store/get/" + os.stoid, {
isShowLoading: 1,
data: {},
success: function (rs) {
getApp().globalData.config = rs.data.data;
if (rs.data.data.store_tel == null && rs.data.data.store_tel == undefined) {
getApp().showWarning("商家未设置电话");
return false;
}
e.confirmBox("请联系客服:" + rs.data.data.store_tel);
}
})
} else {
e.confirmBox("请联系客服:" + t.store_tel);
}
});
},
//--------取消订单---------
cancelOrder: function(e) {
var t = this,th=t, o = e.currentTarget.dataset.id,order=this.data.order;
var is_skill=0;
var order_goods=order.order_goods;
var is_zsorder=order.is_zsorder;
//--判断是不是秒杀--
order_goods.forEach(function (val,ind) {
if(val.prom_type==1){
is_skill=1; return false;
}
})
wx.showModal({
title: "是否取消订单?",
success: function(e) {
if(!e.confirm) return false;
//如果是秒杀和拼单的商品,取消订单要返回redis,并取消订单
if(is_skill==1 || is_zsorder>=2){
getApp().request.delete("/api/weshop/order/cancelTeamOrder/"+os.stoid+"/"+o,{
data:{},
success: function(t) {
if(t.data.code==0)
th.requestOrderDetail(o), wx.setStorageSync("order:order_list:update", !0);
},
})
}else{
getApp().request.put("/api/weshop/order/updatebyId", {
data: {order_id: o, order_status: 3},
success: function(e) {
th.requestOrderDetail(o), wx.setStorageSync("order:order_list:update", !0);
}
});
}
}
});
},
//--------确认收货---------
confirmOrder: function(e) {
var t = this, o = this.data.order.order_id,order=this.data.order;
var is_zsorder=order.is_zsorder;
wx.showModal({
title: "是否确认收货?",
success: function(e) {
e.confirm && r.put("/api/weshop/order/updatebyId", {
data: {
order_id: o, order_status: 2
},
success: function(e) {
t.requestOrderDetail(o), wx.setStorageSync("order:order_list:update", !0);
//如果是会员团订单
if(is_zsorder==3){
getApp().request.post("/api/weshop/order/vipTuanTebate/"+os.stoid+"/"+o,{
data:{}, success:function () { }})
}
}
});
}
});
},
//--------立即支付----------
jumpToCart4: function(e) {
this.data.optionIsGoup ? wx.navigateTo({
url: "/pages/team/team_confirm/team_confirm?orderSn=" + this.data.order.order_sn + "&orderPay=true"
}) : o.jumpToCart4({
order_sn: this.data.order.order_sn,
order_amount: this.data.order.order_amount
}, 1);
},
checkTeam: function() {
wx.navigateTo({
url: "/pages/team/team_detail/team_detail?foundId=" + this.data.order.orderTeamFound.found_id
});
},
//------图片失败,默认图片---------
bind_bnerr: function (e) {
var _errImg = e.target.dataset.errorimg;
var _errObj = {};
_errObj[_errImg] = "public/images/default_goods_image_240.gif";
this.setData(_errObj) //注意这里的赋值方式,只是将数据列表中的此项图片路径值替换掉 ;
},
zfwk:function(){
var url = "/pages/cart/cart_wk/cart_wk?order_id=" + this.data.order.order_id;
getApp().goto(url);
}
});