123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134 |
- // pages/store/store.js
- const util = require('../../utils/util.js');
- const api = require('../../config/api.js');
- const app = getApp()
- Page({
- /**
- * 页面的初始数据
- */
- data: {
- type: 21,
- storeList: [],
- hasData: true,
- loading:false,
- fetcherData: {
- type: 21,
- address: '',
- page: 1,
- size: 20,
- name: ''
- }
- },
- gotoWV: function (event) {
- let id = event.detail
- wx.navigateTo({
- url: `/pages/webview/index?id=${id}`,
- })
- },
- toSearch(e) {
- var type = e.currentTarget.dataset.type
- console.log(type)
- wx.navigateTo({
- url: `/pages/searchRoom/searchRoom?type=` + type
- })
- },
- getStoreList() {
- if (this.data.hasData) {
- if(!this.data.loading){
- this.setData({
- loading:true
- })
- wx.showLoading({
- title: '加载中...',
- })
- 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({
- storeList: this.data.storeList.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('没有更多数据')
- }
- },
- /**
- * 生命周期函数--监听页面加载
- */
- onLoad: function (options) {
- getApp().checkNetStatu();
- this.getStoreList()
- },
- /**
- * 生命周期函数--监听页面初次渲染完成
- */
- onReady: function () {
- },
- /**
- * 生命周期函数--监听页面显示
- */
- onShow: function () {
- },
- /**
- * 生命周期函数--监听页面隐藏
- */
- onHide: function () {
- },
- /**
- * 生命周期函数--监听页面卸载
- */
- onUnload: function () {
- },
- /**
- * 页面相关事件处理函数--监听用户下拉动作
- */
- onPullDownRefresh() {
- this.setData({
- storeList: [],
- 'fetcherData.page': 1,
- hasData: true
- });
- this.getStoreList()
- app.onPullDownRefresh()
- },
- onReachBottom: function () {
- this.getStoreList()
- console.log('onReachBottom')
- },
- /**
- * 用户点击右上角分享
- */
- onShareAppMessage: function () {
- }
- })
|