index.js 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. // components/My_SearchInputBox/index.js
  2. Component({
  3. /**
  4. * 组件的属性列表
  5. */
  6. properties: {
  7. /* 搜索方法 */
  8. searchQuery: {
  9. type: Function
  10. },
  11. /* 新增按钮跳转 */
  12. route: {
  13. type: String
  14. },
  15. /* 是否主账号 */
  16. fisadministrator: {
  17. type: Boolean
  18. }
  19. },
  20. /**
  21. * 组件的初始数据
  22. */
  23. data: {
  24. text: ""
  25. },
  26. /**
  27. * 组件的方法列表
  28. */
  29. methods: {
  30. /* 输入 */
  31. inputText(e) {
  32. this.setData({
  33. text: e.detail.value
  34. })
  35. },
  36. /* 失去焦点 */
  37. searchBlur(e) {
  38. const {
  39. value
  40. } = e.detail;
  41. this.triggerEvent("searchQuery", value.trim())
  42. },
  43. /* 跳转页面 */
  44. itemAdd() {
  45. if (this.data.route == 'product') {
  46. wx.navigateTo({
  47. url: '/pages/productManagement/change',
  48. })
  49. } else if (this.data.route == 'team') {
  50. wx.navigateTo({
  51. url: '/pages/teamManagement/change',
  52. })
  53. }
  54. },
  55. /* 清空 */
  56. clearInput() {
  57. this.setData({
  58. text: ""
  59. })
  60. this.triggerEvent("searchQuery", '')
  61. }
  62. }
  63. })