orderDetail.js
1.69 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
import orderApi from '@/api/shop/order'
import expressApi from '@/api/system/express'
import {getApiUrl} from '@/utils/utils'
export default {
data() {
return {
form: {user: {id: '', name: ''}, address: {name: '', tel: '', addressDetail: ''}},
apiUrl: getApiUrl(),
expressList:[],
shipping:{
show:false,
id:'',
idExpress:'',
shippingSn:''
}
}
},
created() {
this.form.orderSn = this.$route.query.orderSn
this.init()
},
methods: {
init() {
this.fetchData()
},
fetchData() {
if (this.form.orderSn) {
orderApi.getOrder(this.form.orderSn).then(response => {
this.form = response.data
}
)
}
},
openSendOutForm(){
if(this.expressList.length==0){
expressApi.queryAll().then( response=> {
this.expressList = response.data
})
}
this.shipping.show = true
},
sendOut() {
this.$confirm(this.$t('common.optionConfirm'), this.$t('common.tooltip'), {
confirmButtonText: this.$t('button.submit'),
cancelButtonText: this.$t('button.cancel'),
type: 'warning'
}).then(() => {
orderApi.sendOut(this.form.id,this.shipping.idExpress,this.shipping.shippingSn).then(response => {
this.fetchData()
this.shipping.show = false
this.$message({
message: '发货成功',
type: 'success'
})
})
}).catch(() => {
})
},
formatPrice(price) {
if (price) {
return '¥' + (price / 100).toFixed(2)
}
return ''
},
printOrder() {
this.$print(this.$refs.print)
}
}
}