o_detail.js
2.18 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
import App from '../../utils/api.js'
import util from '../../utils/util.js'
Page({
onLoad(opt){
console.log(opt,'uuuu')
this.setData({
totalprice:opt.totalprice ? opt.totalprice : null
})
this.opt=opt;
this.getorderinfo();
},
getorderinfo(){
App.Orders.GetOrderById({orderid:this.opt.id}).then((json)=>{
console.log(json,'orderinfo')
if(json.ret==200){
if(json.data.order && json.data.order.sd_time){
let arr=json.data.order.sd_time.split('-');
console.log(arr[1])
console.log(util.unixtoTime(arr[1],'YYYY-MM-DD HH:II DAY'));
let sdate=util.unixtoTime(arr[0],'YYYY-MM-DD HH:II DAY');
let edate=util.unixtoTime(arr[1],'YYYY-MM-DD HH:II DAY')
json.data.order.showsendtime=(sdate.split(' ')[2] ? sdate.split(' ')[2] : sdate.split(' ')[1])+' '+sdate.split(' ')[1]+'-'+edate.split(' ')[1]
}
this.setData({
cartlist:json.data.cookBookList,
order:json.data.order,
totalprice:json.data.order.cookBookPrice ? json.data.order.cookBookPrice : json.data.order.price
})
}
})
},
setorder(e){
let status=e.currentTarget.dataset.status;
wx.showModal({
content:'订单是否'+(status==2 ? '开始配送' : '配送完成')+',一旦修改不可撤回',
confirmColor:'#199095',
cancelColor:'#999999',
success:(res)=>{
if(res.confirm){
App.Orders.SetOrderById({orderid:this.opt.id,status:status}).then((json)=>{
wx.showToast({
title:'订单'+this.data.order.row_num+(status==2 ? '已开始配送' : '已完成配送'),
duration:1500,
mask:true,
icon:'none'
})
if(json.ret==200){
this.setData({
'order.status':status
})
// this.getorderinfo();
}
})
}
}
})
},
refund(){
wx.showModal({
content:'是否对该订单发起退款,一旦退款不可撤回',
confirmColor:'#199095',
cancelColor:'#999999',
success:(res)=>{
if(res.confirm){
App.Pay.Refund({orderid:this.opt.id}).then((json)=>{
if(json.ret==200){
wx.showToast({
title:'已退款',
mask:true,
duration:2000
})
this.setData({
'order.status':4
})
}
})
}
},
})
}
})