chore[litemall-vue]: 删除无用的mixin
This commit is contained in:
@@ -1,22 +0,0 @@
|
||||
export default {
|
||||
props: {
|
||||
goods: {
|
||||
type: Object,
|
||||
default: () => ({})
|
||||
}
|
||||
},
|
||||
|
||||
computed: {
|
||||
goodsStatusToMe() {
|
||||
const is_buy = this.goods.is_buy;
|
||||
const is_collect = this.goods.is_collect;
|
||||
return is_buy ? '我购买过' : is_collect ? '我收藏过' : '';
|
||||
}
|
||||
},
|
||||
|
||||
methods: {
|
||||
OnClick() {
|
||||
this.$emit('click');
|
||||
}
|
||||
}
|
||||
};
|
||||
@@ -1,70 +0,0 @@
|
||||
export default {
|
||||
data() {
|
||||
return {
|
||||
pages: {
|
||||
perPage: 8,
|
||||
currPage: 1,
|
||||
pageCount: 1
|
||||
},
|
||||
items: [],
|
||||
loading: false,
|
||||
finished: false,
|
||||
isEmpty: false
|
||||
};
|
||||
},
|
||||
|
||||
methods: {
|
||||
async resetInit() {
|
||||
this.resetData();
|
||||
// debugger;
|
||||
const page = await this.initData();
|
||||
this.$nextTick(() => {
|
||||
this.setPages(page);
|
||||
});
|
||||
},
|
||||
isFinished() {
|
||||
this.finished = true;
|
||||
this.loading = false;
|
||||
},
|
||||
async loadMore() {
|
||||
console.log('loadmore');
|
||||
const vm = this;
|
||||
if (vm.pages.pageCount < vm.pages.currPage) {
|
||||
vm.$toast({
|
||||
message: '没有更多了~',
|
||||
position: 'top'
|
||||
});
|
||||
vm.isFinished();
|
||||
} else {
|
||||
const page = await vm.initData(true);
|
||||
vm.nextPage(page.pageCount);
|
||||
}
|
||||
vm.loading = false;
|
||||
},
|
||||
nextPage(pageCount = 1) {
|
||||
this.pages.currPage += 1;
|
||||
this.pages.pageCount = pageCount;
|
||||
},
|
||||
setPages(page = {}) {
|
||||
this.isEmpty = page.totalCount === 0;
|
||||
if (page.totalCount <= this.pages.perPage) {
|
||||
// 不满一页
|
||||
this.isFinished();
|
||||
} else {
|
||||
// 下一页
|
||||
this.nextPage(page.pageCount);
|
||||
}
|
||||
},
|
||||
resetData() {
|
||||
this.items = [];
|
||||
this.pages = {
|
||||
perPage: 8,
|
||||
currPage: 1,
|
||||
pageCount: 1
|
||||
};
|
||||
this.loading = false;
|
||||
this.finished = false;
|
||||
this.isEmpty = false;
|
||||
}
|
||||
}
|
||||
};
|
||||
@@ -1,66 +0,0 @@
|
||||
export default {
|
||||
data() {
|
||||
return {
|
||||
pages: {
|
||||
perPage: 8,
|
||||
currPage: 1,
|
||||
pageCount: 1
|
||||
},
|
||||
loading: false,
|
||||
finished: false,
|
||||
isEmpty: false
|
||||
};
|
||||
},
|
||||
|
||||
methods: {
|
||||
async resetInit() {
|
||||
this.resetData();
|
||||
const page = await this.initData();
|
||||
this.$nextTick(() => {
|
||||
this.setPages(page);
|
||||
});
|
||||
},
|
||||
isFinished() {
|
||||
this.finished = true;
|
||||
this.loading = false;
|
||||
},
|
||||
async loadMore() {
|
||||
console.log('loadmore');
|
||||
const {
|
||||
pages: { pageCount, currPage }
|
||||
} = this;
|
||||
const finish = pageCount < currPage;
|
||||
if (finish) {
|
||||
this.isFinished();
|
||||
} else {
|
||||
this.setPages(await this.initData(true));
|
||||
}
|
||||
this.loading = false;
|
||||
},
|
||||
nextPage(pageCount = 1) {
|
||||
this.pages.currPage += 1;
|
||||
this.pages.pageCount = pageCount;
|
||||
this.loading = false;
|
||||
},
|
||||
setPages(page = {}) {
|
||||
this.isEmpty = page.totalCount === 0;
|
||||
if (page.totalCount <= this.pages.perPage) {
|
||||
// 不满一页
|
||||
this.isFinished();
|
||||
} else {
|
||||
// 下一页
|
||||
this.nextPage(page.pageCount);
|
||||
}
|
||||
},
|
||||
resetData() {
|
||||
this.pages = {
|
||||
perPage: 8,
|
||||
currPage: 1,
|
||||
pageCount: 1
|
||||
};
|
||||
this.loading = true;
|
||||
this.finished = false;
|
||||
this.isEmpty = false;
|
||||
}
|
||||
}
|
||||
};
|
||||
@@ -113,7 +113,6 @@
|
||||
|
||||
<script>
|
||||
import { getHome, goodsCategory, couponReceive } from '@/api/api';
|
||||
import loadMore from '@/mixin/list-load-more';
|
||||
import scrollFixed from '@/mixin/scroll-fixed';
|
||||
import _ from 'lodash';
|
||||
|
||||
@@ -135,7 +134,7 @@ import {
|
||||
} from 'vant';
|
||||
|
||||
export default {
|
||||
mixins: [loadMore, scrollFixed],
|
||||
mixins: [scrollFixed],
|
||||
|
||||
data() {
|
||||
return {
|
||||
@@ -180,7 +179,6 @@ export default {
|
||||
},
|
||||
|
||||
components: {
|
||||
// Vue.use(Tabbar).use(TabbarItem);,
|
||||
[Row.name]: Row,
|
||||
[Col.name]: Col,
|
||||
[Card.name]: Card,
|
||||
|
||||
@@ -3,9 +3,9 @@
|
||||
<van-list v-model="loading"
|
||||
:finished="finished"
|
||||
:immediate-check="false"
|
||||
:offset="100"
|
||||
@load="loadMore">
|
||||
<van-card v-for="(item, i) in items"
|
||||
finished-text="没有更多了"
|
||||
@load="getCollectList">
|
||||
<van-card v-for="(item, i) in list"
|
||||
:key="i"
|
||||
:desc="item.brief"
|
||||
:title="item.name"
|
||||
@@ -21,29 +21,27 @@
|
||||
</van-card>
|
||||
</van-list>
|
||||
|
||||
<is-empty v-if="items.length === 0">没有商品收藏</is-empty>
|
||||
<is-empty v-if="list.length === 0">没有商品收藏</is-empty>
|
||||
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import { collectList, collectAddOrDelete } from '@/api/api';
|
||||
|
||||
import IsEmpty from '@/components/is-empty/';
|
||||
import { Card, Search, List } from 'vant';
|
||||
|
||||
import loadMore from '@/mixin/list-load-more';
|
||||
import scrollFixed from '@/mixin/scroll-fixed';
|
||||
|
||||
export default {
|
||||
mixins: [loadMore, scrollFixed],
|
||||
mixins: [scrollFixed],
|
||||
|
||||
data() {
|
||||
return {
|
||||
page: 1,
|
||||
list: [],
|
||||
page: 0,
|
||||
limit: 10,
|
||||
total: 0,
|
||||
items: []
|
||||
loading: false,
|
||||
finished: false
|
||||
};
|
||||
},
|
||||
|
||||
@@ -53,17 +51,22 @@ export default {
|
||||
|
||||
methods: {
|
||||
init() {
|
||||
this.page = 0;
|
||||
this.list = [];
|
||||
this.getCollectList()
|
||||
},
|
||||
getCollectList() {
|
||||
this.page++;
|
||||
collectList({ type: 0, page: this.page, limit: this.limit }).then(res => {
|
||||
this.page = res.data.data.page;
|
||||
this.limit = res.data.data.limit;
|
||||
this.total = res.data.data.total;
|
||||
this.items.push(...res.data.data.list);
|
||||
this.list.push(...res.data.data.list);
|
||||
this.loading = false;
|
||||
this.finished = res.data.data.page >= res.data.data.pages;
|
||||
});
|
||||
},
|
||||
cancelCollect(event, i, item) {
|
||||
this.$dialog.confirm({ message: '是否取消收藏该商品' }).then(() => {
|
||||
collectAddOrDelete({ valueId: item.valueId, type: 0 }).then(res => {
|
||||
this.items.splice(i, 1);
|
||||
this.list.splice(i, 1);
|
||||
});
|
||||
});
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user