|
@@ -58,7 +58,13 @@
|
|
|
@click="onAddCart(item)"
|
|
@click="onAddCart(item)"
|
|
|
v-if="item.inCart == false"
|
|
v-if="item.inCart == false"
|
|
|
/>
|
|
/>
|
|
|
- <img :src="require('@assets/yijiaru@3x.png')" alt="" class="product-info_img" v-else />
|
|
|
|
|
|
|
+ <img
|
|
|
|
|
+ :src="require('@assets/yijiaru@3x.png')"
|
|
|
|
|
+ alt=""
|
|
|
|
|
+ class="product-info_img"
|
|
|
|
|
+ v-else
|
|
|
|
|
+ @click="onAddCart(item)"
|
|
|
|
|
+ />
|
|
|
</div>
|
|
</div>
|
|
|
</van-list>
|
|
</van-list>
|
|
|
</van-action-sheet>
|
|
</van-action-sheet>
|
|
@@ -143,7 +149,7 @@ export default {
|
|
|
.then(res => {
|
|
.then(res => {
|
|
|
this.$toast.success('恭喜加入购物车');
|
|
this.$toast.success('恭喜加入购物车');
|
|
|
this.$emit('fatherMethod');
|
|
this.$emit('fatherMethod');
|
|
|
- this.getData(true);
|
|
|
|
|
|
|
+ this.getDataOne(false, 0, true);
|
|
|
})
|
|
})
|
|
|
.catch(e => {
|
|
.catch(e => {
|
|
|
this.$toast(e.error);
|
|
this.$toast(e.error);
|
|
@@ -221,7 +227,7 @@ export default {
|
|
|
return '';
|
|
return '';
|
|
|
}
|
|
}
|
|
|
},
|
|
},
|
|
|
- getData(isFirst = false, scrollTop = 0) {
|
|
|
|
|
|
|
+ getDataOne(isFirst = false, scrollTop = 0, refresh = false) {
|
|
|
if (isFirst) {
|
|
if (isFirst) {
|
|
|
this.page = 0;
|
|
this.page = 0;
|
|
|
this.list = [];
|
|
this.list = [];
|
|
@@ -244,7 +250,13 @@ export default {
|
|
|
if (res.first) {
|
|
if (res.first) {
|
|
|
this.list = [];
|
|
this.list = [];
|
|
|
}
|
|
}
|
|
|
- this.list = [...this.list, ...res.content];
|
|
|
|
|
|
|
+ if (refresh) {
|
|
|
|
|
+ console.log('sdfsdsd');
|
|
|
|
|
+ this.list = [...this.list];
|
|
|
|
|
+ } else {
|
|
|
|
|
+ console.log('sdfsdsd11111');
|
|
|
|
|
+ this.list = [...this.list, ...res.content];
|
|
|
|
|
+ }
|
|
|
this.empty = res.empty;
|
|
this.empty = res.empty;
|
|
|
this.loading = false;
|
|
this.loading = false;
|
|
|
this.finished = res.last;
|
|
this.finished = res.last;
|
|
@@ -259,6 +271,69 @@ export default {
|
|
|
if (res.first) {
|
|
if (res.first) {
|
|
|
this.list = [];
|
|
this.list = [];
|
|
|
}
|
|
}
|
|
|
|
|
+ if (refresh) {
|
|
|
|
|
+ this.list = [...this.list];
|
|
|
|
|
+ } else {
|
|
|
|
|
+ this.list = [...this.list, ...res.content];
|
|
|
|
|
+ }
|
|
|
|
|
+ this.empty = res.empty;
|
|
|
|
|
+ this.loading = false;
|
|
|
|
|
+ this.finished = res.last;
|
|
|
|
|
+ if (!this.finished) {
|
|
|
|
|
+ this.page = this.page + 1;
|
|
|
|
|
+ }
|
|
|
|
|
+ this.totalElements = Number(res.totalElements);
|
|
|
|
|
+ return Promise.resolve(Number(res.totalElements));
|
|
|
|
|
+ });
|
|
|
|
|
+ }
|
|
|
|
|
+ },
|
|
|
|
|
+ getData(isFirst = false, scrollTop = 0, refresh = false) {
|
|
|
|
|
+ if (isFirst) {
|
|
|
|
|
+ this.page = 0;
|
|
|
|
|
+ this.list = [];
|
|
|
|
|
+ this.$root.$el.scrollTop = scrollTop;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ this.loading = true;
|
|
|
|
|
+ this.finished = false;
|
|
|
|
|
+ this.empty = false;
|
|
|
|
|
+ let data = { page: this.page, size: 20, sort: 'createdAt,desc' };
|
|
|
|
|
+ if (this.beforeData) {
|
|
|
|
|
+ data = {
|
|
|
|
|
+ ...data,
|
|
|
|
|
+ ...this.beforeData()
|
|
|
|
|
+ };
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ if (this.httpType === 'get') {
|
|
|
|
|
+ return this.$http.get(this.url, data, { body: 'json' }).then(res => {
|
|
|
|
|
+ if (res.first) {
|
|
|
|
|
+ this.list = [];
|
|
|
|
|
+ }
|
|
|
|
|
+ if (refresh) {
|
|
|
|
|
+ this.list = [...this.list];
|
|
|
|
|
+ } else {
|
|
|
|
|
+ this.list = [...this.list, ...res.content];
|
|
|
|
|
+ }
|
|
|
|
|
+ this.empty = res.empty;
|
|
|
|
|
+ this.loading = false;
|
|
|
|
|
+ this.finished = res.last;
|
|
|
|
|
+ if (!this.finished) {
|
|
|
|
|
+ this.page = this.page + 1;
|
|
|
|
|
+ }
|
|
|
|
|
+ this.totalElements = Number(res.totalElements);
|
|
|
|
|
+ return Promise.resolve(Number(res.totalElements));
|
|
|
|
|
+ });
|
|
|
|
|
+ } else {
|
|
|
|
|
+ return this.$http.post(this.url, data, { body: 'json' }).then(res => {
|
|
|
|
|
+ if (res.first) {
|
|
|
|
|
+ this.list = [];
|
|
|
|
|
+ }
|
|
|
|
|
+ if (refresh) {
|
|
|
|
|
+ this.list = [...this.list];
|
|
|
|
|
+ } else {
|
|
|
|
|
+ this.list = [...this.list, ...res.content];
|
|
|
|
|
+ }
|
|
|
this.list = [...this.list, ...res.content];
|
|
this.list = [...this.list, ...res.content];
|
|
|
this.empty = res.empty;
|
|
this.empty = res.empty;
|
|
|
this.loading = false;
|
|
this.loading = false;
|