提交 ebaefb23 编写于 作者: H hdx

long-list: request 改为泛型

上级 e5f50b28
......@@ -103,16 +103,15 @@
this.loading = true
// TODO request data 没有拼接到 url 中,暂时手动拼接
uni.request({
uni.request<ResponseDataType>({
url: `${SERVER_URL}?type=${this.type}&page=${this.$currentPage}&page_size=${PAGE_SIZE}`,
data: {
type: this.type,
page: this.$currentPage,
page_size: PAGE_SIZE
},
dataType: '',
success: (res) => {
const responseData = JSON.parse<ResponseDataType>(res.data as string)
const responseData = res.data
if (responseData == null) {
return
}
......@@ -238,4 +237,4 @@
text-align: center;
background-color: #f8f8f8;
}
</style>
\ No newline at end of file
</style>
......@@ -40,6 +40,18 @@
preload : Boolean,
}
/**
* 根据权重在两个值之间执行线性插值.
* @constructor
* @param {number} value1 - 第一个值,该值应为下限.
* @param {number} value2 - 第二个值,该值应为上限.
* @param {number} amount - 应介于 0 和 1 之间,指示内插的权重.
* @returns {number} 内插值
*/
function lerpNumber(value1 : number, value2 : number, amount : number) : number {
return (value1 + (value2 - value1) * amount)
}
export default {
components: {
longPage
......@@ -148,14 +160,14 @@
// 计算指示线
const current_size = this.$swiperTabsRect[current_index]
const move_to_size = this.$swiperTabsRect[move_to_index]
const indicator_line_l = current_size.x + (move_to_size.x - current_size.x) * percentage
const indicator_line_w = current_size.w + (move_to_size.w - current_size.w) * percentage
const indicator_line_x = lerpNumber(current_size.x, move_to_size.x, percentage)
const indicator_line_w = lerpNumber(current_size.w, move_to_size.w, percentage)
// 更新指示线
const x = indicator_line_l + indicator_line_w / 2
const x = indicator_line_x + indicator_line_w / 2
this.$indicatorNode?.style?.setProperty('transform', `translateX(${x}px) scaleX(${indicator_line_w})`)
// 将指示线滚动到水平中心位置
// 滚动到水平中心位置
const scroll_x = x - this.$swiperWidth / 2
this.$tabScrollView?.setAttribute('scrollLeft', scroll_x)
},
......@@ -214,4 +226,4 @@
.swiper-item {
flex: 1;
}
</style>
</style>
\ No newline at end of file
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册