OrderNoPopup.js
5.16 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
// packageCrowdFunding/components/OrderNoPopup/OrderNoPopup.js
import api from '~/api/api.js'
import { ImgUrl } from '~/config'
const IMG_URL = ImgUrl + '/'
Component({
/**
* 组件的属性列表
*/
properties: {
show: {
type: Boolean,
observer: function (n) {
console.log(n, 'show')
if (n) {
let { switchValuerec } = this.data
this.setData({
switchValue: switchValuerec || 1
})
this.getWaitinputorder()
}
}
},
title: String,
orderInfo: Object,
outTradeNo: {
type: Array,
observer: function(val) {
this.setData({
selectOutTradeNoArr: val
})
}
},
switchValuerec: Number
},
/**
* 组件的初始数据
*/
data: {
IMG_URL,
itemFormObj: [
{
label: '交易参考号',
// prop: 'outTradeNo',
prop: 'tradeNo',
copy: true
},
{
label: '支付时间',
prop: 'accountDate'
},
{
label: '交易金额',
prop: 'totalFee',
type: 'price'
},
{
label: '商户名称',
prop: 'merchantName'
// type: 'price'
}
],
currentPage: 1,
pageSize: 10,
pages: '',
orderNoList: [],
popupSlotStyle: 'height: calc(100% - var(--fontSize120));',
switchValue: 1,
tipsshow: false,
scrollTop: 0,
selectOutTradeNoArr: [] // 已选的交易参考号数据
// isAll: false
},
/**
* 组件的方法列表
*/
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
})
},
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()
},
getList() {
this.setData({ orderNoList: [] })
this.restPageNum()
},
getWaitinputorder() {
let { currentPage, pageSize, orderNoList, selectOutTradeNoArr, switchValue } = this.data
api
.waitinputorder({ currentPage, pageSize, inputOrderType: switchValue })
.then(result => {
console.log(result, 'result')
let { code, data } = result
if (code == 0) {
data.list.forEach(element => {
element.accountDateValue = element.accountDate
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
})
console.log(data.list)
this.setData({
orderNoList: currentPage == 1 ? data.list : [...orderNoList, ...data.list],
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({
tipsProps: false
})
if (selectOutTradeNoArr?.length) {
this.triggerEvent('success', { selectOutTradeNoArr })
}
},
cancel() {
let thisPage = wx.$router.getPageInstance()
thisPage.setData({
orderNoPopup: false
})
},
// 复制交易参考号
toCopyNumber(e) {
const { ordernum } = e.currentTarget.dataset
wx.setClipboardData({
data: ordernum.toString(),
success(res) {
wx.$util.showToast('已复制')
}
})
}
}
})