|
@@ -327,7 +327,7 @@ Page({
|
|
|
popupList: res,
|
|
popupList: res,
|
|
|
isShowPopup: true,
|
|
isShowPopup: true,
|
|
|
});
|
|
});
|
|
|
- }else{
|
|
|
|
|
|
|
+ } else {
|
|
|
this.setData({
|
|
this.setData({
|
|
|
popupList: [],
|
|
popupList: [],
|
|
|
isShowPopup: false,
|
|
isShowPopup: false,
|
|
@@ -351,9 +351,9 @@ Page({
|
|
|
if (this.data.isCompleting) {
|
|
if (this.data.isCompleting) {
|
|
|
return;
|
|
return;
|
|
|
}
|
|
}
|
|
|
-
|
|
|
|
|
|
|
+
|
|
|
this.setData({ isCompleting: true });
|
|
this.setData({ isCompleting: true });
|
|
|
-
|
|
|
|
|
|
|
+
|
|
|
try {
|
|
try {
|
|
|
const { title } = e.currentTarget.dataset;
|
|
const { title } = e.currentTarget.dataset;
|
|
|
let page = e.currentTarget.dataset.page;
|
|
let page = e.currentTarget.dataset.page;
|
|
@@ -428,18 +428,18 @@ Page({
|
|
|
showCancel: false,
|
|
showCancel: false,
|
|
|
confirmText: `重新加载`,
|
|
confirmText: `重新加载`,
|
|
|
})
|
|
})
|
|
|
- .catch(() => {});
|
|
|
|
|
|
|
+ .catch(() => { });
|
|
|
await this.load(true);
|
|
await this.load(true);
|
|
|
return;
|
|
return;
|
|
|
}
|
|
}
|
|
|
-
|
|
|
|
|
|
|
+ // 加载健康宣教的文章
|
|
|
|
|
+ this.loadScienceList();
|
|
|
if (!this.data._loaded) {
|
|
if (!this.data._loaded) {
|
|
|
- this.loadScienceList();
|
|
|
|
|
getSolarTerms()
|
|
getSolarTerms()
|
|
|
.then((solarTerms) => {
|
|
.then((solarTerms) => {
|
|
|
this.setData({ solarTerms });
|
|
this.setData({ solarTerms });
|
|
|
})
|
|
})
|
|
|
- .catch(() => {});
|
|
|
|
|
|
|
+ .catch(() => { });
|
|
|
this.setData({ _loaded: true });
|
|
this.setData({ _loaded: true });
|
|
|
}
|
|
}
|
|
|
},
|
|
},
|
|
@@ -616,17 +616,15 @@ Page({
|
|
|
(<any>this).applyAnimatedStyle(".fab-2", () => {
|
|
(<any>this).applyAnimatedStyle(".fab-2", () => {
|
|
|
"worklet";
|
|
"worklet";
|
|
|
return {
|
|
return {
|
|
|
- transform: `translateX(${-offset.value}px) translateY(${
|
|
|
|
|
- -offset.value / 2
|
|
|
|
|
- }px)`,
|
|
|
|
|
|
|
+ transform: `translateX(${-offset.value}px) translateY(${-offset.value / 2
|
|
|
|
|
+ }px)`,
|
|
|
};
|
|
};
|
|
|
});
|
|
});
|
|
|
(<any>this).applyAnimatedStyle(".fab-3", () => {
|
|
(<any>this).applyAnimatedStyle(".fab-3", () => {
|
|
|
"worklet";
|
|
"worklet";
|
|
|
return {
|
|
return {
|
|
|
- transform: `translateX(${-offset.value}px) translateY(${
|
|
|
|
|
- offset.value / 2
|
|
|
|
|
- }px)`,
|
|
|
|
|
|
|
+ transform: `translateX(${-offset.value}px) translateY(${offset.value / 2
|
|
|
|
|
+ }px)`,
|
|
|
};
|
|
};
|
|
|
});
|
|
});
|
|
|
(<any>this).applyAnimatedStyle(".fab-4", () => {
|
|
(<any>this).applyAnimatedStyle(".fab-4", () => {
|
|
@@ -736,7 +734,7 @@ Page({
|
|
|
total,
|
|
total,
|
|
|
page: currentPage,
|
|
page: currentPage,
|
|
|
} = await getShortScienceList(page, this.data.scienceListSize);
|
|
} = await getShortScienceList(page, this.data.scienceListSize);
|
|
|
-
|
|
|
|
|
|
|
+ console.log("datas", data, "newList:", this.data.scienceList);
|
|
|
const newList = reset ? data : [...this.data.scienceList, ...data];
|
|
const newList = reset ? data : [...this.data.scienceList, ...data];
|
|
|
const hasMore = newList.length < total;
|
|
const hasMore = newList.length < total;
|
|
|
|
|
|
|
@@ -747,7 +745,7 @@ Page({
|
|
|
scienceListHasMore: hasMore,
|
|
scienceListHasMore: hasMore,
|
|
|
scienceListLoading: false,
|
|
scienceListLoading: false,
|
|
|
});
|
|
});
|
|
|
-
|
|
|
|
|
|
|
+ console.log(this.data.scienceList, "this.data.scienceList");
|
|
|
// 分配卡片到两列,实现瀑布流布局
|
|
// 分配卡片到两列,实现瀑布流布局
|
|
|
this.distributeCardsToColumns(newList, reset);
|
|
this.distributeCardsToColumns(newList, reset);
|
|
|
} catch (error) {
|
|
} catch (error) {
|
|
@@ -779,14 +777,14 @@ Page({
|
|
|
const itemsToDistribute = reset
|
|
const itemsToDistribute = reset
|
|
|
? list
|
|
? list
|
|
|
: list.filter(
|
|
: list.filter(
|
|
|
- (item: any) =>
|
|
|
|
|
- !this.data.leftColumnList.some(
|
|
|
|
|
- (existing: any) => existing.id === item.id
|
|
|
|
|
- ) &&
|
|
|
|
|
- !this.data.rightColumnList.some(
|
|
|
|
|
- (existing: any) => existing.id === item.id
|
|
|
|
|
- )
|
|
|
|
|
- );
|
|
|
|
|
|
|
+ (item: any) =>
|
|
|
|
|
+ !this.data.leftColumnList.some(
|
|
|
|
|
+ (existing: any) => existing.id === item.id
|
|
|
|
|
+ ) &&
|
|
|
|
|
+ !this.data.rightColumnList.some(
|
|
|
|
|
+ (existing: any) => existing.id === item.id
|
|
|
|
|
+ )
|
|
|
|
|
+ );
|
|
|
|
|
|
|
|
if (itemsToDistribute.length === 0) return;
|
|
if (itemsToDistribute.length === 0) return;
|
|
|
|
|
|
|
@@ -794,16 +792,16 @@ Page({
|
|
|
let leftHeight = reset
|
|
let leftHeight = reset
|
|
|
? 0
|
|
? 0
|
|
|
: this.data.leftColumnList.reduce(
|
|
: this.data.leftColumnList.reduce(
|
|
|
- (sum: number, item: any) => sum + this.estimateCardHeight(item),
|
|
|
|
|
- 0
|
|
|
|
|
- );
|
|
|
|
|
|
|
+ (sum: number, item: any) => sum + this.estimateCardHeight(item),
|
|
|
|
|
+ 0
|
|
|
|
|
+ );
|
|
|
|
|
|
|
|
let rightHeight = reset
|
|
let rightHeight = reset
|
|
|
? 0
|
|
? 0
|
|
|
: this.data.rightColumnList.reduce(
|
|
: this.data.rightColumnList.reduce(
|
|
|
- (sum: number, item: any) => sum + this.estimateCardHeight(item),
|
|
|
|
|
- 0
|
|
|
|
|
- );
|
|
|
|
|
|
|
+ (sum: number, item: any) => sum + this.estimateCardHeight(item),
|
|
|
|
|
+ 0
|
|
|
|
|
+ );
|
|
|
|
|
|
|
|
// 追加新卡片到较短的列(重置时从空数组开始)
|
|
// 追加新卡片到较短的列(重置时从空数组开始)
|
|
|
const leftColumn = reset ? [] : [...this.data.leftColumnList];
|
|
const leftColumn = reset ? [] : [...this.data.leftColumnList];
|
|
@@ -838,8 +836,8 @@ Page({
|
|
|
const imgHeightRange = imgMaxHeight - imgMinHeight;
|
|
const imgHeightRange = imgMaxHeight - imgMinHeight;
|
|
|
const idHash = item.id
|
|
const idHash = item.id
|
|
|
? String(item.id)
|
|
? String(item.id)
|
|
|
- .split("")
|
|
|
|
|
- .reduce((acc: number, char: string) => acc + char.charCodeAt(0), 0)
|
|
|
|
|
|
|
+ .split("")
|
|
|
|
|
+ .reduce((acc: number, char: string) => acc + char.charCodeAt(0), 0)
|
|
|
: 0;
|
|
: 0;
|
|
|
const imgHeight = imgMinHeight + (idHash % imgHeightRange);
|
|
const imgHeight = imgMinHeight + (idHash % imgHeightRange);
|
|
|
height += imgHeight;
|
|
height += imgHeight;
|