重构项目文件夹目录
This commit is contained in:
@@ -0,0 +1,44 @@
|
||||
const customersApi = require('../../api/customers')
|
||||
|
||||
Page({
|
||||
data: {
|
||||
keyword: '',
|
||||
customers: []
|
||||
},
|
||||
|
||||
onLoad() {
|
||||
this.loadCustomers()
|
||||
},
|
||||
|
||||
onSearchInput(event) {
|
||||
this.setData({ keyword: event.detail.value })
|
||||
clearTimeout(this._timer)
|
||||
this._timer = setTimeout(() => this.loadCustomers(), 300)
|
||||
},
|
||||
|
||||
async loadCustomers() {
|
||||
const fallback = [
|
||||
{ id: 1, name: '王女士', phone: '138****1201', lastTime: '2026-06-01' },
|
||||
{ id: 2, name: '陈女士', phone: '136****8842', lastTime: '2026-05-29' },
|
||||
{ id: 3, name: '林女士', phone: '159****6671', lastTime: '2026-05-27' }
|
||||
]
|
||||
try {
|
||||
const data = await customersApi.list({ keyword: this.data.keyword, page: 1, size: 30 })
|
||||
const list = data.list || data || []
|
||||
this.setData({
|
||||
customers: list.map(item => ({
|
||||
id: item.id,
|
||||
name: item.nickname || item.name || item.account || '客户',
|
||||
phone: item.contactPhone || item.phone || '未填写',
|
||||
lastTime: item.lastOrderTime || item.lastConsumeTime || '-'
|
||||
}))
|
||||
})
|
||||
} catch (error) {
|
||||
this.setData({ customers: fallback })
|
||||
}
|
||||
},
|
||||
|
||||
openDetail(event) {
|
||||
wx.navigateTo({ url: `/pages/customer-detail/index?id=${event.currentTarget.dataset.id}` })
|
||||
}
|
||||
})
|
||||
Reference in New Issue
Block a user