diff --git a/pages/index/index.js b/pages/index/index.js index b25374c..dc34622 100644 --- a/pages/index/index.js +++ b/pages/index/index.js @@ -14,11 +14,26 @@ Page({ // merchantNo: '', // bannerImage: '/images/activity_banner.png', - menu_list: [ - { name: '拼团', disabled: false, className: 'green_button' }, - { name: '秒杀', disabled: true, className: 'gray_button' }, - { name: '夺宝', disabled: true, className: 'gray_button' }, - { name: '砍价', disabled: true, className: 'gray_button' } + menu_list: [{ + name: '拼团', + disabled: false, + className: 'green_button' + }, + { + name: '秒杀', + disabled: true, + className: 'gray_button' + }, + { + name: '夺宝', + disabled: true, + className: 'gray_button' + }, + { + name: '砍价', + disabled: true, + className: 'gray_button' + } ], nowDate: new Date().getTime(), activityList: [], @@ -32,40 +47,36 @@ Page({ /** * 城市选择 */ - bindAddrChange: function (e) { + bindAddrChange: function(e) { this.setData({ - _num: e.detail.value + 1, - addrIndex: e.detail.value - }), + _num: e.detail.value + 1, + addrIndex: e.detail.value + }), this.getActivityList(); }, /** * 生命周期函数--监听页面加载 */ - onShow: function (options) { + onShow: function(options) { let that = this; //获取本地数据 // 获取地址 wx.getStorage({ key: 'districtName', - success: function (res) { + success: function(res) { that.setData({ districtName: res.data }) } - + }); - + // 商家编号 wx.getStorage({ key: 'merchantNo', - success: function (res) { - that.setData({ - merchantNo: res.data - }), - that.getActivityList(res.data); - merchantNo = res.data - that.getActivityList(); + success: function(res) { + that.setData({ merchantNo: res.data }), + that.getActivityList(); wx.request({ url: app.gw.hostUrl + '/mall/wxa/activity/banner', method: 'get', @@ -75,7 +86,7 @@ Page({ header: { 'Content-Type': 'application/x-www-form-urlencoded' }, - success: function (res) { + success: function(res) { var data = res.data; var status = data.code; if (status == 0) { @@ -93,7 +104,7 @@ Page({ return; } }, - fail: function (res) { + fail: function(res) { wx.showToast({ title: '加载数据失败', }); @@ -102,11 +113,11 @@ Page({ } }); - + }, - getActivityList: function () { + getActivityList: function() { let that = this; wx.showNavigationBarLoading() //在标题栏中显示加载 console.log("districtName:" + that.districtName); @@ -114,14 +125,14 @@ Page({ url: app.gw.hostUrl + '/mall/wxa/activity/list', method: 'get', data: { - merchantNo:merchantNo, + merchantNo: that.data.merchantNo, pageNum: that.data.pageNum, pageSize: that.data.pageSize }, header: { 'Content-Type': 'application/x-www-form-urlencoded' }, - success: function (res) { + success: function(res) { var data = res.data; var status = data.code; console.log(res); @@ -154,13 +165,13 @@ Page({ return; } }, - fail: function (res) { + fail: function(res) { wx.showToast({ title: '加载数据失败', }); console.log(res) }, - complete: function (res) { + complete: function(res) { // complete wx.hideNavigationBarLoading() //完成停止加载 wx.stopPullDownRefresh() //停止下拉刷新 @@ -168,11 +179,11 @@ Page({ }) }, - + /** * 点击去开团 */ - openGroup: function (e) { + openGroup: function(e) { console.log('activityNo:' + e.currentTarget.dataset.item); wx.navigateTo({ url: '../activity_detail/activity_detail?activityNo=' + e.currentTarget.dataset.item, @@ -181,7 +192,7 @@ Page({ /** * 生命周期函数--监听页面初次渲染完成 */ - onReady: function () { + onReady: function() { }, @@ -192,21 +203,21 @@ Page({ /** * 生命周期函数--监听页面隐藏 */ - onHide: function () { + onHide: function() { }, /** * 生命周期函数--监听页面卸载 */ - onUnload: function () { + onUnload: function() { }, /** * 页面相关事件处理函数--监听用户下拉动作 */ - onPullDownRefresh: function () { + onPullDownRefresh: function() { let that = this; this.data.pageNum = 1; this.getActivityList(); @@ -215,7 +226,7 @@ Page({ /** * 页面上拉触底事件的处理函数 */ - onReachBottom: function () { + onReachBottom: function() { if (this.data.hasMoreData) { this.getActivityList(); } else { @@ -228,10 +239,10 @@ Page({ /** * 用户点击右上角分享 */ - onShareAppMessage: function () { + onShareAppMessage: function() { }, - getUserInfo: function (e) { + getUserInfo: function(e) { console.log(e) app.globalData.userInfo = e.detail.userInfo this.setData({