Helius
2021-04-07 5a9edd419172c5d4072d7d945a34b1bddfcbc604
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
var util = require('../../utils/util.js');
Component({
    data: {
    history: [],
    content:'',
    hint:'',
    
 
  },
  methods: {
    // 返回上一级
    onCancel(e){
      this.triggerEvent('cancel', {}, {}) //给cancel绑定事件
    },
    // 搜索
    search(e){  
      var _this = this;
      var content = _this.data.content;
      if (content == undefined || content.replace(/\s*/g, "") == ''){
        
        content = _this.data.hint;
      }
      wx.navigateTo({
        url: '../../pages/shopTypeSecond/shopTypeSecond?content=' + content,
      })
    },
    // 数据绑定搜索框
    formName: function (e) {
      this.setData({
        content: e.detail.value
      })
    },
    
    jumpGoods(e) {
      var content = e.currentTarget.dataset.content;
      wx.navigateTo({
        url: '../../pages/shopTypeSecond/shopTypeSecond?content=' + content,
      })
    },
    // 删除历史
    cleanHistory() {
      var _this = this;
      // 删除历史
      util.request("GET", '/wxapi/shopUserSearchRecord/deleteSearchRecord', {}, function (data) {
        if (data.status == '200') {
          _this.searchHistory();
        }
      }, true);
    },
    // 搜索历史
    searchHistory() {
      var _this = this;
      
      util.request("GET", '/wxapi/shopUserSearchRecord/getSearchRecordList', {}, function (data) {
        console.log(data.rows);
        _this.setData({
          history: data.rows
        })
      }, true);
    }
  },
  attached() {
    var _this = this;
   
    // 默认搜索
    util.request("GET", '/wxapi/Advertising/getByType/index_search', {}, function (data) {
      _this.setData({
        hint: data.rows[0].title
      })
    }, true);
    // _this.searchHistory();
    util.request("GET", '/wxapi/shopUserSearchRecord/getSearchRecordList', {}, function (data) {
      console.log(data.rows);
      _this.setData({
        history: data.rows
      })
    }, true);
   
  }
 
})