| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118 |
- <template>
- <MeScroll :up="up" :down="down" @up="upFn" :fixed="false" @down="downFn" @init="initMeScroll">
- <card :list="list" :current="type"></card>
- </MeScroll>
- </template>
- <script>
- import MeScroll from '@/components/mescroll-body/mescroll-uni.vue'
- import card from './card.vue'
- export default {
- components:{
- MeScroll,card
- },
- props: {
- refresh:false,
- type: Number,
- i: Number,
- item:Object
- },
- data() {
- return {
- isInit: false, // 是否初始化
- list: [], // 列表数据
- mescroll: null, // mescroll 对象
- // 上拉配置参数
- up: {
- noMoreSize: 5,
- auto: false,
- page: {
- page: 0,
- size: 10
- }
- },
- // 下拉配置参数
- down: {
- use: false,
- auto: false
- }
- }
- },
- created() {
-
- },
- watch:{
- type(val) {
- if(!this.isInit && val === this.i) {
- this.mescroll.resetUpScroll()
- }
- },
- refresh(val) {
- console.log(val);
- this.mescroll.resetUpScroll()
- }
- },
- mounted() {
- if(!this.isInit && this.i === 0) {
- this.mescroll.resetUpScroll()
- }
- },
- methods: {
- //初始化组件
- initMeScroll(mescroll) {
- this.mescroll = mescroll
- },
- //上拉回调
- async upFn(mescroll) {
- let res=null
- let params={
- current:mescroll.num,
- size:mescroll.size,
- }
- if (this.item.value==0) {
- //自己发起的活动
- params.launchId=this.vuex_mallId || '-1',
- params.launchType=this.$global.sponsorType.mall
- res=await this.$api.activity.list(params)
- }
- if (this.item.value==1) {
- //可参加的活动
- //该商场发布的活动或者该商场下的商户发布的活动
- params.mallId=this.vuex_mallId || '-1'
- params.launchId=this.vuex_mallId || '-1',
- params.launchType=this.$global.sponsorType.mall
- res=await this.$api.activity.getCanJoinActivity(params)
- }
- if (this.item.value==2) {
- // 已参加的活动
- params.joinId=this.vuex_mallId || '-1'
- params.joinType=this.$global.sponsorType.mall
- res=await this.$api.joinRecord.joined(params)
- }
- console.log(res);
- try{
- let data=res.data.records
- let length=data.length
- let total=res.data.total
- mescroll.endBySize(length, total);
- if(mescroll.num == 1) this.list = []; //如果是第一页需手动制空列表
- this.list=this.list.concat(data); //追加新数据
- }catch(e){
- mescroll.endErr();
- }
- },
- //下拉回调
- downFn(mescroll) {
- setTimeout(()=>{
- this.u.toast('刷新成功')
- this.mescroll.resetUpScroll()
- },1500)
- },
- }
- }
- </script>
- <style lang="scss" scoped>
- view{
- box-sizing: border-box;
- }
- </style>
|