search.js 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. var _request = require('../../utils/request.js')
  2. Page({
  3. data: {
  4. statusBarHeight:20,
  5. navBarHeight:45,
  6. windowWidth:375,
  7. wordlist:[],
  8. searchword:''
  9. },
  10. onLoad: function () {
  11. const info = wx.getSystemInfoSync();
  12. console.log('info',info);
  13. this.setData({
  14. statusBarHeight:info.statusBarHeight
  15. })
  16. },
  17. onShow: function () {
  18. this.getData()
  19. },
  20. onUnload: function () {
  21. },
  22. onHide: function () {
  23. },
  24. getData: function () {
  25. var that = this
  26. var url = 'v1/product/commend_words'
  27. var params = {}
  28. var success = function (res) {
  29. console.log('res',res.data.list);
  30. that.setData({
  31. wordlist:res.data.list
  32. })
  33. }
  34. _request.$get(url, params, success)
  35. },
  36. setword:function(e){
  37. var that = this;
  38. console.log('e',e);
  39. var word = e.currentTarget.dataset.word;
  40. that.setData({
  41. searchword:word
  42. })
  43. that.tosearch();
  44. },
  45. tosearch:function(){
  46. console.log('tosearch')
  47. var word = this.data.searchword;
  48. if(word == ''){
  49. word = this.data.wordlist[0]['title']
  50. }
  51. wx.navigateTo({
  52. url: '../projects/project-search/project-search?words=' + word
  53. })
  54. },
  55. bindword: function (e) {
  56. var word = e.detail.value;
  57. this.setData({
  58. searchword: word
  59. })
  60. },
  61. })