searchbar.js 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153
  1. const Parse = getApp().Parse;
  2. const company = getApp().globalData.company
  3. Component({
  4. behaviors: [],
  5. // 属性定义(详情参见下文)
  6. properties: {
  7. options: null,
  8. },
  9. data: {
  10. value: '',
  11. }, // 私有数据,可用于模板渲染
  12. lifetimes: {
  13. // 生命周期函数,可以为函数,或一个在methods段中定义的方法名
  14. attached: function () {
  15. let {
  16. options
  17. } = this.data
  18. console.log('搜索栏', options);
  19. let {
  20. data,
  21. src,
  22. style,
  23. } = options
  24. let {
  25. className,
  26. equalTo
  27. } = data[0]
  28. console.log(className, equalTo);
  29. let {
  30. backgroundColor,
  31. borderRadius,
  32. btnBgColor,
  33. btnBorderRadius,
  34. btnColor,
  35. btnFontSize,
  36. btnHeight,
  37. btnMargin,
  38. btnWidth,
  39. height,
  40. iconColor,
  41. iconMargin,
  42. iconSize,
  43. inputBgColor,
  44. inputBorderRadius,
  45. inputColor,
  46. inputFontSize,
  47. inputHeight,
  48. inputMargin,
  49. inputPadding,
  50. inputWidth,
  51. margin,
  52. opacity,
  53. padding,
  54. placeholder,
  55. placeholderColor,
  56. width,
  57. } = style
  58. this.setData({
  59. src,
  60. backgroundColor,
  61. borderRadius,
  62. btnBgColor,
  63. btnBorderRadius,
  64. btnColor,
  65. btnFontSize,
  66. btnHeight,
  67. btnMargin,
  68. btnWidth,
  69. height,
  70. iconColor,
  71. iconMargin,
  72. iconSize,
  73. inputBgColor,
  74. inputBorderRadius,
  75. inputColor,
  76. inputFontSize,
  77. inputHeight,
  78. inputMargin,
  79. inputPadding,
  80. inputWidth,
  81. margin,
  82. opacity,
  83. padding,
  84. placeholder,
  85. placeholderColor,
  86. width,
  87. className,
  88. equalTo
  89. })
  90. },
  91. moved: function () {},
  92. detached: function () {},
  93. },
  94. ready: function () {},
  95. pageLifetimes: {
  96. // 组件所在页面的生命周期函数
  97. show: function () {},
  98. hide: function () {},
  99. resize: function () {},
  100. },
  101. methods: {
  102. goGoodsLitst() {
  103. let {
  104. value,
  105. className,
  106. equalTo
  107. } = this.data
  108. if(!value) {
  109. wx.showToast({
  110. title: '请输入需要搜索的内容',
  111. icon: 'none'
  112. })
  113. return
  114. }
  115. wx.navigateTo({
  116. url: '/nova-shop/pages/search-list/index?value=' + value,
  117. success: (res) => {
  118. res.eventChannel.emit('acceptDataFromOpenerPage', {
  119. value,
  120. className,
  121. equalTo,
  122. })
  123. },
  124. fail: () => {},
  125. complete: () => {}
  126. });
  127. },
  128. onMyButtonTap: function () {
  129. this.setData({
  130. // 更新属性和数据的方法与更新页面数据的方法类似
  131. })
  132. },
  133. // 内部方法建议以下划线开头
  134. _myPrivateMethod: function () {
  135. // 这里将 data.A[0].B 设为 'myPrivateData'
  136. this.setData({
  137. 'A[0].B': 'myPrivateData'
  138. })
  139. },
  140. _propertyChange: function (newVal, oldVal) {
  141. }
  142. }
  143. })