search.vue 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205
  1. <template>
  2. <view class="diy-search" :style="diyitem.base.bgstyle">
  3. <view :style="{ opacity: opacity }">
  4. <view class="tui-rolling-search">
  5. <block v-if="diyitem.base.is_location == '1'">
  6. <tui-icon @tap="onChangePosition" name="position-fill" color="#333" :size="30" unit="rpx">
  7. </tui-icon>
  8. <view @tap="onChangePosition" class="tui-city-name">{{ cityName }}</view>
  9. <tui-icon @tap="onChangePosition" name="turningdown" :size="32" unit="rpx">
  10. </tui-icon>
  11. <view class="tui-city-line">|</view>
  12. </block>
  13. <tui-icon name="search-2" :size="32" unit="rpx"></tui-icon>
  14. <swiper @tap="search" vertical autoplay circular interval="8000" class="tui-swiper">
  15. <block v-if="diyitem.params.placeholder">
  16. <swiper-item class="tui-swiper-item">
  17. <view class="tui-hot-item">{{diyitem.params.placeholder}}</view>
  18. </swiper-item>
  19. </block>
  20. <block v-else>
  21. <swiper-item v-for="(item, index) in diyitem.params.hotkey" :key="index"
  22. class="tui-swiper-item">
  23. <view class="tui-hot-item">{{ item }}</view>
  24. </swiper-item>
  25. </block>
  26. </swiper>
  27. </view>
  28. <view class="hot-keywords">
  29. <view v-if="diyitem.base.is_hotkey == '1'" class="tui-hot-search"
  30. :style="{ color: diyitem.base.hotkeytxtColor }">
  31. <view>热搜</view>
  32. <block v-for="(item, index) in diyitem.params.hotkey" :key="index">
  33. <view class="tui-hot-tag" :data-key="item" @tap="more">{{ item }}</view>
  34. </block>
  35. </view>
  36. <view v-else class="tui-not-hot-search">
  37. </view>
  38. </view>
  39. </view>
  40. </view>
  41. </template>
  42. <script>
  43. export default {
  44. name: 'search',
  45. props: {
  46. diyitem: {
  47. type: Object,
  48. default () {
  49. return {};
  50. }
  51. },
  52. cityName: {
  53. type: String,
  54. default: ''
  55. },
  56. opacity: {
  57. type: Number,
  58. default: 1
  59. }
  60. },
  61. computed: {
  62. },
  63. data() {
  64. return {};
  65. },
  66. methods: {
  67. onChangePosition() {
  68. this.$emit("onChangePosition", {})
  69. },
  70. search: function() {
  71. this.sam.navigateTo('/pages/common/search/search');
  72. },
  73. more: function(e) {
  74. let key = e.currentTarget.dataset.key || '';
  75. this.sam.navigateTo('/pages/goodsList/goodsList?keyword=' + key);
  76. },
  77. }
  78. };
  79. </script>
  80. <style>
  81. @import './diyapge.css';
  82. .diy-search {
  83. width: 100%;
  84. padding-top: 10rpx;
  85. padding-left: 20rpx;
  86. padding-right: 20rpx;
  87. box-sizing: border-box;
  88. align-items: center;
  89. }
  90. .tui-rolling-search {
  91. width: 100%;
  92. height: 60rpx;
  93. border-radius: 35rpx;
  94. padding: 0 40rpx 0 30rpx;
  95. box-sizing: border-box;
  96. background-color: #fff;
  97. display: flex;
  98. align-items: center;
  99. flex-wrap: nowrap;
  100. color: #999;
  101. }
  102. .tui-category {
  103. font-size: 24rpx;
  104. color: #fff;
  105. display: flex;
  106. align-items: center;
  107. justify-content: center;
  108. flex-direction: column;
  109. margin: 0;
  110. margin-right: 22rpx;
  111. flex-shrink: 0;
  112. }
  113. .tui-category-scale {
  114. transform: scale(0.7);
  115. line-height: 24rpx;
  116. }
  117. .tui-icon-category {
  118. line-height: 20px !important;
  119. margin-bottom: 0 !important;
  120. }
  121. .tui-swiper {
  122. font-size: 26rpx;
  123. height: 60rpx;
  124. flex: 1;
  125. padding-left: 12rpx;
  126. }
  127. .tui-swiper-item {
  128. display: flex;
  129. align-items: center;
  130. }
  131. .tui-hot-item {
  132. line-height: 26rpx;
  133. white-space: nowrap;
  134. overflow: hidden;
  135. text-overflow: ellipsis;
  136. }
  137. .tui-city-name {
  138. padding-left: 6rpx;
  139. padding-right: 0rpx;
  140. color: #333;
  141. font-size: 24rpx;
  142. line-height: 24rpx;
  143. }
  144. .tui-city-line {
  145. color: #d3d3d3;
  146. padding-left: 16rpx;
  147. padding-right: 20rpx;
  148. font-size: 24rpx;
  149. line-height: 24rpx;
  150. }
  151. .hot-keywords {
  152. z-index: 10;
  153. }
  154. .tui-hot-search {
  155. color: #fff;
  156. font-size: 26rpx;
  157. display: flex;
  158. align-items: center;
  159. justify-content: space-between;
  160. padding-top: 12rpx;
  161. padding-left: 8rpx;
  162. padding-right: 8rpx;
  163. padding-bottom: 12rpx;
  164. box-sizing: border-box;
  165. position: relative;
  166. z-index: 2;
  167. }
  168. .tui-not-hot-search {
  169. height: 20rpx;
  170. }
  171. .tui-hot-tag {
  172. display: flex;
  173. align-items: center;
  174. justify-content: center;
  175. line-height: 22rpx;
  176. }
  177. .tui-group-name {
  178. width: 100%;
  179. font-size: 34rpx;
  180. line-height: 34rpx;
  181. font-weight: bold;
  182. text-align: center;
  183. padding: 30rpx 0 20rpx;
  184. display: flex;
  185. align-items: center;
  186. justify-content: space-between;
  187. color: #333;
  188. }
  189. </style>