OrderNoPopup.js
3.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
// packageCrowdFunding/components/OrderNoPopup/OrderNoPopup.js
import api from '../../api/api'
Component({
/**
* 组件的属性列表
*/
properties: {
show: {
type: Boolean,
observer: function(n) {
if (n) {
this.getWaitinputorder()
}
}
},
title: String,
orderInfo: Object
},
/**
* 组件的初始数据
*/
data: {
itemFormObj: [
{
label: '交易参考号',
prop: 'outTradeNo'
}, {
label: '支付时间',
prop: 'accountDate'
}, {
label: '交易金额',
prop: 'totalFee',
type: 'price'
}
],
currentPage: 1,
pageSize: 10,
pages: '',
orderNoList: [],
isAll: false
},
/**
* 组件的方法列表
*/
methods: {
// 选择交易流水号
changeOrderNo(e) {
let { target } = e.currentTarget.dataset
let { orderNoList } = this.data
orderNoList.map(i => {
i.active = false
if (i.outTradeNo && i.outTradeNo == target.outTradeNo) {
i.active = true
}
return i
})
this.setData({orderNoList})
},
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({isAll: true, orderNoList: []})
this.restPageNum()
},
getWaitinputorder() {
let { currentPage, pageSize, orderNoList, orderInfo, isAll } = this.data
// totalFee 根据商品众筹价筛选交易流水号
let totalFee = isAll ? '' : orderInfo.totalFee
api
.waitinputorder({ currentPage, pageSize, totalFee})
.then(result => {
let { code, data } = result
if (code == 0) {
data.list.forEach(element => {
element.accountDate = new Date(element.accountDate).format('yyyy-MM-dd hh:mm:ss')
element.active = false
if (element.outTradeNo && element.outTradeNo == orderInfo.outTradeNo) {
element.active = true
}
})
this.setData({
orderNoList: currentPage == 1 ? data.list : [...orderNoList, ...data.list],
pages: data.pages,
triggered: false
})
}
})
.catch(err => {})
},
confirm() {
let { orderNoList, orderInfo } = this.data
let arr = orderNoList?.filter(v => v.active) || []
if (!arr.length) {
return wx.showToast({
title: '请选择交易参考号',
icon: 'none'
})
}
let thisPage = wx.$router.getPageInstance()
orderInfo.outTradeNo = arr[0]?.outTradeNo || ''
thisPage.setData({
orderInfo,
orderNoPopup: false
})
},
cancel() {
let thisPage = wx.$router.getPageInstance()
thisPage.setData({
orderNoPopup: false
})
}
}
})