MrShi
8 小时以前 63820a55496e99f54d68a1f16e3f6f606c582120
mini-program/pages/search/search.vue
@@ -4,10 +4,10 @@
         <u-search placeholder="请输入商品名称搜索" height="36" searchIconColor="#999999" borderColor="#EEEEEE"
            bgColor="#F9F9FB" :showAction="false" v-model="goodsName" @search="search" />
      </view>
      <view class="history">
      <view class="history" v-if="historyList && historyList.length > 0">
         <view class="history-title">历史搜索</view>
         <view class="history-list">
            <view class="history-list-item">支重轮</view>
            <view class="history-list-item" v-for="(item, index) in historyList" :key="index">{{item.content}}</view>
         </view>
      </view>
      <template v-if="isSearch">
@@ -42,20 +42,39 @@
</template>
<script>
   import { mapState } from 'vuex'
   export default {
      computed: {
         ...mapState(['userInfo'])
      },
      data() {
         return {
            goodsName: '',
            goodsList: [],
            page: 1,
            next: true,
            isSearch: false
            isSearch: false,
            historyList: []
         };
      },
      onLoad() {
         this.gethistary()
      },
      onReachBottom() {
         this.getGoodsList()
      },
      methods: {
         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
               }
            })
         },
         search() {
            if (!this.isSearch) {
               this.isSearch = true