search.vue
2.11 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
<template>
<layout-body class="product-search">
<search-bar class="product-search-bar" @cancel="cancel" v-model="search"></search-bar>
<div class="frames">
<iframe ref="ifr" name="iframe" :src="searchUrl" frameborder="0" v-if="showIframe"></iframe>
</div>
</layout-body>
</template>
<script>
import SearchBar from 'components/search/search-bar';
import {mapState} from 'vuex';
export default {
name: 'Search',
data() {
return {
searchKey: '',
search: '',
showIframe: false
};
},
beforeRouteUpdate(to, from, next) {
this.searchKey = to.query.query;
this.search = to.query.query;
next();
},
created() {
this.searchKey = this.$route.query.query;
this.search = this.$route.query.query;
},
mounted() {
window.blkDocument = {
goNewPage:({url}) => {
const $appLink = document.querySelector('#yoho-app-link');
$appLink.href = url;
$appLink.click();
if (this.$yoho.isiOS) {
$appLink.click();
}
}
};
window.yohoInterface = window.yohoInterface;
this.$bus.$on('after-view-enter', () => {
this.showIframe = true;
});
if (this.yoho.env.fs) {
this.showIframe = true;
}
},
computed: {
...mapState(['yoho']),
searchUrl() {
return `/search?query=${this.searchKey}`;
}
},
methods: {
cancel() {
this.$yoRouter.goBack(-1);
},
loadYohoInterface() {
// this.$yoho.ready(() => {
// });
}
},
components: {SearchBar}
};
</script>
<style lang="scss">
.product-search {
display: flex;
flex-direction: column;
}
.product-search-bar {
height: 90px;
}
.frames {
position: absolute;
top: 90px;
left: 0;
right: 0;
bottom: 0;
overflow-y: auto;
-webkit-overflow-scrolling: touch;
iframe {
width: 100%;
height: 100%;
}
}
</style>