|
|
@ -61,7 +61,7 @@ const currentType = ref(0); |
|
|
*/ |
|
|
*/ |
|
|
const bottomHeight = ref(0); |
|
|
const bottomHeight = ref(0); |
|
|
/** |
|
|
/** |
|
|
* 右侧商品列表的滚动高度 |
|
|
|
|
|
|
|
|
* 右侧商品列表的滚动高度 FIXME: 无法生效 |
|
|
*/ |
|
|
*/ |
|
|
const scrollTop = ref(0); |
|
|
const scrollTop = ref(0); |
|
|
/** |
|
|
/** |
|
|
@ -398,9 +398,13 @@ async function loadProductList(parentId, tips) { |
|
|
item.showChild = item.specs.length > 1 ? false : item.showChild; |
|
|
item.showChild = item.specs.length > 1 ? false : item.showChild; |
|
|
}); |
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
const temp = products.value; |
|
|
|
|
|
products.value = []; |
|
|
|
|
|
await sleep(100); // 等待更新数据 scrollTop.value 无效的 |
|
|
|
|
|
|
|
|
products.value = pageIndex.value === 1 |
|
|
products.value = pageIndex.value === 1 |
|
|
? res.data |
|
|
? res.data |
|
|
: [...products.value, ...(res.data || [])]; |
|
|
|
|
|
|
|
|
: [...temp, ...(res.data || [])]; |
|
|
|
|
|
|
|
|
rightHeight.value = ((await useRect("#scroll-page"))?.height || 1) + 1; |
|
|
rightHeight.value = ((await useRect("#scroll-page"))?.height || 1) + 1; |
|
|
if (tips === 1) { |
|
|
if (tips === 1) { |
|
|
@ -411,11 +415,12 @@ async function loadProductList(parentId, tips) { |
|
|
scrollTop.value = 0; |
|
|
scrollTop.value = 0; |
|
|
bottomHeight.value = 0; |
|
|
bottomHeight.value = 0; |
|
|
} |
|
|
} |
|
|
|
|
|
scrollTop.value = 0; |
|
|
uni.hideNavigationBarLoading(); // 停止下拉刷新 |
|
|
uni.hideNavigationBarLoading(); // 停止下拉刷新 |
|
|
uni.stopPullDownRefresh(); |
|
|
uni.stopPullDownRefresh(); |
|
|
} |
|
|
} |
|
|
/** |
|
|
/** |
|
|
* 滚动事件 |
|
|
|
|
|
|
|
|
* 滚动事件 判断触底否 |
|
|
* @param {Event} e - 滚动事件参数 |
|
|
* @param {Event} e - 滚动事件参数 |
|
|
*/ |
|
|
*/ |
|
|
function onScroll(e) { |
|
|
function onScroll(e) { |
|
|
@ -431,27 +436,30 @@ function onScroll(e) { |
|
|
/** |
|
|
/** |
|
|
* 翻页数据 |
|
|
* 翻页数据 |
|
|
*/ |
|
|
*/ |
|
|
function onLoadList() { |
|
|
|
|
|
const pageIdx = pageIndex.value + 1; |
|
|
|
|
|
|
|
|
// function onLoadList() { |
|
|
|
|
|
// console.log("翻页数据"); |
|
|
|
|
|
|
|
|
if (pageIdx <= pageCount.value) { |
|
|
|
|
|
pageIndex.value = pageIdx; |
|
|
|
|
|
unLoading.value = false; |
|
|
|
|
|
getProducts(scrollId.value); |
|
|
|
|
|
} |
|
|
|
|
|
else { |
|
|
|
|
|
unLoading.value = true; |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
// const pageIdx = pageIndex.value + 1; |
|
|
|
|
|
|
|
|
|
|
|
// if (pageIdx <= pageCount.value) { |
|
|
|
|
|
// pageIndex.value = pageIdx; |
|
|
|
|
|
// unLoading.value = false; |
|
|
|
|
|
// getProducts(scrollId.value); |
|
|
|
|
|
// } |
|
|
|
|
|
// else { |
|
|
|
|
|
// unLoading.value = true; |
|
|
|
|
|
// } |
|
|
|
|
|
// } |
|
|
/** |
|
|
/** |
|
|
* 下拉刷新 |
|
|
* 下拉刷新 |
|
|
*/ |
|
|
*/ |
|
|
function onRefresherRefresh() { |
|
|
|
|
|
triggered.value = false; |
|
|
|
|
|
if (currentType.value != 0) { |
|
|
|
|
|
getProducts(typeData.value[currentType.value - 1].id, 1); |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
// function onRefresherRefresh() { |
|
|
|
|
|
// // console.log("下拉刷新"); |
|
|
|
|
|
// triggered.value = false; |
|
|
|
|
|
// if (currentType.value != 0) { |
|
|
|
|
|
// getProducts(typeData.value[currentType.value - 1].id, 1); |
|
|
|
|
|
// } |
|
|
|
|
|
// } |
|
|
/** |
|
|
/** |
|
|
* 触摸开始事件 |
|
|
* 触摸开始事件 |
|
|
* @param e 触摸事件参数 |
|
|
* @param e 触摸事件参数 |
|
|
@ -518,7 +526,6 @@ async function onTouchEnd() { |
|
|
) { |
|
|
) { |
|
|
bottomHeight.value = 0; |
|
|
bottomHeight.value = 0; |
|
|
if (!isSearching.value) { |
|
|
if (!isSearching.value) { |
|
|
scrollTop.value = 0; |
|
|
|
|
|
await getProducts(typeData.value[currentType.value + 1].id, 2); |
|
|
await getProducts(typeData.value[currentType.value + 1].id, 2); |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
@ -909,7 +916,6 @@ onHide(() => { |
|
|
@scroll="onScroll" 滚动过程中实时监听滚动位置 |
|
|
@scroll="onScroll" 滚动过程中实时监听滚动位置 |
|
|
@refresherrefresh="onRefresherrefresh" 下拉刷新时触发重新加载当前分类数据 |
|
|
@refresherrefresh="onRefresherrefresh" 下拉刷新时触发重新加载当前分类数据 |
|
|
--> |
|
|
--> |
|
|
<!-- FIXME: scrollTop 失效了 --> |
|
|
|
|
|
<scroll-view |
|
|
<scroll-view |
|
|
id="scroll-page" |
|
|
id="scroll-page" |
|
|
class="right" |
|
|
class="right" |
|
|
@ -932,13 +938,13 @@ onHide(() => { |
|
|
transition: '.01s all', |
|
|
transition: '.01s all', |
|
|
}" |
|
|
}" |
|
|
@scrolltolower="() => { |
|
|
@scrolltolower="() => { |
|
|
// FIXME: onLoadList(); 原来的没有用了,这里还要吗 |
|
|
|
|
|
onLoadList() |
|
|
|
|
|
|
|
|
// TODO: onLoadList 原版如何触发 |
|
|
|
|
|
// onLoadList() |
|
|
}" |
|
|
}" |
|
|
@scroll="onScroll" |
|
|
@scroll="onScroll" |
|
|
@refresherrefresh="() => { |
|
|
@refresherrefresh="() => { |
|
|
// FIXME: onRefresherRefresh(); 原来的没有用了,这里还要吗 |
|
|
|
|
|
onRefresherRefresh() |
|
|
|
|
|
|
|
|
// TODO: onRefresherRefresh 原版如何触发 |
|
|
|
|
|
// onRefresherRefresh() |
|
|
}" |
|
|
}" |
|
|
> |
|
|
> |
|
|
<view |
|
|
<view |
|
|
|