12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364 |
- const events = ["inputBlur", "inputConfirm","searchFocus"];
- const bindSearch = function (_self){
- Object.assign(_self, searchmodule);
- }
- /*
- 搜索失去聚焦事件
- */
- export const searchmodule = {
- inputBlur: function(e) {
- this.setData({
- searchfocus: false
- })
- },
- /*
- 搜索input确定时事件
- */
- inputConfirm : function(e) {
- var word = e.detail.value;
- //if (word) {
- if(typeof this.submitsearchinfo=="function"){
- this.submitsearchinfo({keys:word});
- }
- this.cancelSearch();
- // } else {
- // this.setData({
- // searchshow: false,
- // searchfocus: false
- // })
- if (this.focusani){
- clearTimeout(this.focusani);
- }
- //}
- },
- /*
- 搜索聚焦事件
- */
- searchFocus:function(e) {
- var _self = this;
- this.setData({
- searchshow: true
- })
- this.focusani = setTimeout(function () {
- _self.setData({
- searchfocus: true
- })
- }, 500)
- },
- cancelSearch:function(e){
- var _self = this;
- this.setData({
- searchshow: false
- })
- },
- tapHot:function(e){
- var brand = e.currentTarget.dataset.val;
- if(typeof this.submitsearchinfo=="function"){
- this.submitsearchinfo({keys:brand});
- }
- }
- }
- export default bindSearch
|