Commit 170141d4 by tianlonglong

首页

2 parents 7e7246ed 56a312e4
...@@ -46,6 +46,7 @@ ...@@ -46,6 +46,7 @@
"selectedColor": "#0069FF", "selectedColor": "#0069FF",
"borderStyle": "black", "borderStyle": "black",
"backgroundColor": "#ffffff", "backgroundColor": "#ffffff",
"custom": true,
"list": [ "list": [
{ {
"pagePath": "pages/accountHome/index", "pagePath": "pages/accountHome/index",
......
Component({
/**
* 页面的初始数据
*/
data: {
curClick: 1, // 判断当前点击的索引下标
list: [{
"pagePath": "/pages/index/index",
"iconPath": "../images/home.png",
"selectedIconPath": "../images/home-b.png",
"text": "首页",
"curr": 1
},
{
"pagePath": "/pages/home/index",
"iconPath": "../images/cong.png",
"selectedIconPath": "../images/cong-b.png",
"text": "工作台",
"curr": 2
},
{
"pagePath": "/pages/me/index",
"iconPath": "../images/me.png",
"selectedIconPath": "../images/me-b.png",
"text": "我的",
"curr": 3
}
]
},
attached:function(){
let userType = wx.getStorageSync('userrole_type');
if(userType==3){
this.setData({
curClick:2,
list:[
{
"pagePath": "/pages/home/index",
"iconPath": "../images/cong.png",
"selectedIconPath": "../images/cong-b.png",
"text": "工作台",
"curr": 2
},
{
"pagePath": "/pages/me/index",
"iconPath": "../images/me.png",
"selectedIconPath": "../images/me-b.png",
"text": "我的",
"curr": 3
}]
})
}
},
methods: {
NavChange(e) {
// 获取穿过来的参数
// let curIndex = e.currentTarget.dataset.cur;
// 获取穿过来的参数
let path = e.currentTarget.dataset.path;
// 更新data中值
wx.switchTab({
url: path,
})
},
}
})
\ No newline at end of file \ No newline at end of file
{
"component": true,
"usingComponents": {}
}
\ No newline at end of file \ No newline at end of file
<view class="tabbar_wrap">
<block>
<cover-view wx:for="{{list}}" wx:key="index" class="tabbar_item" bindtap="NavChange" data-cur="{{item.curr}}" data-path="{{item.pagePath}}">
<cover-image class="img" src="{{curClick==item.curr?item.selectedIconPath:item.iconPath}}"></cover-image>
<cover-view class="{{curClick==item.curr?'active text':'text'}}">
{{item.text}}
</cover-view>
</cover-view>
</block>
</view>
\ No newline at end of file \ No newline at end of file
.tabbar_wrap {
position: fixed;
bottom: 0;
left: 0;
right: 0;
width: 100%;
display: flex;
align-items: center;
background-color: #FFFFFF;
height: 110rpx;
border-top: 1px solid #CCc;
padding-bottom: env(safe-area-inset-bottom);
}
.tabbar_wrap .tabbar_item {
flex: 1;
display: flex;
justify-content: center;
flex-direction: column;
align-items: center;
}
.tabbar_wrap .tabbar_item .img {
width: 45rpx;
height: 45rpx;
}
.tabbar_wrap .tabbar_item .text {
font-size: 28rpx;
margin-top: 5rpx;
}
.tabbar_wrap .tabbar_item .active {
color: #597BFF;
}
.tabbar_wrap .tabbar_item .addBtn {
width: 90rpx;
height: 90rpx;
padding: 10rpx;
background-color: #Ffffff;
border-radius: 100rpx;
position: absolute;
top: -40rpx;
}
.tabbar_wrap .tabbar_item .subMsg {
font-size: 28rpx;
margin-top: 50rpx;
}
\ No newline at end of file \ No newline at end of file
...@@ -103,6 +103,15 @@ Page({ ...@@ -103,6 +103,15 @@ Page({
tourItems tourItems
}) })
}) })
this.activeTabBar(2)
},
activeTabBar(currentMenu) {
if (typeof this.getTabBar === 'function' && this.getTabBar()) {
this.getTabBar().setData({
// 当前页面的 tabBar 索引
curClick: currentMenu
})
}
}, },
goOtherPage: function(e) { goOtherPage: function(e) {
const { path } = e.currentTarget.dataset.value const { path } = e.currentTarget.dataset.value
......
...@@ -36,8 +36,16 @@ Page({ ...@@ -36,8 +36,16 @@ Page({
}) })
}, },
onShow: function() { onShow:function(){
this.activeTabBar(1)
},
activeTabBar(currentMenu) {
if (typeof this.getTabBar === 'function' && this.getTabBar()) {
this.getTabBar().setData({
// 当前页面的 tabBar 索引
curClick: currentMenu
})
}
}, },
backBtn(){ backBtn(){
this.setData({ this.setData({
......
...@@ -131,8 +131,12 @@ Page({ ...@@ -131,8 +131,12 @@ Page({
wx.setStorageSync({ data: datas[0].id, key: 'accountId' }) wx.setStorageSync({ data: datas[0].id, key: 'accountId' })
//wx.setStorage({ data: datas, key: 'accountList' }) //wx.setStorage({ data: datas, key: 'accountList' })
wx.setStorage({ data: datas[0].name, key: 'accountName' }) wx.setStorage({ data: datas[0].name, key: 'accountName' })
// wx.reLaunch({ url: '/pages/index/index' }) if(res.data.user.type==3){
wx.reLaunch({ url: '/pages/homes/index' }) wx.reLaunch({ url: '/pages/home/index' })
}else{
wx.reLaunch({ url: '/pages/index/index' })
}
} }
}) })
......
...@@ -26,6 +26,17 @@ Page({ ...@@ -26,6 +26,17 @@ Page({
this.setData({ name: name, accountName: accountName }) this.setData({ name: name, accountName: accountName })
this.getUserInfo() this.getUserInfo()
}, },
onShow:function(){
this.activeTabBar(3)
},
activeTabBar(currentMenu) {
if (typeof this.getTabBar === 'function' && this.getTabBar()) {
this.getTabBar().setData({
// 当前页面的 tabBar 索引
curClick: currentMenu
})
}
},
All(e){ All(e){
console.log(e) console.log(e)
}, },
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!