const Http = require("../../../utils/HttpBasics"); const imgurl = require("../../../utils/imgurl"); const config = require("../../../config/config"); let app = getApp(); Page({ /** * 页面的初始数据 */ data: { lists: [], indexId: 0, teljpgUrl: imgurl.teljpg.url, }, // 左侧点击事件 jumpIndex(e) { let index = e.currentTarget.dataset.menuindex let that = this that.setData({ indexId: index }); }, /** * 生命周期函数--监听页面加载 */ onLoad: function (options) { var that = this wx.getSystemInfo({ success: function (res) { that.setData({ winHeight: res.windowHeight }); } }); }, /** * 生命周期函数--监听页面初次渲染完成 */ onReady: function () { }, /** * 生命周期函数--监听页面显示 */ onShow: function () { let that = this; that.getBussiness(); that.getList(1); }, getBussiness:function(){ let that = this; Http.get({ url: config.api.businessList, data: { pageNum: 1, pageSize: 15, type: 1 } }).then(res => { console.log(res) let businessObj = [{ id: 0, title: "全部", type: 1 }]; that.setData({ lists: res.data.list.concat(businessObj).sort(compare("id")) }); console.log(that.data.lists) }) .catch(err => { wx.showToast({ title: err.errMsg, icon: 'none', duration: 2000, mask: false }); }) }, getList: function (pageNum) { let that = this; Http.get({ url: config.api.merchantList, data: { pageNum: pageNum, pageSize: 15 } }).then(res => { console.log(res) that.setData({ merchantVoList: res.data.list }) console.log(that.data.merchantVoList) }) .catch(err => { wx.showToast({ title: err.errMsg, icon: 'none', duration: 2000, mask: false }); }) }, phone: function (e) { let that = this; if (e.currentTarget.dataset.merchantlinkphone) { wx.makePhoneCall({ phoneNumber: e.currentTarget.dataset.merchantlinkphone }) } }, /** * 生命周期函数--监听页面隐藏 */ onHide: function () { }, /** * 生命周期函数--监听页面卸载 */ onUnload: function () { }, /** * 页面相关事件处理函数--监听用户下拉动作 */ onPullDownRefresh: function () { }, /** * 页面上拉触底事件的处理函数 */ onReachBottom: function () { } }) function compare(pro) { return function (obj2, obj1) { var val1 = obj1[pro]; var val2 = obj2[pro]; if (val1 < val2) { return 1; } else if (val1 > val2) { return -1; } else { return 0; } } }