123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960 |
- const events = ["inputBlur", "inputConfirm","searchFocus"];
- const bindSearch = function (_self){
- Object.assign(_self, searchmodule);
- }
- /*
- 搜索失去聚焦事件
- */
- export const searchmodule = {
- inputBlur: function(e) {
- this.setData({
- searchfocus: false
- })
- },
- /*
- 搜索确定时事件
- */
- inputConfirm : function(e) {
- var word = e.detail.value;
- if (word) {
- if(typeof this.submitsearchword=="function"){
- this.submitsearchword(word);
- }
- } 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
- })
- }
- }
- export const linkToSearch = function (word) {
- wx.navigateTo({ url: `../searchresult/searchresult?value=${word}` });
- }
- export default bindSearch
|