OrderPopup.js
3.94 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
// components/OrderPopup/OrderPopup.js
import api from '~/api/api.js'
Component({
/**
* 组件的属性列表
*/
options: {
styleIsolation: 'shared', // 自定义覆盖vant样式
},
properties: {
show: Boolean,
orderType: {
type: String,
observer: function (n) {
}
},
resetTransNo: String,
resetOrder: Boolean
},
/**
* 组件的初始数据
*/
data: {
textareaValue: '',
routerBack: null,
outTradeNo: '',
payVoucherList: []
},
/** 组件生命周期 */
lifetimes: {
attached: function () {
}
},
/**
* 组件的方法列表
*/
methods: {
noScroll() { },
close() {
let thisPage = wx.$router.getPageInstance()
let { routerBack } = this.data
if (routerBack) {
wx.navigateBack()
return
}
this.setData({
show: false
})
// 点击关闭 情况门店付款数据
thisPage.setData({
showPopup: false,
['orderInfo.transactionNo']: '',
['orderInfo.paymentDocList']: []
})
},
input(e) {
let { value } = e.detail
let val = value.replace(/[\u4E00-\u9FA5]/g, '')
this.setData({
outTradeNo: val
})
},
// 上传付款凭证
upLoad(event) {
let _this = this
let { payVoucherList } = _this.data
const { file } = event.detail
let tempFiles = file?.url
let imgType = tempFiles.split('.')[1]
let type = imgType == 'unknown' ? 'jpg' : imgType
wx.getFileSystemManager().readFile({
filePath: tempFiles, //选择图片返回的相对路径
encoding: 'base64', //编码格式
success(_res) {
wx.$util.showLoading('上传中...')
api
.uploadImg({
file: `${type}@${_res.data}`
})
.then(img => {
wx.$util.hideLoading()
console.log(img)
let { code, data, message } = img
if (code == 0) {
payVoucherList.push({ url: data })
_this.setData({
payVoucherList
})
} else {
wx.$util.showToast(message)
}
})
}
})
},
// 删除上传
deletePayVoucher(e) {
let { index } = e?.detail
let _this = this
let { payVoucherList } = _this.data
payVoucherList.splice(index, 1)
this.setData({
payVoucherList
})
},
changeOrderSource(e) {
console.log(e)
let { index } = e.currentTarget.dataset
let { orderTypeList } = this.data
orderTypeList.map(i => (i.active = false))
orderTypeList[index].active = true
this.setData({
orderTypeList
})
},
confirm(e) {
let { outTradeNo, payVoucherList, resetOrder } = this.data
// debugger
// console.log(wx.$router)
let thisPage = wx.$router.getPageInstance()
if (resetOrder) return this.newResetOrder()
// if (orderType == 2) {
if (payVoucherList.length && outTradeNo) {
thisPage.setData({
['orderInfo.transactionNo']: outTradeNo,
['orderInfo.paymentDocList']: payVoucherList.map(item => item.url)
})
console.log(thisPage.handleSecondConfirm);
thisPage.handleSecondConfirm()
} else {
wx.$util.showToast('交易流水号或付款凭证不能为空!')
}
// }
},
// 标记错误订单&补录订单
newResetOrder() {
let { resetTransNo, payVoucherList } = this.data
let thisPage = wx.$router.getPageInstance()
if (payVoucherList.length && resetTransNo) {
thisPage.setData({
['orderInfo.transactionNo']: resetTransNo,
['orderInfo.paymentDocList']: payVoucherList.map(item => item.url)
})
thisPage.handleSecondConfirm()
} else {
wx.$util.showToast('交易流水号或付款凭证不能为空!')
}
}
}
})