orderSwitchPopup.js
4.08 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
import api from '../../api/api.js'
import Util from '../../utils/util'
Component({
options: {
multipleSlots: true // 在组件定义时的选项中启用多slot支持
},
/*组件的属性列表*/
properties: {
title: {
type: String,
value: '标题'
},
// 弹窗内容
content: {
type: String,
value: '内容'
},
// 弹窗取消按钮文字
btn_no: {
type: String,
value: '取消'
},
// 弹窗确认按钮文字
btn_ok: {
type: String,
value: '补录这笔订单'
},
//是否显示取消按钮
isShowCancel: {
type: Boolean,
value: true
},
//是否显示右上角关闭按钮
isShowClose: {
type: Boolean,
value: true
// <view class="order-popup-close" bindtap="close">
// <image src="../images/order-close.png" />
// </view>
},
//应用于某些场景的button的open-type属性
sureButtonType: {
type: String,
value: ''
},
//控制弹窗的显示
flag: {
type: Boolean,
value: true
}
// merchantId: {
// //是否根据4s店查询
// type: String,
// value: ''
// }
},
/* 组件的初始数据 */
data: {
bgOpacity: 0,
wrapAnimate: 'wrapAnimate',
popupAnimate: 'popupAnimate',
currentPage: 1,
pageSize: 10,
tableList: [],
activeIndex: ''
},
lifetimes: {
attached: function () {
this.getWaitinputorder()
// 在组件实例进入页面节点树时执行
},
detached: function () {
// 在组件实例被从页面节点树移除时执行
}
},
/* 组件的方法列表 */
methods: {
choose(e) {
let { item, index } = e.currentTarget.dataset
console.log(index)
let { tableList } = this.data
tableList.forEach(element => {
element.active = false
})
tableList[index].active = true
this.setData({
tableList,
activeIndex: index
})
},
restPageNum() {
console.log('restPageNum')
this.setData({
currentPage: 1
})
this.getWaitinputorder()
},
scrollonReachBottom() {
console.log('scrollonReachBottom')
let { pages, currentPage } = this.data
// 判断当前页是否是末页
if (pages == currentPage) return wx.$util.showToast('列表已到底')
this.setData({
currentPage: currentPage + 1
})
this.getWaitinputorder()
},
getWaitinputorder() {
let { currentPage, pageSize, tableList } = this.data
api
.waitinputorder({ currentPage, pageSize })
.then(result => {
let { code, data } = result
if (code == 0) {
// console.log(data.list)
data.list.forEach(element => {
// element.totalFee = element.totalFee / 100
element.formatAccountDate = Util.tsFormatTime(element.accountDate, 'M/D h:m')
element.accountDate = new Date(element.accountDate).format('yyyy-MM-dd')
})
// console.log(data.list)
this.setData({
tableList: currentPage == 1 ? data.list : [...tableList, ...data.list],
pages: data.pages,
triggered: false
})
// console.log(tableList)
}
// console.log(result)
})
.catch(err => {})
},
/* 内部私有方法建议以下划线开头 triggerEvent 用于触发事件 */
_close() {
//触发取消回调
this.triggerEvent('close')
},
_success() {
let { tableList, activeIndex } = this.data
// console.log('number' === typeof activeIndex)
// debugger
if ('number' !== typeof activeIndex) return wx.$util.showToast('请选择订单')
let { accountDate, outTradeNo, totalFee } = tableList[activeIndex]
tableList[activeIndex] && this.triggerEvent('success', { accountDate, outTradeNo, totalFee })
// if (activeIndex != '') {
// //触发成功回调
// console.log(tableList[activeIndex].tradeNo)
// }
}
}
})