123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106 |
- <template>
- <mescroll-body ref="mescrollRef" @init="mescrollInit" @down="downCallback" :up="upOption" @up="upCallback">
- <view class="item">
- <text class="tip">热门搜索:</text>
- <text class="hot-word" @click="doSearch('奶粉')">奶粉</text>
- <text class="hot-word" @click="doSearch('面霜')">面霜</text>
- <text class="hot-word" @click="doSearch('图书')">图书</text>
- </view>
- <view class="item">
- <text class="tip">关键词:</text>
- <input class="word-input" placeholder="请输入搜索关键词" v-model="curWord" @input="inputWord"/>
- </view>
- <good-list :list="goods"></good-list>
- </mescroll-body>
- </template>
- <script>
- import MescrollMixin from "@/components/mescroll-uni/mescroll-mixins.js";
- import {apiSearch} from "@/api/mock.js"
-
- export default {
- mixins: [MescrollMixin],
- data() {
- return {
- upOption: {
-
-
-
-
-
- noMoreSize: 3,
- empty: {
- tip: '~ 搜索无结果 ~'
- }
- },
- goods: [],
- curWord:""
- }
- },
- methods: {
-
- inputWord(e){
-
-
- this.searchTimer && clearTimeout(this.searchTimer)
- this.searchTimer = setTimeout(()=>{
- this.doSearch(this.curWord)
- },300)
- },
-
- doSearch(word){
- this.curWord = word
- this.goods = [];
- this.mescroll.resetUpScroll();
- },
-
- upCallback(page) {
-
- apiSearch(page.num, page.size, this.curWord).then(curPageData=>{
-
- this.mescroll.endSuccess(curPageData.length);
-
- if(page.num == 1) this.goods = [];
-
- this.goods=this.goods.concat(curPageData);
- }).catch(()=>{
-
- this.mescroll.endErr();
- })
- }
- }
- }
- </script>
- <style>
-
- .item{
- padding: 20rpx;
- }
- .tip{
- font-size: 30rpx;
- vertical-align: middle;
- }
- .hot-word{
- font-size: 24rpx;
- margin-left: 30rpx;
- padding: 6rpx 40rpx;
- border: 2rpx solid #FF6990;
- border-radius: 100rpx;
- vertical-align: middle;
- color: #FF6990;
- }
- .word-input{
- display: inline-block;
- width: 60%;
- height: 50rpx;
- line-height: 50rpx;
- font-size: 24rpx;
- margin-left: 30rpx;
- border: 2rpx solid #18B4FE;
- border-radius: 60rpx;
- text-align: center;
- background-color: #fff;
- vertical-align: middle;
- }
- </style>
|