dev
xiaowen 3 years ago
parent 1b3a1fed98
commit cfa3037c0b

@ -1,3 +1,4 @@
const app = getApp();
Component({
data: {
selected: null, //当前选中的tab下标
@ -51,9 +52,31 @@ Component({
init() {
const page = getCurrentPages().pop();
let n = this.data.list.findIndex(item => item.pagePath === `${page.route}`);
this.setData({
selected: n
});
if(n === 2) {
app.globalData.request({
action: 'getUserMainBrand',
token: wx.getStorageSync('token') || 't%2BrswgjvzGM='
}).then(res => {
app.globalData.request({
action: "getUserBrandHome",
brandname: res
}).then(data => {
let brandObj = data[0];
let arr = this.data.list;
arr[2].selectedIconPath = brandObj.img;
this.setData({
list: arr,
selected: n
});
})
})
} else {
this.setData({
selected: n
});
}
}
},
})

@ -1,7 +1,7 @@
<view class="tab-bar">
<view wx:for="{{list}}" wx:key="index" class="tab-bar-item {{item.diyClass}}" data-path="{{item.pagePath}}" data-index="{{index}}" bindtap="switchTab">
<image src="{{selected === index ? item.selectedIconPath : item.iconPath}}" class="{{item.diyClass}}" mode="aspectFit"/>
<view style="color: {{selected === index ? selectedColor : color}}" class="{{item.diyClass}}">{{item.text}}</view>
<view style="color: {{selected === index ? selectedColor : color}}" class="{{item.diyClass}} {{item.diyClass ? 'activeBg' : ''}}">{{item.text}}</view>
</view>
</view>

@ -56,17 +56,19 @@
height: 140rpx;
bottom: 25.6%;
z-index: 100;
border-top-left-radius: 140rpx;
border-top-right-radius: 140rpx;
border-radius: 140rpx;
background: #fff;
}
.tab-bar-item view.diy {
margin-top: 90rpx;
background: #fff;
width: 100%;
height: 100%;
padding-top: 58rpx;
z-index: 99;
background: #fff;
}
.activeBg {
background: #0579FF;
}

@ -29,6 +29,7 @@ Page({
dataOption: {}
},
onShow() {
this.getTabBar().init();
this.getBrand().then((res) => {
let headlBrand = res;
this.setData({

Loading…
Cancel
Save