diy_searchbox.js
1.25 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
var t = getApp(),
o = t.globalData.setting;
Component({
properties: {
// 这里定义了innerText属性,属性值可以在组件使用时指定
object: {
type: Object,
value: null,
},
},
data: {
// 这里是一些组件内部数据
yc:false,
imghost: o.imghost,
someData: {},
first:1,
inputShowed:1,
inputval:'在店铺内搜索',
keyword:'',
},
ready: function() {
var th=this;
getApp().getConfig2(function(e) {
//看有没有热搜
if(e.hot_keywords)
th.setData({keyword:e.hot_keywords});
})
},
methods: {
//智能跳转
go_url:function (e) {
var url=e.currentTarget.dataset.url;
getApp().goto(url);
},
click_sear:function(){
//如果搜索的单词为空的时候,就要跳到搜索页
if(this.data.keyword!=''){
getApp().goto("/pages/goods/search/search");
return false;
}
this.setData({first:0,inputShowed:1,inputval:''});
},
onblur:function(){
var val=this.data.inputval;
if(val==''){
this.setData({first:1,});
}
},
set_input:function(e){
var val=e.detail.value;
this.setData({inputval:val});
},
sear:function(){
var url="/pages/goods/search/search?s_key="+this.data.inputval;
getApp().goto(url);
}
}
})