methods.js
2.71 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
import {
getSceneClueList,
getSceneMarketMaterialMenu
} from '../request'
import dayjs from 'dayjs'
export default {
inputSearch(e) {
let {
value
} = e.detail
this.setData({
currentPage: 1,
list: [],
flag: false,
nothing: false,
storeName: value
})
this.getSceneClueList()
},
search() {
this.setData({
currentPage: 1,
list: [],
flag: false,
nothing: false,
storeName: ''
})
this.getSceneClueList()
},
tabBarClick(e) {
if (this.data.tabIndex == e.detail) return
const tabIndex = e.detail
this.setData({
tabIndex
})
this.search()
},
jumpClue(e) {
let {
id
} = e.currentTarget.dataset,
url = '/packageStudy/pages/sceneMarket/clueForm/clueForm'
if (id) url += `?id=${id}`
wx.navigateTo({
url,
})
},
/**获取tab高度 */
getTabHeight() {
wx.$util.getViewInfo('.search-box', res => {
if (res?.height) this.setData({
searchBoxHeight: res.height
})
})
},
async getSceneMarketMaterialMenu() {
try {
const {
code,
message,
data
} = await getSceneMarketMaterialMenu()
if (code == 0) {
this.setData({
tab: data
})
this.tabBarClick({
detail: 0
})
} else throw message
} catch (error) {
wx.$util.showToast(error)
}
},
async getSceneClueList() {
try {
wx.$util.showLoading()
const {
tab,
storeName,
tabIndex,
pageSize,
currentPage
} = this.data, {
code,
message,
data
} = await getSceneClueList({
pageSize,
currentPage,
businessCode: tab[tabIndex].code,
storeName
})
wx.hideLoading()
if (code == 0) {
let {
list,
total
} = data
list?.map(e => {
e.time = dayjs(e.createdDate).format('YYYY-MM-DD')
})
this.setData({
[`list[${currentPage - 1}]`]: list || [],
total,
flag: true
}, () => {
setTimeout(() => {
wx.hideLoading()
}, 200)
})
} else throw message
} catch (error) {
wx.hideLoading()
this.setData({
flag: true
})
wx.$util.showToast(error)
}
},
viewScrollTolower() {
let {
currentPage,
total,
pageSize
} = this.data
if (!pageSize) pageSize = 10
if (Math.ceil(total / pageSize) > currentPage) {
this.setData({
currentPage: currentPage + 1
})
this.getSceneClueList()
} else {
this.setData({
nothing: true
})
}
}
}