const app = getApp(); var http = require("../../utils/http.js"); Page({ /** * 页面的初始数据 */ data: { picImg:http.picImg, current: 1, size: 20, nvabarData: { showCapsule: 1, //是否显示左上角图标 1表示显示 0表示不显示 title: "历史油价", //导航栏 中间的标题 }, stationName: "", oilPriceList: [], total: 0, // 此页面 页面内容距最顶部的距离 height: app.globalData.height * 2 + 20, currentCooPrice:'', currentPrice:'' }, /** * 生命周期函数--监听页面加载 */ onLoad() { this.getOilHistory(); const cooperation = wx.getStorageSync("cooperation"); this.setData({ stationName: cooperation.company, settlementType:cooperation.settlementType//1--价格 2--公斤 }); }, getOilHistory: function () { var that = this; wx.request({ url: app.globalData.devUrl + `/zx/user/coo-user-history/${ wx.getStorageSync("cooperation").id }?current=${that.data.current}&size=20`, method: `GET`, header: { "content-type": "application/x-www-form-urlencoded", }, success: function (res) { if (res.data.code == "0000") { let newData = that.data.oilPriceList; if (that.data.current === 1) { newData = res.data.data.records; } else { newData = newData.concat(res.data.data.records); } that.setData({ oilPriceList: newData, total: res.data.data.total, currentCooPrice:newData[0].cooPrice, currentPrice:newData[0].price, }); } wx.stopPullDownRefresh() }, error: function () { console.log(res); }, fail: function (data) { wx.showModal({ title: "提示", content: "网络传输异常", showCancel: false, }); }, }); }, /** * 生命周期函数--监听页面初次渲染完成 */ onReady() {}, /** * 生命周期函数--监听页面显示 */ onShow() {}, /** * 生命周期函数--监听页面隐藏 */ onHide() {}, /** * 生命周期函数--监听页面卸载 */ onUnload() {}, /** * 页面相关事件处理函数--监听用户下拉动作 */ onPullDownRefresh() { const current = 1; this.setData({ current, }); this.getOilHistory(); }, /** * 页面上拉触底事件的处理函数 */ onReachBottom() { if (this.data.oilPriceList.length >= this.data.total) { wx.showToast({ title: "没有更多数据了", }); } else { const current = this.data.current + 1; this.setData({ current, }); this.getOilHistory(); } }, /** * 用户点击右上角分享 */ onShareAppMessage() {}, });