| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120 |
- <template>
- <MeScroll :up="up" :down="down" @up="upFn" :fixed="false" @down="downFn" @init="initMeScroll">
- <u-toast ref="uToast" />
- <card @confirm="confirm" :list="list"></card>
- </MeScroll>
- </template>
- <script>
- import MeScroll from '@/components/mescroll-body/mescroll-uni.vue'
- import card from './card.vue'
- export default {
- components: {
- MeScroll,
- card
- },
- props: {
- type: Number,
- i: Number,
- item: Object
- },
- data() {
- return {
- userId: '',
- isInit: false, // 是否初始化
- list: [], // 列表数据
- mescroll: null, // mescroll 对象
- // 上拉配置参数
- up: {
- noMoreSize: 3,
- auto: false,
- page: {
- page: 0,
- size: 10
- }
- },
- // 下拉配置参数
- down: {
- use: false,
- auto: false
- }
- }
- },
- created() {
- this.userId = uni.getStorageSync("userId");
- },
- watch: {
- type(val) {
- if (!this.isInit && val === this.i) {
- this.mescroll.resetUpScroll()
- }
- }
- },
- mounted() {
- if (!this.isInit && this.i === 0) {
- this.mescroll.resetUpScroll()
- }
- },
- methods: {
- confirm(item){
- this.$dialog.showModal("确认收货?").then(res=>{
- let data=this.$u.deepClone(item)
- data.pointsGoodsStatus=2
- this.$u.api.pointsGoods.mineGoodsListSubmit(data).then(res=>{
- this.$u.toast('操作成功')
- this.mescroll.resetUpScroll()
- })
- })
- },
- /**
- * @param {Object} mescroll 初始化组件
- */
- initMeScroll(mescroll) {
- this.mescroll = mescroll
- },
- /**
- * @param {Object} mescroll 上拉回调
- */
- upFn(mescroll) {
- if (!this.userId) {
- this.$u.toast('用户未登录')
- mescroll.endErr();
- return
- }
- let that = this
- let obj = {
- userId: this.userId,
- current: mescroll.num,
- size: mescroll.size,
- pointsGoodsStatus:this.item.value
- }
- try {
- this.$u.api.pointsGoods.mineGoodsList(obj).then(res => {
- let data = res.records
- let length = data.length
- let total = res.total
- mescroll.endBySize(length, total);
- if (mescroll.num == 1) that.list = []; //如果是第一页需手动制空列表
- that.list = that.list.concat(data); //追加新数据
- })
- } catch (e) {
- mescroll.endErr();
- }
- },
- /**
- * 下拉回调
- * */
- downFn(mescroll) {
- setTimeout(() => {
- this.$showToast('刷新成功')
- this.mescroll.resetUpScroll()
- }, 1500)
- },
- }
- }
- </script>
- <style lang="scss" scoped>
- view {
- box-sizing: border-box;
- }
- </style>
|