1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889 |
- <template>
- <view>
-
- <view class="top-warp">
- <view class="tip">每次切换菜单及时刷新列表,不缓存数据</view>
- <me-tabs v-model="tabIndex" :tabs="tabs" @change="tabChange"></me-tabs>
- </view>
-
-
- <mescroll-body ref="mescrollRef" @init="mescrollInit" top="120" @down="downCallback" :up="upOption" @up="upCallback" @emptyclick="emptyClick">
-
- <good-list :list="goods"></good-list>
- </mescroll-body>
- </view>
- </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: 4,
- empty:{
- tip: '~ 搜索无数据 ~',
- btnText: '去看看'
- }
- },
- goods: [],
- tabs: ['全部', '奶粉', '面膜', '图书'],
- tabIndex: 0
- }
- },
- methods: {
-
- upCallback(page) {
-
- let keyword = this.tabs[this.tabIndex]
- apiSearch(page.num, page.size, keyword).then(curPageData=>{
-
- this.mescroll.endSuccess(curPageData.length);
-
- if(page.num == 1) this.goods = [];
- this.goods=this.goods.concat(curPageData);
- }).catch(()=>{
-
- this.mescroll.endErr();
- })
- },
-
- emptyClick(){
- uni.showToast({
- title:'点击了按钮,具体逻辑自行实现'
- })
- },
-
-
- tabChange() {
- this.goods = []
- this.mescroll.resetUpScroll()
- }
- }
- }
- </script>
- <style>
- .top-warp{
- z-index: 9990;
- position: fixed;
- top: --window-top;
- left: 0;
- width: 100%;
- height: 120upx;
- background-color: white;
- }
- .top-warp .tip{
- font-size: 28upx;
- height: 60upx;
- line-height: 60upx;
- text-align: center;
- }
- </style>
|