recordingOrderPopup.js
6.12 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
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
// tabIndex/components/recordingOrderPopup/recordingOrderPopup.js
import api from '~/api/api'
const IMG_URL =
'https://img02.glsx.com.cn/weapp/resource/dj-car-boutique-work-wechat/'
Component({
/**
* 组件的属性列表
*/
properties: {
show: {
type: Boolean,
observer: function (n) {
if (n) {
let { switchValuerec } = this.data
this.setData({
switchValue: switchValuerec || 1,
currentPage: 1,
orderNoList: []
})
this.getWaitinputorder()
}
}
},
title: String,
outTradeNo: {
type: Array,
observer: function(val) {
this.setData({
selectOutTradeNoArr: val
})
}
},
switchValuerec: Number,
lowPriceFlag: {
type: Number,
value: 0
},
merchantId: {
type: String,
value: ''
},
yqMerchantId: {
type: String,
value: ''
}
},
/**
* 组件的初始数据
*/
data: {
IMG_URL,
itemFormObj: [
{
label: '交易参考号',
prop: 'tradeNo',
type: 'copy'
},
{
label: '支付时间',
prop: 'accountDate'
},
{
label: '支付金额',
prop: 'totalFee',
type: 'price'
},
{
label: '商户名称',
prop: 'merchantName'
}
],
currentPage: 1,
pageSize: 10,
pages: '',
orderNoList: [],
popupSlotStyle: 'height: calc(100% - var(--fontSize120));',
filmOrderData: ['太阳膜', '精品升级'],
switchValue: 1,
tipsshow: false,
scrollTop: 0,
selectOutTradeNoArr: [] // 已选的交易参考号数据
},
/**
* 组件的方法列表
*/
methods: {
showTips() {
this.setData({
tipsshow: true
})
},
changeSwitch(e) {
let { value } = e.currentTarget.dataset
this.setData({
switchValue: value,
scrollTop: 0,
// outTradeNo: [],
currentPage: 1 // 重新请求列表
})
this.getWaitinputorder()
},
// 选择交易流水号
changeOrderNo(e) {
let { target } = e.currentTarget.dataset
let { orderNoList, selectOutTradeNoArr } = this.data
// 是要勾选的话判断不能超管9个
if (!target.active) {
if (target.outTradeNo) {
if (selectOutTradeNoArr.length >= 8) {
return wx.$util.showToast('勾选已超过限制')
}
selectOutTradeNoArr.push(target)
}
} else {
const index = selectOutTradeNoArr.findIndex(val => val.outTradeNo == target.outTradeNo)
if (index > -1) {
selectOutTradeNoArr.splice(index, 1)
}
}
orderNoList.map(i => {
// i.active = false
if (i.outTradeNo && i.outTradeNo == target.outTradeNo) {
i.active = !i.active
}
return i
})
this.setData({
orderNoList,
selectOutTradeNoArr
})
},
// 产品类型切换
selectTap(e) {
let { index } = e.currentTarget.dataset
this.setData({
showSelect: !this.data.showSelect,
filmOrderIndex: index
})
},
closeSelect() {
this.setData({
showSelect: false
})
},
optionTap(e) {
let { index, orderIndex } = e.currentTarget.dataset
let prop = `orderNoList[${orderIndex}].filmOrder`
this.setData({
[prop]: index,
showSelect: false
})
},
// 复制单号
copyOutTradeNo(e) {
let { item } = e.currentTarget.dataset
wx.$util.setCopyData(`${item?.tradeNo}`)
},
restPageNum() {
this.setData({
currentPage: 1
})
this.getWaitinputorder()
},
scrollonReachBottom() {
let { pages, currentPage } = this.data
// 判断当前页是否是末页
if (pages == currentPage) return wx.$util.showToast('列表已到底')
this.setData({
currentPage: currentPage + 1
})
this.getWaitinputorder()
},
getWaitinputorder() {
let {
currentPage,
pageSize,
orderNoList,
selectOutTradeNoArr,
switchValue,
lowPriceFlag,
merchantId,
yqMerchantId
} = this.data
const params = { currentPage, pageSize, inputOrderType: switchValue }
if (lowPriceFlag) {
params.lowPriceFlag = lowPriceFlag
params.merchantId = merchantId
params.yqMerchantId = yqMerchantId
}
api
.waitinputorder(params)
.then(result => {
let { code, data } = result
if (code == 0) {
data.list.forEach(element => {
element.filmOrder = 0
element.accountDate = new Date(element.accountDate).format(
'yyyy-MM-dd hh:mm:ss'
)
element.active = selectOutTradeNoArr.some(val => val.outTradeNo == element.outTradeNo)
element.merchantName = element?.shopMerchantName ? element?.shopMerchantName : element.yqMerchantName
element.switchValue = switchValue
})
orderNoList =
currentPage == 1 ? data.list : [...orderNoList, ...data.list]
// orderNoList = orderNoList.for
// for (let index = 0; index < 3; index++) {
// // const element = array[index];
// orderNoList.push(...orderNoList)
// }
this.setData({
orderNoList,
pages: data.pages,
triggered: false
})
}
})
.catch(err => { })
},
confirm() {
let { selectOutTradeNoArr } = this.data
if (!selectOutTradeNoArr?.length) {
return wx.showToast({
title: '请选择交易参考号',
icon: 'none'
})
}
let thisPage = wx.$router.getPageInstance()
thisPage.setData({
showOrderpop: false
})
if (selectOutTradeNoArr?.length) {
this.triggerEvent('success', { selectOutTradeNoArr })
}
},
cancel() {
let thisPage = wx.$router.getPageInstance()
thisPage.setData({
showOrderpop: false
})
}
}
})