小程序端工程代码
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

77 lines
2.0 KiB

  1. <template>
  2. <view>
  3. <view class="searchGood">
  4. <view class="search acea-row row-between-wrapper">
  5. <view class="input acea-row row-between-wrapper">
  6. <text class="iconfont icon-sousuo2"></text>
  7. <!-- <form @submit.prevent="submit"></form> -->
  8. <input type="text" placeholder="点击搜索商品" v-model="search" />
  9. </view>
  10. <view class="bnt" @click="submit">搜索</view>
  11. </view>
  12. <view v-if="keywords.length">
  13. <view class="title">热门搜索</view>
  14. <view class="list acea-row">
  15. <view
  16. class="item"
  17. v-for="keywordsKey of keywords"
  18. :key="keywordsKey"
  19. @click="toSearch(keywordsKey)"
  20. >{{ keywordsKey }}</view>
  21. </view>
  22. </view>
  23. <view class="line"></view>
  24. <!-- <GoodList></GoodList>-->
  25. </view>
  26. <!--<view class="noCommodity">-->
  27. <!--<view class="noPictrue">-->
  28. <!--<image :src="`${$VUE_APP_RESOURCES_URL}/images/noSearch.png`" class="image" />-->
  29. <!--</view>-->
  30. <!--<recommend></recommend>-->
  31. <!--</view>-->
  32. </view>
  33. </template>
  34. <script>
  35. // import GoodList from "@/components/GoodList";
  36. import { getSearchKeyword } from "@/api/store";
  37. import { trim } from "@/utils";
  38. // import Recommend from "@/components/Recommend";
  39. export default {
  40. name: "GoodSearch",
  41. components: {
  42. // Recommend,
  43. // GoodList
  44. },
  45. props: {},
  46. data: function() {
  47. return {
  48. keywords: [],
  49. search: ""
  50. };
  51. },
  52. mounted: function() {
  53. this.getData();
  54. },
  55. methods: {
  56. submit() {
  57. const search = trim(this.search) || "";
  58. if (!search) return;
  59. this.toSearch(search);
  60. },
  61. toSearch(s) {
  62. this.$yrouter.push({ path: "/pages/shop/GoodsList/index", query: { s } });
  63. },
  64. getData() {
  65. getSearchKeyword().then(res => {
  66. this.keywords = res.data;
  67. });
  68. }
  69. }
  70. };
  71. </script>
  72. <style >
  73. .noCommodity {
  74. border-top: 0.05*100rpx solid #f5f5f5;
  75. }
  76. </style>