diff --git a/pages/main/index.js b/pages/main/index.js index b2d928c..c3f1e35 100644 --- a/pages/main/index.js +++ b/pages/main/index.js @@ -7,7 +7,7 @@ let app = getApp(); Page({ data: { newUrl: "", - cover:"", + cover: "", usergift: imgurl.usergift.url, guanbi1: imgurl.guanbi1.url, icon0001: imgurl.icon0001.url, @@ -20,7 +20,7 @@ Page({ icon0008: imgurl.icon0008.url, barcode: imgurl.barcode.url, leftarrows: imgurl.leftarrows.url, - newcard:imgurl.newcard.url, + newcard: imgurl.newcard.url, newseckill: imgurl.newseckill.url, newbargain: imgurl.newbargain.url, newgroup: imgurl.newgroup.url, @@ -31,16 +31,16 @@ Page({ market: app.globalData.market, list: [], loading: true, - fistLogin:null, + fistLogin: null, alphaData: null, swiperCurrent: 0, title: null, - weappShareTitle:'',//分享标题 - weappShareCoverImg:'',//分享图片 + weappShareTitle: '', //分享标题 + weappShareCoverImg: '', //分享图片 desc: null, scrollTop: 0, showGame: false, - showTopic:false, + showTopic: false, gamedata: {}, couponId: '', //游戏返回时传回的字段 played: false, //从游戏页面跳回首页返回true @@ -49,35 +49,39 @@ Page({ showIf: false, showPages: false, display: 'none', - display1:'none', - optionsData:null, - credit:0, + display1: 'none', + optionsData: null, + credit: 0, score: '0', page: 1 // 刷新进入页面时已经加载了第一页数据,onReachBottom时 page++,从第2页开始加载 }, - close:function(){ + close: function() { this.setData({ - showIf:false + showIf: false }) }, - alphaClick: function (even) { + alphaClick: function(even) { var animation = wx.createAnimation({}) - animation.opacity(0).step({ duration: 2000 }) - this.setData({ alphaData: animation.export() }) + animation.opacity(0).step({ + duration: 2000 + }) + this.setData({ + alphaData: animation.export() + }) }, // 我的卡包 - mycard:function(){ + mycard: function() { wx.navigateTo({ url: '/pages/cardorder/index/index', }) }, //我的券包 - mycoupon:function(){ + mycoupon: function() { wx.navigateTo({ url: '/pages/couponorder/index/index', }) - }, - gotoSpellGroup:function(){ + }, + gotoSpellGroup: function() { wx.navigateTo({ url: '/pages/spellGroup/spellGroup', }) @@ -85,7 +89,7 @@ Page({ qrcode: function() { var that = this; let memberId = that.data.memberId; - if (memberId){ + if (memberId) { wx.navigateTo({ url: '/pages/specialcourtesy/specialcourtesy' }) @@ -98,31 +102,31 @@ Page({ // }) // }, //跳往限时秒杀 - gotoRushBuy: function () { + gotoRushBuy: function() { wx.navigateTo({ url: '/pages/rushToBuy/index', }) }, // 跳往卡列表 - gotodiscountcard: function () { + gotodiscountcard: function() { wx.navigateTo({ url: '/pages/discountCardList/discountCardList', }) }, //跳往积分商城 - gotouser:function(){ + gotouser: function() { wx.navigateTo({ url: `/pages/integralmall/index` }) }, //跳往砍价专场 - gobargain: function () { + gobargain: function() { wx.navigateTo({ url: '/pages/bargain/bargain', }) }, //跳往拼团专场 - gogroup: function () { + gogroup: function() { wx.navigateTo({ url: '/pages/spellGroup/spellGroup', }) @@ -133,7 +137,7 @@ Page({ // url: '/pages/index/searchbar/index', // }) // }, - + // createQrCode: function(url, canvasId, cavW, cavH) { // //调用插件中的draw方法,绘制二维码图片 // QR.api.draw(url, canvasId, cavW, cavH); @@ -205,7 +209,7 @@ Page({ played: true }) } - if (optionss.couponChannelId|| optionss.orderId) { + if (optionss.couponChannelId || optionss.orderId) { that.setData({ optionsData: optionss }) @@ -213,7 +217,7 @@ Page({ } else { that.userLogin() } - //获取条形码 + //获取条形码 // util.barcode("barcode", optionss.quancode, 510, 100); }, onShow: function() { @@ -221,49 +225,32 @@ Page({ that.setData({ havePlayEd: app.globalData.havePlayEd ? app.globalData.havePlayEd : false }) + /** + * couponNum 是否有普通的优惠券购买 + * couponNum2 是否有新买的消费卡 + */ let num = wx.getStorageSync('couponNum'); let num1 = wx.getStorageSync('couponNum2'); - if (num == 'couponNum') { - wx.showTabBarRedDot({ - index: 3 - }) - that.setData({ - display: "block" - }) - }else{ - wx.hideTabBarRedDot({ - index: 3 - }) - that.setData({ - display: "none" - }) - } - - if (num1 == 'couponNum2') { + + if (num == 'couponNum' || num1 == 'couponNum2') { wx.showTabBarRedDot({ index: 3 }) - that.setData({ - display1: "block" - }) } else { wx.hideTabBarRedDot({ index: 3 }) - that.setData({ - display1: "none" - }) } - console.log(app.globalData.score) - if (app.globalData.score){ + + if (app.globalData.score) { that.setData({ fistLogin: app.globalData.score }) } // 如果有游戏 - setTimeout(function(){ + setTimeout(function() { that.alphaClick(); - },8000) + }, 8000) }, // 会员码获取 getmemberId: function(token) { @@ -274,12 +261,11 @@ Page({ token: token } }).then(res => { - console.log(res) that.setData({ levelName: res.data.levelName, upgradePercent: res.data.upgradePercent, upgradeScore: res.data.upgradeScore, - credit: res.data.credit ? res.data.credit:0, + credit: res.data.credit ? res.data.credit : 0, score: res.data.score }) if (res.data.nickName) { @@ -287,11 +273,9 @@ Page({ ismember: true, memberId: res.data.id }) - // var size = this.setCanvasSize(); var initUrl = JSON.stringify({ flagid: res.data.id }); - // that.createQrCode(initUrl, "mycanvas1", size.w, size.h); } }) .catch(err => { @@ -302,7 +286,7 @@ Page({ }) }) }, - gotoChengzhangzhi:function(){ + gotoChengzhangzhi: function() { wx.navigateTo({ url: '/pages/czdetail/czdetail', }) @@ -320,7 +304,7 @@ Page({ console.log(e.detail.val) console.log(e.detail.pageNum) }, - onBargain:function(e){ + onBargain: function(e) { console.log(e) }, /** @@ -368,9 +352,8 @@ Page({ showCancel: false }); }); - }, - + getStaticGame(token) { let _this = this; Http.get({ @@ -385,7 +368,7 @@ Page({ showIf: true, newUrl: res.data.imgUrl }) - }else{ + } else { _this.setData({ showIf: false }) @@ -414,7 +397,7 @@ Page({ _this.setData({ showGame: true, }) - }else{ + } else { _this.setData({ showGame: false }) @@ -431,24 +414,24 @@ Page({ }) }, /** - * mallinfo - */ - getMallInfo: function (token) { + * mallinfo + */ + getMallInfo: function(token) { let that = this; Http.get({ - url: config.api.getMallInfo, - data: { - token: token, - } - }).then(res => { - that.setData({ - weappShareTitle: res.data.weappShareTitle ? res.data.weappShareTitle:null, - weappShareCoverImg: res.data.weappShareCoverImg ? res.data.weappShareCoverImg:null, + url: config.api.getMallInfo, + data: { + token: token, + } + }).then(res => { + that.setData({ + weappShareTitle: res.data.weappShareTitle ? res.data.weappShareTitle : null, + weappShareCoverImg: res.data.weappShareCoverImg ? res.data.weappShareCoverImg : null, + }); + }) + .catch(err => { + // 不需要错误提示 }); - }) - .catch(err => { - - }); }, /** * banner @@ -456,50 +439,49 @@ Page({ getBannerlist: function() { let that = this; Http.get({ - url: config.api.bannerlist, - data: { - pageNum: 1, - pageSize: 7 - } - }).then(res => { - // that.getmemberId(app.globalData.token); - // that.checkUserCarStatus(); - that.setData({ - list: res.data.list + url: config.api.bannerlist, + data: { + pageNum: 1, + pageSize: 7 + } + }).then(res => { + // that.getmemberId(app.globalData.token); + // that.checkUserCarStatus(); + that.setData({ + list: res.data.list + }); + }) + .catch(err => { + // that.getmemberId(app.globalData.token); + // that.checkUserCarStatus(); }); - }) - .catch(err => { - // that.getmemberId(app.globalData.token); - // that.checkUserCarStatus(); - }) - ; }, // 专题显示 - topicShow: function () { + topicShow: function() { let that = this; Http.get({ - url: config.api.topicShow, - data: { - token: app.globalData.token - } - }).then(res => { - if (res&&res.data){ - that.setData({ - cover: res.data.cover, - id: res.data.id, - showTopic: true - }) - }else{ - that.setData({ - showTopic: false - }) - } - }) - .catch(err => { - console.log(err); - }) + url: config.api.topicShow, + data: { + token: app.globalData.token + } + }).then(res => { + if (res && res.data) { + that.setData({ + cover: res.data.cover, + id: res.data.id, + showTopic: true + }) + } else { + that.setData({ + showTopic: false + }) + } + }) + .catch(err => { + console.log(err); + }) }, - gotoTopic(){ + gotoTopic() { wx.navigateTo({ url: `/pages/topicDetail/index?id=${this.data.id}` }) @@ -588,7 +570,7 @@ Page({ wx.stopPullDownRefresh(); }; // 砍价下拉刷新 - that.selectComponent("#bargain").getList(); + that.selectComponent("#bargain").getList(); that.selectComponent("#spellGroup").getList(); that.selectComponent("#rushtobyCard").getList(); wx.stopPullDownRefresh();