52 lines
1.5 KiB
Vue
52 lines
1.5 KiB
Vue
<template>
|
|
<view class="page">
|
|
<view class="search">
|
|
<input v-model="kw" placeholder="搜索客户名称/电话" @confirm="search" />
|
|
<button size="mini" @click="search">搜索</button>
|
|
</view>
|
|
<scroll-view scroll-y class="list">
|
|
<view class="item" v-for="c in customers" :key="c.id" @click="select(c)">
|
|
<view class="name">{{ c.name }}</view>
|
|
<view class="meta">{{ c.mobile || '—' }}</view>
|
|
</view>
|
|
</scroll-view>
|
|
</view>
|
|
</template>
|
|
|
|
<script>
|
|
import { get } from '../../common/http.js'
|
|
export default {
|
|
data() { return { kw: '', customers: [] } },
|
|
onLoad() { this.search() },
|
|
methods: {
|
|
async search() {
|
|
try {
|
|
const res = await get('/api/customers', { kw: this.kw, page: 1, size: 50 })
|
|
this.customers = Array.isArray(res?.list) ? res.list : (Array.isArray(res) ? res : [])
|
|
} catch(e) { uni.showToast({ title: '加载失败', icon: 'none' }) }
|
|
},
|
|
select(c) {
|
|
const opener = getCurrentPages()[getCurrentPages().length-2]
|
|
if (opener && opener.$vm) {
|
|
opener.$vm.order.customerId = c.id
|
|
opener.$vm.customerName = c.name
|
|
}
|
|
uni.navigateBack()
|
|
}
|
|
}
|
|
}
|
|
</script>
|
|
|
|
<style>
|
|
.page { display:flex; flex-direction: column; height: 100vh; }
|
|
.search { display:flex; gap: 12rpx; padding: 16rpx; background:#fff; }
|
|
.search input { flex:1; background:#f6f6f6; border-radius: 12rpx; padding: 12rpx; }
|
|
.list { flex:1; }
|
|
.item { padding: 20rpx 24rpx; background:#fff; border-bottom: 1rpx solid #f1f1f1; }
|
|
.name { color:#333; margin-bottom: 6rpx; }
|
|
.meta { color:#888; font-size: 24rpx; }
|
|
</style>
|
|
|
|
|
|
|