// packageH/communityStoreDetails/communityStoreDetails.js var app = getApp(); var location = require("../../../mybehaviors/location/location"); Page({ behaviors: [location], /** * 页面的初始数据 */ data: { show: false, communityStoreDetails: null, communityId: 0, Height: "340rpx", isMoreShow: false, stores: [], point: {}, address: "", city: "", search: "", preSearch: "", currentPage: 1, totalPage: 0, iPnoneBottomBol: false, openTemplate: 0 //门店列表样式 }, /** * 生命周期函数--监听页面加载 */ onLoad: async function (options) { this.getiPnoneBottom(); try { // this._initData(); if (options.id) { this.setData({ communityId: options.id, }); } else if (!this.data.communityId) { wx.navigateTo({ url: "/packageH/o2o/communityStore/communityStore", }); } this._getLocation((mapdata, e) => { this._getData(); }); } catch (e) { console.error(e); } }, initData() { this.setData({ stores: [], totalPage: 0, currentPage: 1, }); }, _getData() { this.initData(); let _that = this; let tempNoDatas = false; let urlStr = app.getNetAddresss("plugin.store-community.frontend.community.getInfo"); // console.info(_that.data, '=---', !_that.data.city, _that.data.noDatas) if (!_that.data.communityId) { _that.setData({ noDatas: true, }); return; } // console.error(_that.data.lat) app._getNetWork({ url: urlStr, data: { lng: _that.data.point.lng, lat: _that.data.point.lat, community_id: _that.data.communityId, page: _that.data.currentPage, kwd: _that.data.search, }, success: function (resdata) { let res = resdata.data; // console.info(resdata) if (res.result === 1) { console.info(res); let store_list = res.data.store_list; let datas = store_list ? store_list.data : []; if (datas.length === 0) { tempNoDatas = true; } if (res.data.info.explain) { res.data.info.explain = res.data.info.explain.replace(/]+>/g, "").replace(/ /gi, ""); }, /** * 生命周期函数--监听页面初次渲染完成 */ onReady: function () {}, /** * 生命周期函数--监听页面显示 */ onShow: function () {}, /** * 生命周期函数--监听页面隐藏 */ onHide: function () {}, _getMoreData() { let _that = this; let urlStr = app.getNetAddresss("plugin.store-community.frontend.community.getInfo"); app._getNetWork({ url: urlStr, data: { lng: _that.data.point.lng, lat: _that.data.point.lat, community_id: _that.data.communityId, page: _that.data.currentPage, kwd: _that.data.search, }, success: function (resdata) { let res = resdata.data; if (res.result === 1) { console.info(res); let store_list = res.data.store_list; let nextData = store_list ? store_list.data : []; let datas = [..._that.data.stores, ...nextData]; _that.setData({ stores: datas, }); } }, fail: function (res) { console.log(res); }, }); }, /** * 页面上拉触底事件的处理函数 */ onReachBottom: function () { console.info(this.data.totalPage, this.data.currentPage); if (this.data.totalPage !== 0 && this.data.totalPage > this.data.currentPage) { this.setData({ currentPage: this.data.currentPage + 1, }); this._getMoreData(); } }, /** * 用户点击右上角分享 */ onShareAppMessage: function () {}, });