|
@@ -1,7 +1,16 @@
|
|
//index.js
|
|
//index.js
|
|
-const { request, serverName } = require('../../utils/services');
|
|
|
|
-const { Toast } = require('../../utils/util.js');
|
|
|
|
-const { defaultImg, noExhibitionImg } = require('../../utils/images');
|
|
|
|
|
|
+const {
|
|
|
|
+ request,
|
|
|
|
+ serverName,
|
|
|
|
+ imgServer
|
|
|
|
+} = require('../../utils/services');
|
|
|
|
+const {
|
|
|
|
+ Toast
|
|
|
|
+} = require('../../utils/util.js');
|
|
|
|
+const {
|
|
|
|
+ defaultImg,
|
|
|
|
+ noExhibitionImg
|
|
|
|
+} = require('../../utils/images');
|
|
|
|
|
|
|
|
|
|
const WxParse = require('../../common/component/wxParse/wxParse.js');
|
|
const WxParse = require('../../common/component/wxParse/wxParse.js');
|
|
@@ -24,16 +33,17 @@ Page({
|
|
currentPage: 1,
|
|
currentPage: 1,
|
|
exhibitionList: [],
|
|
exhibitionList: [],
|
|
likes: {},
|
|
likes: {},
|
|
- tag: 0
|
|
|
|
|
|
+ tag: 0,
|
|
|
|
+ latitude: null,
|
|
|
|
+ longitude: null
|
|
},
|
|
},
|
|
|
|
|
|
- onLoad: function () {
|
|
|
|
-
|
|
|
|
-
|
|
|
|
|
|
+ onLoad: function() {
|
|
this.setData({
|
|
this.setData({
|
|
serverName,
|
|
serverName,
|
|
defaultImg,
|
|
defaultImg,
|
|
noExhibitionImg,
|
|
noExhibitionImg,
|
|
|
|
+ imgServer
|
|
// isLogin
|
|
// isLogin
|
|
})
|
|
})
|
|
|
|
|
|
@@ -42,7 +52,7 @@ Page({
|
|
this.getList(1);
|
|
this.getList(1);
|
|
},
|
|
},
|
|
|
|
|
|
- loadMore: function () {
|
|
|
|
|
|
+ loadMore: function() {
|
|
if (!this.data.lastPage) {
|
|
if (!this.data.lastPage) {
|
|
console.log(this.data.currentPage + 1)
|
|
console.log(this.data.currentPage + 1)
|
|
this.getList(this.data.currentPage + 1);
|
|
this.getList(this.data.currentPage + 1);
|
|
@@ -51,26 +61,22 @@ Page({
|
|
}
|
|
}
|
|
},
|
|
},
|
|
|
|
|
|
- onReachBottom: function () {
|
|
|
|
|
|
+ onReachBottom: function() {
|
|
if (!this.data.loading) {
|
|
if (!this.data.loading) {
|
|
this.loadMore();
|
|
this.loadMore();
|
|
console.log('reach Bottom');
|
|
console.log('reach Bottom');
|
|
}
|
|
}
|
|
-
|
|
|
|
},
|
|
},
|
|
|
|
|
|
- onShow: function () {
|
|
|
|
- let { collectedArr, collectedChange } = app.globalData;
|
|
|
|
- let { exhibitionList } = this.data
|
|
|
|
|
|
+ onShow: function() {
|
|
|
|
+ let {
|
|
|
|
+ collectedArr,
|
|
|
|
+ collectedChange
|
|
|
|
+ } = app.globalData;
|
|
|
|
+ let {
|
|
|
|
+ exhibitionList
|
|
|
|
+ } = this.data
|
|
let isLogin = app.globalData.isLogin;
|
|
let isLogin = app.globalData.isLogin;
|
|
-
|
|
|
|
-
|
|
|
|
- // this.setData({
|
|
|
|
- // exhibitionList: []
|
|
|
|
- // });
|
|
|
|
- // this.getBanner();
|
|
|
|
- // this.getList(1);
|
|
|
|
- console.log('dwdwasda', isLogin)
|
|
|
|
this.setData({
|
|
this.setData({
|
|
isLogin
|
|
isLogin
|
|
})
|
|
})
|
|
@@ -82,8 +88,7 @@ Page({
|
|
exhibitionList[i].hasCollect = collectedArr[j].status
|
|
exhibitionList[i].hasCollect = collectedArr[j].status
|
|
if (exhibitionList[i].hasCollect) {
|
|
if (exhibitionList[i].hasCollect) {
|
|
exhibitionList[i].collectionsCount += 1;
|
|
exhibitionList[i].collectionsCount += 1;
|
|
- }
|
|
|
|
- else {
|
|
|
|
|
|
+ } else {
|
|
exhibitionList[i].collectionsCount -= 1;
|
|
exhibitionList[i].collectionsCount -= 1;
|
|
}
|
|
}
|
|
if (exhibitionList[i].collectionsCount < 0) {
|
|
if (exhibitionList[i].collectionsCount < 0) {
|
|
@@ -96,14 +101,14 @@ Page({
|
|
}
|
|
}
|
|
this.setData({
|
|
this.setData({
|
|
exhibitionList,
|
|
exhibitionList,
|
|
-
|
|
|
|
|
|
+
|
|
})
|
|
})
|
|
}
|
|
}
|
|
// app.globalData.clickToSelect = false;
|
|
// app.globalData.clickToSelect = false;
|
|
app.globalData.collectedChange = false;
|
|
app.globalData.collectedChange = false;
|
|
|
|
|
|
},
|
|
},
|
|
- onPullDownRefresh: function () {
|
|
|
|
|
|
+ onPullDownRefresh: function() {
|
|
this.setData({
|
|
this.setData({
|
|
exhibitionList: [],
|
|
exhibitionList: [],
|
|
currentPage: 1
|
|
currentPage: 1
|
|
@@ -111,24 +116,26 @@ Page({
|
|
this.getList(1);
|
|
this.getList(1);
|
|
},
|
|
},
|
|
|
|
|
|
-
|
|
|
|
- getList: function (page) {
|
|
|
|
- let type = this.data.tag;
|
|
|
|
- console.log(this.data.tag)
|
|
|
|
- this.setData({
|
|
|
|
- loading: true
|
|
|
|
- })
|
|
|
|
|
|
+ fetchData: function (page){
|
|
request["getExhibitionList"]({
|
|
request["getExhibitionList"]({
|
|
page: page,
|
|
page: page,
|
|
- type: type
|
|
|
|
|
|
+ type: 0,
|
|
|
|
+ lat: this.data.latitude,
|
|
|
|
+ lng: this.data.longitude
|
|
}, '', res => {
|
|
}, '', res => {
|
|
|
|
|
|
- let tempContent = this.data.exhibitionList
|
|
|
|
- ? this.data.exhibitionList
|
|
|
|
- : [];
|
|
|
|
- let { last: lastPage, totalPages, content: exhibitionList } = res.data.data;
|
|
|
|
-
|
|
|
|
- let { openTime } = exhibitionList;
|
|
|
|
|
|
+ let tempContent = this.data.exhibitionList ?
|
|
|
|
+ this.data.exhibitionList :
|
|
|
|
+ [];
|
|
|
|
+ let {
|
|
|
|
+ last: lastPage,
|
|
|
|
+ totalPages,
|
|
|
|
+ content: exhibitionList
|
|
|
|
+ } = res.data.data;
|
|
|
|
+
|
|
|
|
+ let {
|
|
|
|
+ openTime
|
|
|
|
+ } = exhibitionList;
|
|
console.log(res)
|
|
console.log(res)
|
|
this.setData({
|
|
this.setData({
|
|
currentPage: res.data.data.number + 1,
|
|
currentPage: res.data.data.number + 1,
|
|
@@ -137,8 +144,6 @@ Page({
|
|
exhibitionList: tempContent.concat(exhibitionList),
|
|
exhibitionList: tempContent.concat(exhibitionList),
|
|
});
|
|
});
|
|
console.log(exhibitionList)
|
|
console.log(exhibitionList)
|
|
-
|
|
|
|
-
|
|
|
|
// WxParse.wxParseTemArray("replyTemArray", 'reply', replyArr.length, that)
|
|
// WxParse.wxParseTemArray("replyTemArray", 'reply', replyArr.length, that)
|
|
|
|
|
|
}, err => {
|
|
}, err => {
|
|
@@ -148,13 +153,36 @@ Page({
|
|
})
|
|
})
|
|
},
|
|
},
|
|
|
|
|
|
- getBanner: function () {
|
|
|
|
- request["getBannerList"]({
|
|
|
|
- }, '', res => {
|
|
|
|
- let { content: commodityImgs } = res.data.data;
|
|
|
|
|
|
+
|
|
|
|
+ getList: function(page) {
|
|
|
|
+ let type = this.data.tag;
|
|
|
|
+ this.setData({
|
|
|
|
+ loading: true
|
|
|
|
+ })
|
|
|
|
+ if (this.data.latitude||this.data.longitude) {
|
|
|
|
+ this.fetchData(page)
|
|
|
|
+ } else {
|
|
|
|
+ wx.getLocation({
|
|
|
|
+ type: 'wgs84',
|
|
|
|
+ success: (res) => {
|
|
|
|
+ this.setData({
|
|
|
|
+ latitude: res.latitude,
|
|
|
|
+ longitude: res.longitude
|
|
|
|
+ })
|
|
|
|
+ this.fetchData(page)
|
|
|
|
+ },
|
|
|
|
+ })
|
|
|
|
+ }
|
|
|
|
+ },
|
|
|
|
+
|
|
|
|
+ getBanner: function() {
|
|
|
|
+ request["getBannerList"]({}, '', res => {
|
|
|
|
+ let {
|
|
|
|
+ content: commodityImgs
|
|
|
|
+ } = res.data.data;
|
|
// console.log("wdwdwd",commodityImgs)
|
|
// console.log("wdwdwd",commodityImgs)
|
|
this.setData({
|
|
this.setData({
|
|
- commodityImgs: commodityImgs||[]
|
|
|
|
|
|
+ commodityImgs: commodityImgs || []
|
|
});
|
|
});
|
|
}, err => {
|
|
}, err => {
|
|
|
|
|
|
@@ -163,14 +191,21 @@ Page({
|
|
})
|
|
})
|
|
},
|
|
},
|
|
|
|
|
|
- addLike: function (e) {
|
|
|
|
- let { type, id, idx } = e.currentTarget.dataset;
|
|
|
|
|
|
+ addLike: function(e) {
|
|
|
|
+ let {
|
|
|
|
+ type,
|
|
|
|
+ id,
|
|
|
|
+ idx
|
|
|
|
+ } = e.currentTarget.dataset;
|
|
console.log(idx, type, id)
|
|
console.log(idx, type, id)
|
|
|
|
|
|
let likes = this.data.likes;
|
|
let likes = this.data.likes;
|
|
likes[id] = !likes[id];
|
|
likes[id] = !likes[id];
|
|
let exhibitionList = this.data.exhibitionList;
|
|
let exhibitionList = this.data.exhibitionList;
|
|
- let { collectedArr, collectedChange } = app.globalData, hasItem = true;
|
|
|
|
|
|
+ let {
|
|
|
|
+ collectedArr,
|
|
|
|
+ collectedChange
|
|
|
|
+ } = app.globalData, hasItem = true;
|
|
|
|
|
|
|
|
|
|
console.log('type', type)
|
|
console.log('type', type)
|
|
@@ -216,7 +251,7 @@ Page({
|
|
}, err => {
|
|
}, err => {
|
|
|
|
|
|
}, complete => {
|
|
}, complete => {
|
|
-
|
|
|
|
|
|
+
|
|
Toast.hideLoading();
|
|
Toast.hideLoading();
|
|
})
|
|
})
|
|
// }
|
|
// }
|
|
@@ -224,11 +259,11 @@ Page({
|
|
console.log(this.data.exhibitionList)
|
|
console.log(this.data.exhibitionList)
|
|
},
|
|
},
|
|
|
|
|
|
- tabClick: function (e) {
|
|
|
|
|
|
+ tabClick: function(e) {
|
|
// console.log(e.currentTarget.dataset)
|
|
// console.log(e.currentTarget.dataset)
|
|
|
|
|
|
// if (e.currentTarget.id == 1) {
|
|
// if (e.currentTarget.id == 1) {
|
|
-
|
|
|
|
|
|
+
|
|
// wx.switchTab({
|
|
// wx.switchTab({
|
|
// url: '../swkz/index',
|
|
// url: '../swkz/index',
|
|
// success: function (res) { },
|
|
// success: function (res) { },
|
|
@@ -237,24 +272,30 @@ Page({
|
|
// })
|
|
// })
|
|
// }
|
|
// }
|
|
// else {
|
|
// else {
|
|
- this.setData({
|
|
|
|
- exhibitionList: [],
|
|
|
|
- activeIndex: e.currentTarget.id,
|
|
|
|
- tag: e.currentTarget.dataset.tag,
|
|
|
|
- currentPage: 1
|
|
|
|
- });
|
|
|
|
- this.getList(1);
|
|
|
|
|
|
+ this.setData({
|
|
|
|
+ exhibitionList: [],
|
|
|
|
+ activeIndex: e.currentTarget.id,
|
|
|
|
+ tag: e.currentTarget.dataset.tag,
|
|
|
|
+ currentPage: 1
|
|
|
|
+ });
|
|
|
|
+ this.getList(1);
|
|
// }
|
|
// }
|
|
},
|
|
},
|
|
- onShareAppMessage: function () {
|
|
|
|
|
|
+ onShareAppMessage: function() {
|
|
|
|
|
|
},
|
|
},
|
|
|
|
|
|
|
|
|
|
- to_pay: function (e) {
|
|
|
|
|
|
+ to_pay: function(e) {
|
|
// console.log('dwdwdw', e.currentTarget.dataset)
|
|
// console.log('dwdwdw', e.currentTarget.dataset)
|
|
|
|
|
|
- let { url, pagetype, urltype, hasproduct, haspay } = e.currentTarget.dataset;
|
|
|
|
|
|
+ let {
|
|
|
|
+ url,
|
|
|
|
+ pagetype,
|
|
|
|
+ urltype,
|
|
|
|
+ hasproduct,
|
|
|
|
+ haspay
|
|
|
|
+ } = e.currentTarget.dataset;
|
|
|
|
|
|
|
|
|
|
app.globalData.currentUrl = url
|
|
app.globalData.currentUrl = url
|
|
@@ -266,9 +307,9 @@ Page({
|
|
case 0:
|
|
case 0:
|
|
wx.navigateTo({
|
|
wx.navigateTo({
|
|
url: `../wv_page/index`,
|
|
url: `../wv_page/index`,
|
|
- success: function (res) { },
|
|
|
|
- fail: function (res) { },
|
|
|
|
- complete: function (res) { },
|
|
|
|
|
|
+ success: function(res) {},
|
|
|
|
+ fail: function(res) {},
|
|
|
|
+ complete: function(res) {},
|
|
})
|
|
})
|
|
break;
|
|
break;
|
|
case 1:
|
|
case 1:
|
|
@@ -276,25 +317,25 @@ Page({
|
|
case 0:
|
|
case 0:
|
|
wx.navigateTo({
|
|
wx.navigateTo({
|
|
url: `../cg_detail/index?id=${url}`,
|
|
url: `../cg_detail/index?id=${url}`,
|
|
- success: function (res) { },
|
|
|
|
- fail: function (res) { },
|
|
|
|
- complete: function (res) { },
|
|
|
|
|
|
+ success: function(res) {},
|
|
|
|
+ fail: function(res) {},
|
|
|
|
+ complete: function(res) {},
|
|
})
|
|
})
|
|
break;
|
|
break;
|
|
case 1:
|
|
case 1:
|
|
if (hasproduct) {
|
|
if (hasproduct) {
|
|
wx.navigateTo({
|
|
wx.navigateTo({
|
|
url: `./pay_page/index?id=${url}`,
|
|
url: `./pay_page/index?id=${url}`,
|
|
- success: function (res) { },
|
|
|
|
- fail: function (res) { },
|
|
|
|
- complete: function (res) { },
|
|
|
|
|
|
+ success: function(res) {},
|
|
|
|
+ fail: function(res) {},
|
|
|
|
+ complete: function(res) {},
|
|
})
|
|
})
|
|
} else {
|
|
} else {
|
|
wx.navigateTo({
|
|
wx.navigateTo({
|
|
url: `../zl_detail/index?id=${url}`,
|
|
url: `../zl_detail/index?id=${url}`,
|
|
- success: function (res) { },
|
|
|
|
- fail: function (res) { },
|
|
|
|
- complete: function (res) { },
|
|
|
|
|
|
+ success: function(res) {},
|
|
|
|
+ fail: function(res) {},
|
|
|
|
+ complete: function(res) {},
|
|
})
|
|
})
|
|
}
|
|
}
|
|
|
|
|
|
@@ -333,4 +374,4 @@ Page({
|
|
|
|
|
|
|
|
|
|
}
|
|
}
|
|
-})
|
|
|
|
|
|
+})
|