|
@@ -10,6 +10,8 @@ Page({
|
|
|
data: {
|
|
|
roomList: [],
|
|
|
hasData: true,
|
|
|
+ loading: false,
|
|
|
+ isSearch: false,
|
|
|
fetcherData: {
|
|
|
type: null,
|
|
|
address: '',
|
|
@@ -28,7 +30,9 @@ Page({
|
|
|
wx.showLoading({
|
|
|
title: '加载中...',
|
|
|
});
|
|
|
- // console.log(this.data.searchKey)
|
|
|
+ this.setData({
|
|
|
+ isSearch: true
|
|
|
+ })
|
|
|
this.searchRoomList()
|
|
|
} else {
|
|
|
wx.showToast({
|
|
@@ -40,42 +44,78 @@ Page({
|
|
|
|
|
|
},
|
|
|
getRoomList() {
|
|
|
+
|
|
|
if (this.data.hasData) {
|
|
|
- util.request(api.BrandList, this.data.fetcherData).then((res) => {
|
|
|
- console.log(res)
|
|
|
- if (res.errno === 0) {
|
|
|
- if (res.data.data.length != 0) {
|
|
|
- this.setData({
|
|
|
- roomList: this.data.roomList.concat(res.data.data),
|
|
|
- 'fetcherData.page': this.data.fetcherData.page + 1
|
|
|
- })
|
|
|
-
|
|
|
- } else {
|
|
|
- this.setData({
|
|
|
- hasData: false
|
|
|
- })
|
|
|
+
|
|
|
+ if (!this.data.loading) {
|
|
|
+
|
|
|
+ this.setData({
|
|
|
+ loading: true
|
|
|
+ })
|
|
|
+
|
|
|
+ util.request(api.BrandList, this.data.fetcherData).then((res) => {
|
|
|
+ this.setData({
|
|
|
+ loading: false
|
|
|
+ })
|
|
|
+ if (res.errno === 0) {
|
|
|
+ if (res.data.data.length != 0) {
|
|
|
+ this.setData({
|
|
|
+ roomList: this.data.roomList.concat(res.data.data),
|
|
|
+ 'fetcherData.page': this.data.fetcherData.page + 1
|
|
|
+ })
|
|
|
+
|
|
|
+ } else {
|
|
|
+ this.setData({
|
|
|
+ hasData: false
|
|
|
+ })
|
|
|
+ }
|
|
|
}
|
|
|
- }
|
|
|
- });
|
|
|
+ }).catch(err => {
|
|
|
+ this.setData({
|
|
|
+ loading: false
|
|
|
+ })
|
|
|
+ });
|
|
|
+ }
|
|
|
+
|
|
|
} else {
|
|
|
console.log('没有更多数据')
|
|
|
}
|
|
|
|
|
|
},
|
|
|
- searchRoomList() {
|
|
|
+ reloadData() {
|
|
|
this.setData({
|
|
|
- 'fetcherData.page': 1,
|
|
|
- 'fetcherData.size': 100,
|
|
|
+ hasData: true
|
|
|
+ }, () => {
|
|
|
+ this.getRoomList()
|
|
|
})
|
|
|
- util.request(api.BrandList, this.data.fetcherData).then((res) => {
|
|
|
- wx.hideLoading()
|
|
|
- if (res.errno === 0) {
|
|
|
+ },
|
|
|
+ searchRoomList() {
|
|
|
+ if (!this.data.loading) {
|
|
|
+ this.setData({
|
|
|
+ loading: false
|
|
|
+ })
|
|
|
+ this.setData({
|
|
|
+ 'fetcherData.page': 1,
|
|
|
+ 'fetcherData.size': 100,
|
|
|
+ })
|
|
|
+ util.request(api.BrandList, this.data.fetcherData).then((res) => {
|
|
|
this.setData({
|
|
|
- roomList: res.data.data,
|
|
|
+ loading: false
|
|
|
})
|
|
|
+ wx.hideLoading()
|
|
|
+ if (res.errno === 0) {
|
|
|
+ this.setData({
|
|
|
+ roomList: res.data.data,
|
|
|
+ })
|
|
|
+
|
|
|
+ }
|
|
|
+ }).catch(err => {
|
|
|
+ this.setData({
|
|
|
+ loading: false
|
|
|
+ })
|
|
|
+ });
|
|
|
+ }
|
|
|
|
|
|
- }
|
|
|
- });
|
|
|
},
|
|
|
gotoWV: function (event) {
|
|
|
let id = event.detail
|
|
@@ -116,7 +156,9 @@ Page({
|
|
|
/**
|
|
|
* 生命周期函数--监听页面显示
|
|
|
*/
|
|
|
- onShow: function () {},
|
|
|
+ onShow: function () {
|
|
|
+
|
|
|
+ },
|
|
|
|
|
|
/**
|
|
|
* 生命周期函数--监听页面隐藏
|
|
@@ -143,7 +185,9 @@ Page({
|
|
|
* 页面上拉触底事件的处理函数
|
|
|
*/
|
|
|
onReachBottom: function () {
|
|
|
- this.getRoomList()
|
|
|
+ if (!this.data.isSearch) {
|
|
|
+ this.getRoomList()
|
|
|
+ }
|
|
|
},
|
|
|
|
|
|
/**
|