diy_searchbox.js 1.25 KB
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);
	}
	
  }
})