重构项目文件夹目录
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}` })
|
||||
}
|
||||
})
|
||||
@@ -0,0 +1,3 @@
|
||||
{
|
||||
"navigationBarTitleText": "客户"
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
<view class="page">
|
||||
<view class="search-card card">
|
||||
<input value="{{keyword}}" bindinput="onSearchInput" placeholder="搜索客户姓名或手机号" />
|
||||
</view>
|
||||
|
||||
<view class="list section">
|
||||
<view wx:for="{{customers}}" wx:key="id" class="card list-card customer-card" data-id="{{item.id}}" bindtap="openDetail">
|
||||
<view>
|
||||
<text class="name">{{item.name}}</text>
|
||||
<text class="meta">{{item.phone}}</text>
|
||||
<text class="meta">最近消费 {{item.lastTime}}</text>
|
||||
</view>
|
||||
<text class="arrow">›</text>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
@@ -0,0 +1,39 @@
|
||||
.search-card {
|
||||
padding: 0 24rpx;
|
||||
height: 84rpx;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
.search-card input {
|
||||
width: 100%;
|
||||
font-size: 26rpx;
|
||||
}
|
||||
|
||||
.customer-card {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
}
|
||||
|
||||
.name,
|
||||
.meta {
|
||||
display: block;
|
||||
}
|
||||
|
||||
.name {
|
||||
color: #292520;
|
||||
font-size: 30rpx;
|
||||
font-weight: 800;
|
||||
}
|
||||
|
||||
.meta {
|
||||
margin-top: 8rpx;
|
||||
color: #928a81;
|
||||
font-size: 24rpx;
|
||||
}
|
||||
|
||||
.arrow {
|
||||
color: #b0a79e;
|
||||
font-size: 48rpx;
|
||||
}
|
||||
Reference in New Issue
Block a user