Browse Source

bug修改

feature/v1.1.0
xpz2018 6 years ago
parent
commit
d2620d9d6a
1 changed files with 48 additions and 37 deletions
  1. 85
      pages/index/index.js

85
pages/index/index.js

@ -14,11 +14,26 @@ Page({
// merchantNo: '', // merchantNo: '',
// bannerImage: '/images/activity_banner.png', // 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(), nowDate: new Date().getTime(),
activityList: [], activityList: [],
@ -32,40 +47,36 @@ Page({
/** /**
* 城市选择 * 城市选择
*/ */
bindAddrChange: function (e) {
bindAddrChange: function(e) {
this.setData({ this.setData({
_num: e.detail.value + 1,
addrIndex: e.detail.value
}),
_num: e.detail.value + 1,
addrIndex: e.detail.value
}),
this.getActivityList(); this.getActivityList();
}, },
/** /**
* 生命周期函数--监听页面加载 * 生命周期函数--监听页面加载
*/ */
onShow: function (options) {
onShow: function(options) {
let that = this; let that = this;
//获取本地数据 //获取本地数据
// 获取地址 // 获取地址
wx.getStorage({ wx.getStorage({
key: 'districtName', key: 'districtName',
success: function (res) {
success: function(res) {
that.setData({ that.setData({
districtName: res.data districtName: res.data
}) })
} }
}); });
// 商家编号 // 商家编号
wx.getStorage({ wx.getStorage({
key: 'merchantNo', 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({ wx.request({
url: app.gw.hostUrl + '/mall/wxa/activity/banner', url: app.gw.hostUrl + '/mall/wxa/activity/banner',
method: 'get', method: 'get',
@ -75,7 +86,7 @@ Page({
header: { header: {
'Content-Type': 'application/x-www-form-urlencoded' 'Content-Type': 'application/x-www-form-urlencoded'
}, },
success: function (res) {
success: function(res) {
var data = res.data; var data = res.data;
var status = data.code; var status = data.code;
if (status == 0) { if (status == 0) {
@ -93,7 +104,7 @@ Page({
return; return;
} }
}, },
fail: function (res) {
fail: function(res) {
wx.showToast({ wx.showToast({
title: '加载数据失败', title: '加载数据失败',
}); });
@ -102,11 +113,11 @@ Page({
} }
}); });
}, },
getActivityList: function () {
getActivityList: function() {
let that = this; let that = this;
wx.showNavigationBarLoading() //在标题栏中显示加载 wx.showNavigationBarLoading() //在标题栏中显示加载
console.log("districtName:" + that.districtName); console.log("districtName:" + that.districtName);
@ -114,14 +125,14 @@ Page({
url: app.gw.hostUrl + '/mall/wxa/activity/list', url: app.gw.hostUrl + '/mall/wxa/activity/list',
method: 'get', method: 'get',
data: { data: {
merchantNo:merchantNo,
merchantNo: that.data.merchantNo,
pageNum: that.data.pageNum, pageNum: that.data.pageNum,
pageSize: that.data.pageSize pageSize: that.data.pageSize
}, },
header: { header: {
'Content-Type': 'application/x-www-form-urlencoded' 'Content-Type': 'application/x-www-form-urlencoded'
}, },
success: function (res) {
success: function(res) {
var data = res.data; var data = res.data;
var status = data.code; var status = data.code;
console.log(res); console.log(res);
@ -154,13 +165,13 @@ Page({
return; return;
} }
}, },
fail: function (res) {
fail: function(res) {
wx.showToast({ wx.showToast({
title: '加载数据失败', title: '加载数据失败',
}); });
console.log(res) console.log(res)
}, },
complete: function (res) {
complete: function(res) {
// complete // complete
wx.hideNavigationBarLoading() //完成停止加载 wx.hideNavigationBarLoading() //完成停止加载
wx.stopPullDownRefresh() //停止下拉刷新 wx.stopPullDownRefresh() //停止下拉刷新
@ -168,11 +179,11 @@ Page({
}) })
}, },
/** /**
* 点击去开团 * 点击去开团
*/ */
openGroup: function (e) {
openGroup: function(e) {
console.log('activityNo:' + e.currentTarget.dataset.item); console.log('activityNo:' + e.currentTarget.dataset.item);
wx.navigateTo({ wx.navigateTo({
url: '../activity_detail/activity_detail?activityNo=' + e.currentTarget.dataset.item, 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; let that = this;
this.data.pageNum = 1; this.data.pageNum = 1;
this.getActivityList(); this.getActivityList();
@ -215,7 +226,7 @@ Page({
/** /**
* 页面上拉触底事件的处理函数 * 页面上拉触底事件的处理函数
*/ */
onReachBottom: function () {
onReachBottom: function() {
if (this.data.hasMoreData) { if (this.data.hasMoreData) {
this.getActivityList(); this.getActivityList();
} else { } else {
@ -228,10 +239,10 @@ Page({
/** /**
* 用户点击右上角分享 * 用户点击右上角分享
*/ */
onShareAppMessage: function () {
onShareAppMessage: function() {
}, },
getUserInfo: function (e) {
getUserInfo: function(e) {
console.log(e) console.log(e)
app.globalData.userInfo = e.detail.userInfo app.globalData.userInfo = e.detail.userInfo
this.setData({ this.setData({

Loading…
Cancel
Save