Browse Source

[tabbar][修改]:[修改tabbar的小红点]

tags/江西版6.1.0
meo 6 years ago
parent
commit
7bbc2d4b2d
1 changed files with 100 additions and 118 deletions
  1. +100
    -118
      pages/main/index.js

+ 100
- 118
pages/main/index.js View File

@@ -7,7 +7,7 @@ let app = getApp();
Page({ Page({
data: { data: {
newUrl: "", newUrl: "",
cover:"",
cover: "",
usergift: imgurl.usergift.url, usergift: imgurl.usergift.url,
guanbi1: imgurl.guanbi1.url, guanbi1: imgurl.guanbi1.url,
icon0001: imgurl.icon0001.url, icon0001: imgurl.icon0001.url,
@@ -20,7 +20,7 @@ Page({
icon0008: imgurl.icon0008.url, icon0008: imgurl.icon0008.url,
barcode: imgurl.barcode.url, barcode: imgurl.barcode.url,
leftarrows: imgurl.leftarrows.url, leftarrows: imgurl.leftarrows.url,
newcard:imgurl.newcard.url,
newcard: imgurl.newcard.url,
newseckill: imgurl.newseckill.url, newseckill: imgurl.newseckill.url,
newbargain: imgurl.newbargain.url, newbargain: imgurl.newbargain.url,
newgroup: imgurl.newgroup.url, newgroup: imgurl.newgroup.url,
@@ -31,16 +31,16 @@ Page({
market: app.globalData.market, market: app.globalData.market,
list: [], list: [],
loading: true, loading: true,
fistLogin:null,
fistLogin: null,
alphaData: null, alphaData: null,
swiperCurrent: 0, swiperCurrent: 0,
title: null, title: null,
weappShareTitle:'',//分享标题
weappShareCoverImg:'',//分享图片
weappShareTitle: '', //分享标题
weappShareCoverImg: '', //分享图片
desc: null, desc: null,
scrollTop: 0, scrollTop: 0,
showGame: false, showGame: false,
showTopic:false,
showTopic: false,
gamedata: {}, gamedata: {},
couponId: '', //游戏返回时传回的字段 couponId: '', //游戏返回时传回的字段
played: false, //从游戏页面跳回首页返回true played: false, //从游戏页面跳回首页返回true
@@ -49,35 +49,39 @@ Page({
showIf: false, showIf: false,
showPages: false, showPages: false,
display: 'none', display: 'none',
display1:'none',
optionsData:null,
credit:0,
display1: 'none',
optionsData: null,
credit: 0,
score: '0', score: '0',
page: 1 // 刷新进入页面时已经加载了第一页数据,onReachBottom时 page++,从第2页开始加载 page: 1 // 刷新进入页面时已经加载了第一页数据,onReachBottom时 page++,从第2页开始加载
}, },
close:function(){
close: function() {
this.setData({ this.setData({
showIf:false
showIf: false
}) })
}, },
alphaClick: function (even) {
alphaClick: function(even) {
var animation = wx.createAnimation({}) 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({ wx.navigateTo({
url: '/pages/cardorder/index/index', url: '/pages/cardorder/index/index',
}) })
}, },
//我的券包 //我的券包
mycoupon:function(){
mycoupon: function() {
wx.navigateTo({ wx.navigateTo({
url: '/pages/couponorder/index/index', url: '/pages/couponorder/index/index',
}) })
},
gotoSpellGroup:function(){
},
gotoSpellGroup: function() {
wx.navigateTo({ wx.navigateTo({
url: '/pages/spellGroup/spellGroup', url: '/pages/spellGroup/spellGroup',
}) })
@@ -85,7 +89,7 @@ Page({
qrcode: function() { qrcode: function() {
var that = this; var that = this;
let memberId = that.data.memberId; let memberId = that.data.memberId;
if (memberId){
if (memberId) {
wx.navigateTo({ wx.navigateTo({
url: '/pages/specialcourtesy/specialcourtesy' url: '/pages/specialcourtesy/specialcourtesy'
}) })
@@ -98,31 +102,31 @@ Page({
// }) // })
// }, // },
//跳往限时秒杀 //跳往限时秒杀
gotoRushBuy: function () {
gotoRushBuy: function() {
wx.navigateTo({ wx.navigateTo({
url: '/pages/rushToBuy/index', url: '/pages/rushToBuy/index',
}) })
}, },
// 跳往卡列表 // 跳往卡列表
gotodiscountcard: function () {
gotodiscountcard: function() {
wx.navigateTo({ wx.navigateTo({
url: '/pages/discountCardList/discountCardList', url: '/pages/discountCardList/discountCardList',
}) })
}, },
//跳往积分商城 //跳往积分商城
gotouser:function(){
gotouser: function() {
wx.navigateTo({ wx.navigateTo({
url: `/pages/integralmall/index` url: `/pages/integralmall/index`
}) })
}, },
//跳往砍价专场 //跳往砍价专场
gobargain: function () {
gobargain: function() {
wx.navigateTo({ wx.navigateTo({
url: '/pages/bargain/bargain', url: '/pages/bargain/bargain',
}) })
}, },
//跳往拼团专场 //跳往拼团专场
gogroup: function () {
gogroup: function() {
wx.navigateTo({ wx.navigateTo({
url: '/pages/spellGroup/spellGroup', url: '/pages/spellGroup/spellGroup',
}) })
@@ -133,7 +137,7 @@ Page({
// url: '/pages/index/searchbar/index', // url: '/pages/index/searchbar/index',
// }) // })
// }, // },
// createQrCode: function(url, canvasId, cavW, cavH) { // createQrCode: function(url, canvasId, cavW, cavH) {
// //调用插件中的draw方法,绘制二维码图片 // //调用插件中的draw方法,绘制二维码图片
// QR.api.draw(url, canvasId, cavW, cavH); // QR.api.draw(url, canvasId, cavW, cavH);
@@ -205,7 +209,7 @@ Page({
played: true played: true
}) })
} }
if (optionss.couponChannelId|| optionss.orderId) {
if (optionss.couponChannelId || optionss.orderId) {
that.setData({ that.setData({
optionsData: optionss optionsData: optionss
}) })
@@ -213,7 +217,7 @@ Page({
} else { } else {
that.userLogin() that.userLogin()
} }
//获取条形码
//获取条形码
// util.barcode("barcode", optionss.quancode, 510, 100); // util.barcode("barcode", optionss.quancode, 510, 100);
}, },
onShow: function() { onShow: function() {
@@ -221,49 +225,32 @@ Page({
that.setData({ that.setData({
havePlayEd: app.globalData.havePlayEd ? app.globalData.havePlayEd : false havePlayEd: app.globalData.havePlayEd ? app.globalData.havePlayEd : false
}) })
/**
* couponNum 是否有普通的优惠券购买
* couponNum2 是否有新买的消费卡
*/
let num = wx.getStorageSync('couponNum'); let num = wx.getStorageSync('couponNum');
let num1 = wx.getStorageSync('couponNum2'); 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({ wx.showTabBarRedDot({
index: 3 index: 3
}) })
that.setData({
display1: "block"
})
} else { } else {
wx.hideTabBarRedDot({ wx.hideTabBarRedDot({
index: 3 index: 3
}) })
that.setData({
display1: "none"
})
} }
console.log(app.globalData.score)
if (app.globalData.score){

if (app.globalData.score) {
that.setData({ that.setData({
fistLogin: app.globalData.score fistLogin: app.globalData.score
}) })
} }
// 如果有游戏 // 如果有游戏
setTimeout(function(){
setTimeout(function() {
that.alphaClick(); that.alphaClick();
},8000)
}, 8000)
}, },
// 会员码获取 // 会员码获取
getmemberId: function(token) { getmemberId: function(token) {
@@ -274,12 +261,11 @@ Page({
token: token token: token
} }
}).then(res => { }).then(res => {
console.log(res)
that.setData({ that.setData({
levelName: res.data.levelName, levelName: res.data.levelName,
upgradePercent: res.data.upgradePercent, upgradePercent: res.data.upgradePercent,
upgradeScore: res.data.upgradeScore, upgradeScore: res.data.upgradeScore,
credit: res.data.credit ? res.data.credit:0,
credit: res.data.credit ? res.data.credit : 0,
score: res.data.score score: res.data.score
}) })
if (res.data.nickName) { if (res.data.nickName) {
@@ -287,11 +273,9 @@ Page({
ismember: true, ismember: true,
memberId: res.data.id memberId: res.data.id
}) })
// var size = this.setCanvasSize();
var initUrl = JSON.stringify({ var initUrl = JSON.stringify({
flagid: res.data.id flagid: res.data.id
}); });
// that.createQrCode(initUrl, "mycanvas1", size.w, size.h);
} }
}) })
.catch(err => { .catch(err => {
@@ -302,7 +286,7 @@ Page({
}) })
}) })
}, },
gotoChengzhangzhi:function(){
gotoChengzhangzhi: function() {
wx.navigateTo({ wx.navigateTo({
url: '/pages/czdetail/czdetail', url: '/pages/czdetail/czdetail',
}) })
@@ -320,7 +304,7 @@ Page({
console.log(e.detail.val) console.log(e.detail.val)
console.log(e.detail.pageNum) console.log(e.detail.pageNum)
}, },
onBargain:function(e){
onBargain: function(e) {
console.log(e) console.log(e)
}, },
/** /**
@@ -368,9 +352,8 @@ Page({
showCancel: false showCancel: false
}); });
}); });

}, },
getStaticGame(token) { getStaticGame(token) {
let _this = this; let _this = this;
Http.get({ Http.get({
@@ -385,7 +368,7 @@ Page({
showIf: true, showIf: true,
newUrl: res.data.imgUrl newUrl: res.data.imgUrl
}) })
}else{
} else {
_this.setData({ _this.setData({
showIf: false showIf: false
}) })
@@ -414,7 +397,7 @@ Page({
_this.setData({ _this.setData({
showGame: true, showGame: true,
}) })
}else{
} else {
_this.setData({ _this.setData({
showGame: false showGame: false
}) })
@@ -431,24 +414,24 @@ Page({
}) })
}, },
/** /**
* mallinfo
*/
getMallInfo: function (token) {
* mallinfo
*/
getMallInfo: function(token) {
let that = this; let that = this;
Http.get({ 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 * banner
@@ -456,50 +439,49 @@ Page({
getBannerlist: function() { getBannerlist: function() {
let that = this; let that = this;
Http.get({ 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; let that = this;
Http.get({ 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({ wx.navigateTo({
url: `/pages/topicDetail/index?id=${this.data.id}` url: `/pages/topicDetail/index?id=${this.data.id}`
}) })
@@ -588,7 +570,7 @@ Page({
wx.stopPullDownRefresh(); wx.stopPullDownRefresh();
}; };
// 砍价下拉刷新 // 砍价下拉刷新
that.selectComponent("#bargain").getList();
that.selectComponent("#bargain").getList();
that.selectComponent("#spellGroup").getList(); that.selectComponent("#spellGroup").getList();
that.selectComponent("#rushtobyCard").getList(); that.selectComponent("#rushtobyCard").getList();
wx.stopPullDownRefresh(); wx.stopPullDownRefresh();


Loading…
Cancel
Save