|
@@ -26,7 +26,10 @@ Page({
|
|
|
data: {
|
|
|
testImg: '../../../imgs/testImg/fdkz.png',
|
|
|
myBrowsed: [],
|
|
|
- noCollectionImg
|
|
|
+ noCollectionImg,
|
|
|
+ currentPage: 1,
|
|
|
+ loading: false,
|
|
|
+ hasMore: true
|
|
|
},
|
|
|
|
|
|
/**
|
|
@@ -54,7 +57,7 @@ Page({
|
|
|
app.globalData.city = "北京";
|
|
|
}
|
|
|
|
|
|
- this.getBrowsedExhibitions();
|
|
|
+ this.getBrowsedExhibitions(1);
|
|
|
}
|
|
|
// else {
|
|
|
// // 没有位置信息,获取位置
|
|
@@ -71,7 +74,7 @@ Page({
|
|
|
// })
|
|
|
// },
|
|
|
// complete:()=>{
|
|
|
- // this.getBrowsedExhibitions()
|
|
|
+ // this.getBrowsedExhibitions(1)
|
|
|
// }
|
|
|
// })
|
|
|
// }
|
|
@@ -80,8 +83,10 @@ Page({
|
|
|
onPullDownRefresh: function() {
|
|
|
this.setData({
|
|
|
myBrowsed: [],
|
|
|
+ currentPage: 1,
|
|
|
+ hasMore: true
|
|
|
});
|
|
|
- this.getBrowsedExhibitions()
|
|
|
+ this.getBrowsedExhibitions(1)
|
|
|
},
|
|
|
saveBrowsedExhibitions() {
|
|
|
let {
|
|
@@ -102,7 +107,7 @@ Page({
|
|
|
loginSessionKey
|
|
|
}, "", res => {
|
|
|
if (res) {
|
|
|
- this.getBrowsedExhibitions()
|
|
|
+ this.getBrowsedExhibitions(1)
|
|
|
}
|
|
|
}, err => {
|
|
|
|
|
@@ -116,52 +121,88 @@ Page({
|
|
|
|
|
|
},
|
|
|
|
|
|
- getBrowsedExhibitions: function() {
|
|
|
+ getBrowsedExhibitions: function(page = 1) {
|
|
|
+ if (this.data.loading) return;
|
|
|
+
|
|
|
let loginSessionKey = wx.getStorageSync("token") || "";
|
|
|
- let ids = undefined;
|
|
|
- console.log(app.globalData)
|
|
|
- if (app.globalData.cookieIDs) {
|
|
|
- if (app.globalData.cookieIDs.length > 9) {
|
|
|
- app.globalData.cookieIDs = app.globalData.cookieIDs.slice(0, 10)
|
|
|
- // console.log(cookieIDs)
|
|
|
-
|
|
|
- }
|
|
|
- console.log(app.globalData.cookieIDs.join(","))
|
|
|
-
|
|
|
- for (let i = 0; i < app.globalData.cookieIDs.length;i++){
|
|
|
- if (app.globalData.cookieIDs[i] =='undefined'){
|
|
|
- app.globalData.cookieIDs.splice(i,1);
|
|
|
- }
|
|
|
- }
|
|
|
- ids = app.globalData.cookieIDs.join(",") || "";
|
|
|
+ // let ids = undefined;
|
|
|
+ // console.log(app.globalData)
|
|
|
+ // if (app.globalData.cookieIDs) {
|
|
|
+ // if (app.globalData.cookieIDs.length > 9) {
|
|
|
+ // app.globalData.cookieIDs = app.globalData.cookieIDs.slice(0, 10)
|
|
|
+ // // console.log(cookieIDs)
|
|
|
+
|
|
|
+ // }
|
|
|
+ // console.log(app.globalData.cookieIDs.join(","))
|
|
|
+
|
|
|
+ // for (let i = 0; i < app.globalData.cookieIDs.length;i++){
|
|
|
+ // if (app.globalData.cookieIDs[i] =='undefined'){
|
|
|
+ // app.globalData.cookieIDs.splice(i,1);
|
|
|
+ // }
|
|
|
+ // }
|
|
|
+ // ids = app.globalData.cookieIDs.join(",") || "";
|
|
|
|
|
|
- // console.log("asdasdas",ids)
|
|
|
- } else {
|
|
|
- return
|
|
|
- }
|
|
|
+ // // console.log("asdasdas",ids)
|
|
|
+ // } else {
|
|
|
+ // return
|
|
|
+ // }
|
|
|
+
|
|
|
+ this.setData({
|
|
|
+ loading: true
|
|
|
+ });
|
|
|
+
|
|
|
let {latitude:lat,longitude:lng} = this.data
|
|
|
- newRequestFns["getExhibitionsByIds"]({
|
|
|
- ids,
|
|
|
+ newRequestFns["getTrace"]({
|
|
|
+ pageNo: page,
|
|
|
lat,
|
|
|
lng,
|
|
|
loginSessionKey
|
|
|
}, "", res => {
|
|
|
if (res.data.code > -1) {
|
|
|
- let {
|
|
|
- data: myBrowsed
|
|
|
- } = res.data;
|
|
|
+ let newTraceData = res.data.data ? res.data.data.pageData : [];
|
|
|
+
|
|
|
+ // 处理数据,添加detailType字段
|
|
|
+ if (newTraceData && newTraceData.length > 0) {
|
|
|
+ newTraceData.forEach(item => {
|
|
|
+ // 根据业务逻辑设置detailType,这里假设根据某个字段判断
|
|
|
+ // 如果有specific字段来区分展会和文物,请根据实际情况修改
|
|
|
+ item.detailType = item.detailType || 1; // 默认为展会类型
|
|
|
+ });
|
|
|
+ }
|
|
|
+ console.log(newTraceData, 999)
|
|
|
+ let updatedMyBrowsed;
|
|
|
+ if (page === 1) {
|
|
|
+ // 第一页,直接替换
|
|
|
+ updatedMyBrowsed = newTraceData || [];
|
|
|
+ } else {
|
|
|
+ // 后续页面,追加数据
|
|
|
+ updatedMyBrowsed = [...this.data.myBrowsed, ...(newTraceData || [])];
|
|
|
+ }
|
|
|
+
|
|
|
+ // 判断是否还有更多数据
|
|
|
+ let hasMore = newTraceData && newTraceData.length > 0;
|
|
|
+
|
|
|
this.setData({
|
|
|
- myBrowsed
|
|
|
+ myBrowsed: updatedMyBrowsed,
|
|
|
+ currentPage: page,
|
|
|
+ hasMore: hasMore,
|
|
|
+ loading: false
|
|
|
})
|
|
|
- console.log(myBrowsed)
|
|
|
+ console.log(updatedMyBrowsed, updatedMyBrowsed, 777)
|
|
|
+ } else {
|
|
|
+ this.setData({
|
|
|
+ loading: false,
|
|
|
+ hasMore: false
|
|
|
+ });
|
|
|
}
|
|
|
|
|
|
}, err => {
|
|
|
-
|
|
|
+ this.setData({
|
|
|
+ loading: false
|
|
|
+ });
|
|
|
},
|
|
|
complete => {
|
|
|
wx.stopPullDownRefresh();
|
|
|
-
|
|
|
})
|
|
|
},
|
|
|
|
|
@@ -244,7 +285,8 @@ Page({
|
|
|
* 页面上拉触底事件的处理函数
|
|
|
*/
|
|
|
onReachBottom: function() {
|
|
|
-
|
|
|
+ if (this.data.loading || !this.data.hasMore) return;
|
|
|
+ this.getBrowsedExhibitions(this.data.currentPage + 1);
|
|
|
},
|
|
|
|
|
|
/**
|