123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191 |
- <template>
- <mescroll-body ref="mescrollRef" @init="mescrollInit" @down="downCallback" @up="upCallback"
- :down="downOption"
- :up="upOption"
- :top="0"
- :bottom="0"
- :topbar="false"
- :bottombar="true"
- :fixed="true"
- height="100%"
- :safearea="false"
- @emptyclick="emptyClick"
- @topclick="topClick"
- @scroll="scroll">
-
- <view class="tip">展示down和up的所有配置项</view>
- <view class="tip" @click="triggerDownScroll">点此主动触发下拉刷新</view>
- <view class="tip" @click="scrollToY(200)">点此测试滚动到指定位置 (如: 200px)</view>
-
- <view class="tip" @click="scrollIntoView('#anchorPoint')" id="anchorPoint">点此测试滚动到指定view (元素在本页)</view>
-
- <view class="tip" @click="scrollIntoView('.good-comp >>> #good2')">点此测试滚动到指定view (元素在子组件)</view>
-
-
- <me-tabs v-model="tabIndex" :tabs="tabs" @change="tabChange"></me-tabs>
-
-
-
- <me-video v-if="tabIndex==0" :mescroll="mescroll" poster="https://vkceyugu.cdn.bspapp.com/VKCEYUGU-mescroll/2e3cd7a0-f31a-11ea-81ea-f115fe74321c.png" src="https://vkceyugu.cdn.bspapp.com/VKCEYUGU-mescroll/2ae5d090-f26e-11ea-81ea-f115fe74321c.mp4"></me-video>
-
-
- <good-list class="good-comp" :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 {
- downOption: {
- use: true,
- auto: true,
- native: false,
- autoShowLoading: false,
- isLock: false,
- offset: 80,
- inOffsetRate: 1,
- outOffsetRate: 0.2,
- bottomOffset: 20,
- minAngle: 45,
- bgColor: "#E75A7C",
- textColor: "#fff",
- textInOffset: '下拉刷新',
- textOutOffset: '释放更新',
- textLoading: '加载中 ...'
- },
- upOption: {
- use: true,
- auto: true,
- isLock: false,
- isBoth: true,
- page: {
- num: 0,
- size: 10,
- time: null
- },
- noMoreSize: 3,
- offset: 80,
- bgColor: "transparent",
- textColor: "gray",
- textLoading: '加载中 ...',
- textNoMore: '-- END --',
- toTop: {
-
- src: "https://www.mescroll.com/img/mescroll-totop.png",
- offset: 1000,
- duration: 300,
- zIndex: 9990,
- left: null,
- right: 20,
- bottom: 120,
- safearea: false,
- width: 72,
- radius: "50%"
- },
- empty: {
- use: true,
- icon: "https://www.mescroll.com/img/mescroll-empty.png",
- tip: '~ 暂无相关数据 ~',
- btnText: '去逛逛 >',
- fixed: false,
- top: "100rpx",
- zIndex: 99
- },
- onScroll: true
- },
- goods: [],
- tabs: ['全部', '奶粉', '图书'],
- tabIndex: 0
- }
- },
- methods: {
-
- downCallback() {
-
-
-
- this.mescroll.resetUpScroll()
- },
-
- 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:"点击了按钮"
- })
- },
-
- topClick(){
- console.log('点击了回到顶部按钮');
- },
-
- scroll(){
- console.log('mescroll元素id: '+this.mescroll.viewId+' , 滚动内容高度:'+this.mescroll.getScrollHeight() + ', mescroll高度:'+this.mescroll.getClientHeight() + ', 滚动条位置:'+this.mescroll.getScrollTop() + ', 距离底部:'+this.mescroll.getScrollBottom() + ', 是否向上滑:'+this.mescroll.isScrollUp)
- },
-
- tabChange() {
- this.goods = []
- this.mescroll.resetUpScroll()
- },
-
- triggerDownScroll(){
- this.mescroll.triggerDownScroll()
- },
-
- scrollToY(y){
-
- this.mescroll.scrollTo(y, 0)
- },
-
- scrollIntoView(viewId){
-
- this.mescroll.scrollTo(viewId, 0)
- }
- },
-
-
-
-
- }
- </script>
- <style>
- .tip{
- font-size: 28upx;
- height: 60upx;
- line-height: 60upx;
- text-align: center;
- }
- </style>
|