|
|
@@ -72,7 +72,7 @@
|
|
72
|
72
|
</view>
|
|
73
|
73
|
</view>
|
|
74
|
74
|
|
|
75
|
|
- <scroll-view class="goods-list" scroll-y @scrolltolower="handleLoadMore" @scroll="handleScroll" :scroll-top="pageState.scrollTop" enable-back-to-top>
|
|
|
75
|
+ <scroll-view ref="scrollView" class="goods-list" scroll-y @scrolltolower="handleLoadMore" @scroll="handleScroll" enable-back-to-top>
|
|
76
|
76
|
<view @click.stop="clickItem(goods)" class="goods-item" v-for="(goods, goodsIndex) in goodsList"
|
|
77
|
77
|
:key="`goods-${goodsIndex}`">
|
|
78
|
78
|
<u-swipe-action ref="swipeRef">
|
|
|
@@ -419,16 +419,28 @@ export default {
|
|
419
|
419
|
this.pageState.total = this.total;
|
|
420
|
420
|
},
|
|
421
|
421
|
// 恢复页面状态
|
|
422
|
|
- restorePageState() {
|
|
423
|
|
- if (this.pageState.goodsList.length > 0) {
|
|
424
|
|
- this.pageNum = this.pageState.pageNum;
|
|
425
|
|
- this.goodsList = [...this.pageState.goodsList];
|
|
426
|
|
- this.total = this.pageState.total;
|
|
427
|
|
- // 滚动位置会通过scroll-top属性自动恢复
|
|
428
|
|
- return true;
|
|
429
|
|
- }
|
|
430
|
|
- return false;
|
|
431
|
|
- },
|
|
|
422
|
+ restorePageState() {
|
|
|
423
|
+ if (this.pageState.goodsList.length > 0) {
|
|
|
424
|
+ this.pageNum = this.pageState.pageNum;
|
|
|
425
|
+ this.goodsList = [...this.pageState.goodsList];
|
|
|
426
|
+ this.total = this.pageState.total;
|
|
|
427
|
+ this.$nextTick(() => {
|
|
|
428
|
+ if (this.pageState.scrollTop > 0) {
|
|
|
429
|
+ if (this.$refs.scrollView) {
|
|
|
430
|
+ setTimeout(() => {
|
|
|
431
|
+ try {
|
|
|
432
|
+ this.$refs.scrollView.$el.scrollTop = this.pageState.scrollTop;
|
|
|
433
|
+ } catch (e) {
|
|
|
434
|
+ console.log('设置滚动位置失败:', e);
|
|
|
435
|
+ }
|
|
|
436
|
+ }, 100);
|
|
|
437
|
+ }
|
|
|
438
|
+ }
|
|
|
439
|
+ });
|
|
|
440
|
+ return true;
|
|
|
441
|
+ }
|
|
|
442
|
+ return false;
|
|
|
443
|
+ },
|
|
432
|
444
|
},
|
|
433
|
445
|
onShow() {
|
|
434
|
446
|
// 尝试恢复页面状态
|