Commit d10eeb94 authored by Junling Bu's avatar Junling Bu
Browse files

chore[litemall-vue]: 删除无用的mixin

parent c0d141a6
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');
}
}
};
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;
}
}
};
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 @@ ...@@ -113,7 +113,6 @@
<script> <script>
import { getHome, goodsCategory, couponReceive } from '@/api/api'; import { getHome, goodsCategory, couponReceive } from '@/api/api';
import loadMore from '@/mixin/list-load-more';
import scrollFixed from '@/mixin/scroll-fixed'; import scrollFixed from '@/mixin/scroll-fixed';
import _ from 'lodash'; import _ from 'lodash';
...@@ -135,7 +134,7 @@ import { ...@@ -135,7 +134,7 @@ import {
} from 'vant'; } from 'vant';
export default { export default {
mixins: [loadMore, scrollFixed], mixins: [scrollFixed],
data() { data() {
return { return {
...@@ -180,7 +179,6 @@ export default { ...@@ -180,7 +179,6 @@ export default {
}, },
components: { components: {
// Vue.use(Tabbar).use(TabbarItem);,
[Row.name]: Row, [Row.name]: Row,
[Col.name]: Col, [Col.name]: Col,
[Card.name]: Card, [Card.name]: Card,
......
...@@ -3,9 +3,9 @@ ...@@ -3,9 +3,9 @@
<van-list v-model="loading" <van-list v-model="loading"
:finished="finished" :finished="finished"
:immediate-check="false" :immediate-check="false"
:offset="100" finished-text="没有更多了"
@load="loadMore"> @load="getCollectList">
<van-card v-for="(item, i) in items" <van-card v-for="(item, i) in list"
:key="i" :key="i"
:desc="item.brief" :desc="item.brief"
:title="item.name" :title="item.name"
...@@ -21,29 +21,27 @@ ...@@ -21,29 +21,27 @@
</van-card> </van-card>
</van-list> </van-list>
<is-empty v-if="items.length === 0">没有商品收藏</is-empty> <is-empty v-if="list.length === 0">没有商品收藏</is-empty>
</div> </div>
</template> </template>
<script> <script>
import { collectList, collectAddOrDelete } from '@/api/api'; import { collectList, collectAddOrDelete } from '@/api/api';
import IsEmpty from '@/components/is-empty/'; import IsEmpty from '@/components/is-empty/';
import { Card, Search, List } from 'vant'; import { Card, Search, List } from 'vant';
import loadMore from '@/mixin/list-load-more';
import scrollFixed from '@/mixin/scroll-fixed'; import scrollFixed from '@/mixin/scroll-fixed';
export default { export default {
mixins: [loadMore, scrollFixed], mixins: [scrollFixed],
data() { data() {
return { return {
page: 1, list: [],
page: 0,
limit: 10, limit: 10,
total: 0, loading: false,
items: [] finished: false
}; };
}, },
...@@ -53,17 +51,22 @@ export default { ...@@ -53,17 +51,22 @@ export default {
methods: { methods: {
init() { init() {
this.page = 0;
this.list = [];
this.getCollectList()
},
getCollectList() {
this.page++;
collectList({ type: 0, page: this.page, limit: this.limit }).then(res => { collectList({ type: 0, page: this.page, limit: this.limit }).then(res => {
this.page = res.data.data.page; this.list.push(...res.data.data.list);
this.limit = res.data.data.limit; this.loading = false;
this.total = res.data.data.total; this.finished = res.data.data.page >= res.data.data.pages;
this.items.push(...res.data.data.list);
}); });
}, },
cancelCollect(event, i, item) { cancelCollect(event, i, item) {
this.$dialog.confirm({ message: '是否取消收藏该商品' }).then(() => { this.$dialog.confirm({ message: '是否取消收藏该商品' }).then(() => {
collectAddOrDelete({ valueId: item.valueId, type: 0 }).then(res => { collectAddOrDelete({ valueId: item.valueId, type: 0 }).then(res => {
this.items.splice(i, 1); this.list.splice(i, 1);
}); });
}); });
}, },
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment