MrShi
12 小时以前 62b483cc627b0a5f7d626d6b333a3ef7c7c1f4f4
mini-program/pages/search/search.vue
@@ -7,7 +7,7 @@
      <view class="history" v-if="historyList && historyList.length > 0">
         <view class="history-title">历史搜索</view>
         <view class="history-list">
            <view class="history-list-item" v-for="(item, index) in historyList" :key="index">{{item.content}}</view>
            <view class="history-list-item" v-for="(item, index) in historyList" :key="index" @click="seleContent(item.content)">{{item.content}}</view>
         </view>
      </view>
      <template v-if="isSearch">
@@ -54,23 +54,38 @@
            page: 1,
            next: true,
            isSearch: false,
            historyList: []
            historyList: [],
            categoryId: null,
            applicableBrandId: null
         };
      },
      onLoad() {
      onLoad(option) {
         if (option.categoryId) {
            this.categoryId = option.categoryId
            this.isSearch = true
            this.getGoodsList()
         }
         if (option.applicableBrandId) {
            this.applicableBrandId = option.applicableBrandId
            this.isSearch = true
            this.getGoodsList()
         }
         this.gethistary()
      },
      onReachBottom() {
         this.getGoodsList()
      },
      methods: {
         seleContent(val) {
            this.goodsName = val
            this.search()
         },
         gethistary() {
            if (!this.userInfo) return
            this.$u.api.searchHistoryList({
               memberId: this.userInfo.id
            }).then(res => {
               if (res.code === 200) {
                  console.log(res)
                  this.historyList = res.data
               }
            })
@@ -92,10 +107,14 @@
               model: {
                  type: 0,
                  sortInfo: 3,
                  goodsName: this.goodsName
                  goodsName: this.goodsName,
                  memberId: this.userInfo.id,
                  categoryId: this.categoryId,
                  applicableBrandId: this.applicableBrandId
               }
            }).then(res => {
               if (res.code === 200) {
                  this.gethistary()
                  res.data.records.forEach(item => {
                     item.minPrice = item.minPrice.toFixed(2).split('.')
                  })
@@ -111,6 +130,11 @@
   }
</script>
<style>
   page {
      background-color: #F9F9FB;
   }
</style>
<style lang="scss" scoped>
   .box {
      width: 100%;
@@ -152,7 +176,7 @@
               margin-right: 24rpx;
               margin-bottom: 24rpx;
               &:last-child {
                  margin: 0 !important;
                  margin-right: 0 !important;
               }
            }
         }