forked from youzan/vant
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDetail.js
More file actions
85 lines (78 loc) · 1.97 KB
/
Detail.js
File metadata and controls
85 lines (78 loc) · 1.97 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
import { createNamespace } from '../utils';
import { isAndroid } from '../utils/validate/system';
import Cell from '../cell';
import Field from '../field';
const [createComponent, bem, t] = createNamespace('address-edit-detail');
const android = isAndroid();
export default createComponent({
props: {
value: String,
error: Boolean,
focused: Boolean,
detailRows: Number,
searchResult: Array,
detailMaxlength: Number,
showSearchResult: Boolean
},
methods: {
onSelect(express) {
this.$emit('select-search', express);
this.$emit(
'input',
`${express.address || ''} ${express.name || ''}`.trim()
);
},
onFinish() {
this.$refs.field.blur();
},
genFinish() {
const show = this.value && this.focused && android;
if (show) {
return (
<div class={bem('finish')} onClick={this.onFinish}>
{t('complete')}
</div>
);
}
},
genSearchResult() {
const { searchResult } = this;
const show = this.focused && searchResult && this.showSearchResult;
if (show) {
return searchResult.map(express => (
<Cell
key={express.name + express.address}
title={express.name}
label={express.address}
icon="location-o"
clickable
onClick={() => {
this.onSelect(express);
}}
/>
));
}
}
},
render() {
return (
<Cell class={bem()}>
<Field
autosize
ref="field"
rows={this.detailRows}
clearable={!android}
type="textarea"
value={this.value}
error={this.error}
label={t('label')}
maxlength={this.detailMaxlength}
placeholder={t('placeholder')}
scopedSlots={{ icon: this.genFinish }}
{...{ on: this.$listeners }}
/>
{this.genSearchResult()}
</Cell>
);
}
});