productSearch.vue 8.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382
  1. <template>
  2. <view class="content">
  3. <view class="status_bar" :style="{height: statusBarHeight}"></view>
  4. <!-- 搜索框 -->
  5. <view class="search-cont">
  6. <image class="w64 h64" src="/static/images/back_black.png"></image>
  7. <view class="inner">
  8. <!-- <image class="icon-search" src="../../static/images/search.png" mode=""></image> -->
  9. <input type="text" value="" placeholder="城口腊肉/香肠" confirm-type="搜索" @confirm="goSearch"
  10. :focus='setFocus' placeholder-style="font-size:28rpx;color:#BBBBBB;font-family: PingFang SC;" />
  11. <view class="line"></view>
  12. <view class="search">搜索</view>
  13. </view>
  14. </view>
  15. <!-- 搜索历史 -->
  16. <!-- <view class="title-box">
  17. <text class="title">历史搜索</text>
  18. <image src="../../static/images/del.png" mode="" @click="clearHistory"></image>
  19. </view>
  20. <view class="data-list">
  21. <view class="item" v-for="(item,index) in searchHistory" :key="index" @click="doSearch(item)">
  22. {{ item }}
  23. </view>
  24. </view> -->
  25. <!-- 热门搜索 -->
  26. <view class="title-box">
  27. <text class="title">热门搜索</text>
  28. <image class="w32 h32" src="/static/images/delete_icon.png"></image>
  29. </view>
  30. <view class="popular-list">
  31. <view class="item" v-for="(item,index) in topSearch" :key="index" @click="doSearch(item)">
  32. {{ item }}
  33. </view>
  34. </view>
  35. <!-- 推荐搜索 -->
  36. <view class="title-box">
  37. <text class="title">大家都在搜</text>
  38. <image class="w32 h32" src="/static/images/refresh_icon.png"></image>
  39. </view>
  40. <view class="data-list">
  41. <view class="item" v-for="(item,index) in topSearch" :key="index" @click="doSearch(item)">
  42. <text> {{ item }}</text>
  43. <image class="w40 h40 ml8" src="/static/images/hot.png"></image>
  44. </view>
  45. </view>
  46. <scroll-view class="card-group" scroll-x="true" show-scrollbar="false" enhanced="true" enable-flex="true">
  47. <!-- 今日热卖榜 -->
  48. <view class="card border1">
  49. <image class="card-bg" src="/static/images/hot_selling.png"></image>
  50. <view class="card-title">
  51. <image class="w40 h40 ml8" src="/static/images/hot.png"></image>
  52. <text class="title1">今日热卖榜</text>
  53. </view>
  54. <view class="product-list">
  55. <view class="product-item">
  56. <view class="left">
  57. <image class="photo" src="/static/images/img.png"></image>
  58. <view class="lable">1</view>
  59. </view>
  60. <view class="right">
  61. <view class="title">乌灵胶囊81粒养心安神失乌灵胶囊81粒养心安神失眠乌灵胶囊81粒养心安神失眠眠健...</view>
  62. <view class="txt">肌肉酸疼、扭伤拉伤</view>
  63. <view class="num-box">
  64. <view class="price"><text class="symbol">¥</text><text class="bold">89</text>.48</view>
  65. <view class="sale">已售 5485</view>
  66. </view>
  67. </view>
  68. </view>
  69. </view>
  70. </view>
  71. <!-- 30天新品热销榜单 -->
  72. <view class="card ml24 border2">
  73. <image class="card-bg" src="/static/images/new_hot.png"></image>
  74. <view class="card-title">
  75. <image class="w40 h40 ml8" src="/static/images/new_product.png"></image>
  76. <text class="title1">30天新品热销榜单</text>
  77. </view>
  78. <view class="product-list">
  79. <view class="product-item">
  80. <view class="left">
  81. <image class="photo" src="/static/images/img.png"></image>
  82. <view class="lable">1</view>
  83. </view>
  84. <view class="right">
  85. <view class="title">乌灵胶囊81粒养心安神失乌灵胶囊81粒养心安神失眠乌灵胶囊81粒养心安神失眠眠健...</view>
  86. <view class="txt">肌肉酸疼、扭伤拉伤</view>
  87. <view class="num-box">
  88. <view class="price"><text class="symbol">¥</text><text class="bold">89</text>.48</view>
  89. <view class="sale">已售 5485</view>
  90. </view>
  91. </view>
  92. </view>
  93. </view>
  94. </view>
  95. </scroll-view>
  96. </view>
  97. </template>
  98. <script>
  99. export default {
  100. data() {
  101. return {
  102. // 状态栏的高度
  103. statusBarHeight: uni.getStorageSync('menuInfo').statusBarHeight,
  104. setFocus: false,
  105. // 历史搜索
  106. searchHistory: [],
  107. // 推荐搜索
  108. topSearch: []
  109. };
  110. },
  111. onShow() {
  112. this.setFocus = true
  113. this.searchHistory = this.utils.getHisSearch();
  114. var config = uni.getStorageSync('config');
  115. if (config != null && config != undefined && config != "") {
  116. this.topSearch = JSON.parse(config).hotSearch.split(',');
  117. }
  118. },
  119. methods: {
  120. // 清空历史搜索数据
  121. clearHistory() {
  122. this.utils.clearHisSearch();
  123. this.searchHistory = this.utils.getHisSearch();
  124. },
  125. doSearch(item) {
  126. uni.navigateTo({
  127. url: './productList?key=' + item
  128. })
  129. },
  130. goSearch(e) {
  131. if (e.detail.value != null && e.detail.value != "") {
  132. this.utils.addHisSearch(e.detail.value);
  133. }
  134. uni.navigateTo({
  135. url: './productList?key=' + e.detail.value
  136. })
  137. }
  138. }
  139. }
  140. </script>
  141. <style lang="scss">
  142. page {
  143. background-color: #ffffff;
  144. }
  145. .content {
  146. .search-cont {
  147. display: flex;
  148. padding: 16rpx 30rpx;
  149. background-color: #FFFFFF;
  150. .inner {
  151. box-sizing: border-box;
  152. width: 436rpx;
  153. height: 64rpx;
  154. background: #F5F7FA;
  155. border-radius: 36rpx;
  156. display: flex;
  157. align-items: center;
  158. padding: 0 24rpx;
  159. .search {
  160. font-weight: 500;
  161. font-size: 28rpx;
  162. color: #333333;
  163. }
  164. .line {
  165. width: 2rpx;
  166. height: 24rpx;
  167. background: #999999;
  168. margin: 0 26rpx;
  169. }
  170. input {
  171. height: 60rpx;
  172. line-height: 60rpx;
  173. flex: 1;
  174. }
  175. }
  176. }
  177. .title-box {
  178. padding: 30rpx;
  179. display: flex;
  180. align-items: center;
  181. justify-content: space-between;
  182. .title {
  183. font-weight: 600;
  184. font-size: 32rpx;
  185. color: #000000;
  186. }
  187. image {
  188. width: 30rpx;
  189. height: 30rpx;
  190. }
  191. }
  192. .data-list {
  193. padding: 0rpx 10rpx 30rpx;
  194. display: grid;
  195. grid-template-columns: repeat(2, 1fr);
  196. /* 两列布局 */
  197. grid-gap: 20rpx;
  198. .item {
  199. padding: 0 30rpx;
  200. height: 56rpx;
  201. line-height: 56rpx;
  202. font-size: 26rpx;
  203. font-family: PingFang SC;
  204. font-weight: 500;
  205. color: #4D4D4D;
  206. border-radius: 28rpx;
  207. margin: 0;
  208. display: flex;
  209. align-items: center;
  210. text-align: center;
  211. }
  212. }
  213. .popular-list {
  214. padding: 0rpx 10rpx 30rpx;
  215. display: flex;
  216. flex-wrap: wrap;
  217. .item {
  218. padding: 0 40rpx;
  219. height: 56rpx;
  220. line-height: 56rpx;
  221. font-size: 26rpx;
  222. font-family: PingFang SC;
  223. font-weight: 500;
  224. color: #4D4D4D;
  225. background: #F5F7FA;
  226. border-radius: 28rpx;
  227. margin: 0 20rpx 20rpx 0;
  228. }
  229. }
  230. .card-group {
  231. display: flex;
  232. padding: 0 24rpx;
  233. box-sizing: border-box;
  234. .card {
  235. width: 600rpx;
  236. padding: 26rpx 32rpx 0;
  237. background: #FFFFFF;
  238. border-radius: 24rpx 24rpx 24rpx 24rpx;
  239. position: relative;
  240. z-index: 0;
  241. .card-bg{
  242. width: 100%;
  243. height: 96rpx;
  244. position: absolute;
  245. top: 0;
  246. left: 0;
  247. border-radius: 24rpx 24rpx 0 0;
  248. z-index: -1;
  249. }
  250. .card-title {
  251. display: flex;
  252. align-items: center;
  253. font-weight: 600;
  254. font-size: 32rpx;
  255. margin-bottom: 34rpx;
  256. .title1 {
  257. color: #FF4400;
  258. }
  259. .title2 {
  260. color: #D46C0D;
  261. }
  262. }
  263. .product-list {
  264. .product-item {
  265. display: flex;
  266. align-items: center;
  267. margin-bottom: 40rpx;
  268. .left {
  269. margin-right: 22rpx;
  270. width: 120rpx;
  271. height: 120rpx;
  272. border-radius: 8rpx 8rpx 8rpx 8rpx;
  273. overflow: hidden;
  274. position: relative;
  275. .photo {
  276. width: 100%;
  277. height: 100%;
  278. }
  279. .lable {
  280. position: absolute;
  281. left: 0;
  282. top: 0;
  283. width: 32rpx;
  284. height: 32rpx;
  285. text-align: center;
  286. line-height: 32rpx;
  287. background: linear-gradient(135deg, #C1C5CD 0%, #A5AAB5 100%);
  288. border-radius: 8rpx 0rpx 8rpx 0rpx;
  289. font-family: Roboto, Roboto;
  290. font-weight: 500;
  291. font-size: 24rpx;
  292. color: #FFFFFF;
  293. }
  294. }
  295. .right {
  296. flex: 1;
  297. min-width: 0;
  298. .title {
  299. font-weight: 500;
  300. font-size: 28rpx;
  301. color: #333333;
  302. overflow: hidden;
  303. /* 隐藏溢出内容 */
  304. text-overflow: ellipsis;
  305. /* 显示省略号 */
  306. white-space: nowrap;
  307. /* 不换行 */
  308. }
  309. .txt {
  310. font-size: 22rpx;
  311. color: #999999;
  312. margin: 4rpx 0 20rpx;
  313. }
  314. .num-box {
  315. display: flex;
  316. justify-content: space-between;
  317. align-items: flex-end;
  318. .price {
  319. font-family: Roboto, Roboto;
  320. font-weight: 600;
  321. font-size: 26rpx;
  322. color: #FA341E;
  323. .symbol {
  324. font-size: 20rpx;
  325. }
  326. .bold {
  327. font-size: 36rpx;
  328. }
  329. }
  330. .sale {
  331. font-size: 21rpx;
  332. color: #999999;
  333. }
  334. }
  335. }
  336. }
  337. }
  338. }
  339. .border1{
  340. border: 1rpx solid rgba(241,89,38,0.5);
  341. }
  342. .border2{
  343. border: 1rpx solid rgba(244,160,7,0.5);
  344. }
  345. }
  346. }
  347. </style>