CustomerAutocomplete.vue
3.65 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
154
155
156
157
158
159
160
161
162
163
164
<template>
<view :class="['customer-box',{'is-show':showCustomerBox}]">
<view class="customer-title">客户档案的记录</view>
<scroll-view
scroll-y
class="scroll-box"
>
<template v-if="loading">
<view class="loading flex">
<uni-icons
type="refreshempty"
:size="46"
color="#3773F8"
class="icon"
></uni-icons>
</view>
</template>
<template v-else>
<template v-if="searchList.length">
<template v-for="(i,index) in searchList">
<view
class="item flex"
:key="index"
hover-class="active"
@click="$emit('choose',i)"
>
{{ `${showType == 'tel'?i.ownerPhone:i.ownerName}`}}
</view>
</template>
</template>
<template v-else>
<view class="nothing flex">
<view class="icon"></view>
未匹配到客户信息
</view>
</template>
</template>
</scroll-view>
</view>
</template>
<script type='text/ecmascript-6'>
export default {
name: 'CustomerAutocomplete',
props: {
searchValue: String,
showType: String,
show: Boolean
},
data () {
return {
loading: true,
searchList: []
}
},
watch: {
showCustomerBox: {
immediate: true,
handler (newval) {
if (newval) this.getCustomerInfoList(this.searchValue, this.showType)
}
}
},
computed: {
showCustomerBox () {
return this.show && this.haveCustomerAccess && this.searchValue
},
haveCustomerAccess () {
return this.$store.state.user.haveCustomerAccess
}
},
mounted () {
},
methods: {
async getCustomerInfoList (val, type) {
try {
this.loading = true
const { shopMerchantId, sceneType } = uni.$storage.get("userInfo"),
params = {
merchantId: shopMerchantId,
bussinessScene: sceneType == 0 ? 1 : 2 // 1.延保 2.轻改
}
if (type == 'tel') params.ownerPhone = val
else params.ownerName = val
this.searchList = await uni.$api.customerApi.getCustomerInfoList(params)
this.loading = false
} catch (error) {
this.loading = false
}
}
}
}
</script>
<style scoped lang='scss'>
.customer-box {
position: absolute;
left: 0;
top: toRpx(88);
width: 100%;
height: toRpx(352);
background: #ffffff;
border-radius: toRpx(16);
z-index: -1;
opacity: 0;
.customer-title {
font-size: toRpx(24);
color: #999999;
line-height: toRpx(40);
padding: toRpx(16) toRpx(24) toRpx(8);
}
.scroll-box {
height: calc(100% - #{toRpx(64)});
.loading {
width: 100%;
height: 100%;
justify-content: center;
.icon {
animation: rotate-loading 1s linear infinite;
}
}
.nothing {
width: 100%;
height: 100%;
font-size: toRpx(24);
color: #c7ccd7;
flex-direction: column;
.icon {
margin-top: toRpx(52);
width: toRpx(96);
height: toRpx(96);
background-image: url('@/assets/images/common/nothing.webp');
background-size: 100%;
}
}
.item {
width: 100%;
height: toRpx(48);
font-size: toRpx(28);
color: #333333;
line-height: toRpx(40);
padding-left: toRpx(24);
margin-bottom: toRpx(8);
}
.active {
background: #ecf1ff;
}
@keyframes rotate-loading {
0% {
transform: rotate(0);
}
100% {
transform: rotate(360deg);
}
}
}
}
.is-show {
z-index: 1;
opacity: 1;
}
</style>