const util = require('../../utils/util') const app = getApp() Page({ /** * 页面的初始数据 */ data: { storeList:[], selectH: 0, searchParams:{ storeId: '', storeName: '', pageNo: 1, pageSize: 20, schemeName: '' }, loadding: false, pullUpOn: true, schemeList:[] }, /** * 生命周期函数--监听页面加载 */ onLoad: function (options) { this.bindStoreList() this.bindScheme() }, onUnload: function () { wx.reLaunch({ url: '../vendingMachine/index', }) }, /** * 页面相关事件处理函数--监听用户下拉动作 */ onPullDownRefresh: function () { this.setData({ ["searchParams.pageNo"]: 1, pullUpOn: true, loadding: false, schemeList: [] }) this.bindScheme() setTimeout(() => { wx.stopPullDownRefresh() }, 300); }, /** * 页面上拉触底事件的处理函数 */ onReachBottom: function () { var that = this //只是测试效果,逻辑以实际数据为准 this.setData({ loadding: true, pullUpOn: true }) this.setData({ ["searchParams.pageNo"]: that.data.searchParams.pageNo + 1 }) this.bindScheme() }, bindStorePickerChange: function (e) { var item = this.data.storeList[e.detail.value] console.log(item) this.setData({ ['searchParams.storeId']: item.id, ['searchParams.storeName']: item.storeName, ["searchParams.pageNo"]: 1, pullUpOn: true, loadding: false, schemeList: [] }) this.bindScheme() }, showSearchModel: function() { this.setData({ selectH: 200 }) }, hideSearchModel: function() { this.setData({ selectH: 0 }) }, clearSearch(){ }, submitSearch(){ this.setData({ selectH: 0 }) }, toAddScheme(){ wx.navigateTo({ url: '/pages/scheme/form', }) }, bindStoreList() { var that = this util.request(util.api.storeList, {}, "GET", false, true,app.globalData.token).then((res) => { if (res.code == 200) { that.setData({ storeList: res.result }) } }).catch((res) => {}) }, inputedit: function (e) { let _this = this; let dataset = e.currentTarget.dataset; let value = e.detail.value; let name = dataset.name; _this.data[name] = value; _this.setData({ [name]: _this.data[name] }); }, bindScheme(){ var that = this console.log("3333") console.log(that.data.searchParams) console.log("4444") util.request(util.api.schemeListPage, that.data.searchParams, "GET", false, false, app.globalData.token).then((res) => { if (res.code == 200) { if (res.result.records.length > 0) { if (that.data.schemeList.length > 0) { let list = that.data.schemeList res.result.records.forEach((e)=>{ list.push(e) }) that.setData({ schemeList: list }) } else { that.setData({ schemeList: res.result.records }) } } else { that.setData({ loadding: false, pullUpOn: false, ["searchParams.pageNo"]:that.data.searchParams.pageNo-1 }) } console.log("555") console.log(that.data.schemeList) console.log("666") } }).catch((res) => {}) }, toEdit(e){ wx.navigateTo({ url: '/pages/scheme/form?id='+e.currentTarget.dataset.id, }) }, btnSearch(){ console.log("1111") console.log(this.data.searchParams) console.log("2222") this.setData({ ["searchParams.pageNo"]: 1, pullUpOn: true, loadding: false, schemeList: [] }) this.bindScheme() } })