add file
This commit is contained in:
@@ -0,0 +1,103 @@
|
||||
// custom-tab-bar/index.js
|
||||
Component({
|
||||
|
||||
/**
|
||||
* 页面的初始数据
|
||||
*/
|
||||
data: {
|
||||
tabBarShow: true,
|
||||
active: 0,
|
||||
"backgroundColor": "#ffffff",
|
||||
"selectedColor": "#fff",
|
||||
"listAll": {
|
||||
"list2":[
|
||||
{
|
||||
"pagePath": "/Pages/yaoshi/home/home",
|
||||
"text": "首页",
|
||||
"iconPath": "/static/images/yaoshi/tabbar_icon/home.png",
|
||||
"selectedIconPath": "/static/images/yaoshi/tabbar_icon/home_select.png"
|
||||
},
|
||||
{
|
||||
"pagePath": "/Pages/yaoshi/my/my",
|
||||
"text": "我的",
|
||||
"iconPath": "/static/images/yaoshi/tabbar_icon/my.png",
|
||||
"selectedIconPath": "/static/images/yaoshi/tabbar_icon/my_select.png"
|
||||
}],
|
||||
"list1":[
|
||||
{
|
||||
"pagePath": "/Pages/yishi/index/index",
|
||||
"text": "首页(Y)",
|
||||
"iconPath": "/static/images/yishi/tabbar_icon/index.png",
|
||||
"selectedIconPath": "/static/images/yishi/tabbar_icon/index_select.png"
|
||||
},
|
||||
{
|
||||
"pagePath": "/Pages/yishi/wenzhen/wenzhen",
|
||||
"text": "问诊(Y)",
|
||||
"iconPath": "/static/images/yishi/tabbar_icon/wenzhen.png",
|
||||
"selectedIconPath": "/static/images/yishi/tabbar_icon/wenzhen_select.png"
|
||||
},
|
||||
{
|
||||
"pagePath": "/Pages/yishi/my/index",
|
||||
"text": "我的(Y)",
|
||||
"iconPath": "/static/images/yishi/tabbar_icon/my.png",
|
||||
"selectedIconPath": "/static/images/yishi/tabbar_icon/my_select.png"
|
||||
}]
|
||||
},
|
||||
items: [ ],
|
||||
dialog_visible: false,
|
||||
dialog_content: ""
|
||||
},
|
||||
attached() {
|
||||
const usertype = wx.getStorageSync('usertype')
|
||||
console.log("usertype: " ,usertype);
|
||||
if (usertype == 2) {
|
||||
this.setData({
|
||||
items: this.data.listAll.list1
|
||||
})
|
||||
}else{
|
||||
this.setData({
|
||||
items: this.data.listAll.list2
|
||||
})
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
// swichNav: function (e) {
|
||||
// console.log(123);
|
||||
// let that = this;
|
||||
// if (this.data.currentTab === e.target.dataset.current) {
|
||||
// return false;
|
||||
// } else {
|
||||
// that.setData({
|
||||
// currentTab: e.target.dataset.current
|
||||
// })
|
||||
// let url = e.currentTarget.dataset.url; // 点击tabbar时,跳转对应的页面
|
||||
// wx.switchTab({
|
||||
// url: url,
|
||||
// })
|
||||
// }
|
||||
// },
|
||||
onChange(e) {
|
||||
// this.setData({
|
||||
// dialog_visible: true,
|
||||
// dialog_content: "测试"
|
||||
// })
|
||||
console.log("custom tab bar onChange");
|
||||
// return;
|
||||
let url = this.data.items[e.detail].pagePath
|
||||
wx.switchTab({
|
||||
url: url,
|
||||
})
|
||||
},
|
||||
confirmDialog(){
|
||||
this.setData({
|
||||
dialog_visible: false
|
||||
})
|
||||
},
|
||||
cancelDialog(){
|
||||
this.setData({
|
||||
dialog_visible: false
|
||||
})
|
||||
},
|
||||
}
|
||||
|
||||
})
|
||||
@@ -0,0 +1,8 @@
|
||||
{
|
||||
"component": true,
|
||||
"usingComponents": {
|
||||
"van-tabbar": "@vant/weapp/tabbar/index",
|
||||
"van-tabbar-item": "@vant/weapp/tabbar-item/index",
|
||||
"t-dialog": "tdesign-miniprogram/dialog/dialog"
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,37 @@
|
||||
<!-- <view class="nav-tabs" wx:if="{{tabBarShow}}">
|
||||
<view class="tab-list {{currentTab == idx ? 'active' : 'default' }}" wx:for="{{items}}" wx:key="prototype" wx:for-index="idx" wx:for-item="item" data-current="{{idx}}" data-url="{{item.pagePath}}" bindtap="swichNav">
|
||||
<text class="tab-text" wx:for-index="idx" data-current="{{idx}}" src="{{currentTab == idx ? item.selectedIconPath : item.iconPath }}">{{item.text}}</text>
|
||||
<image class="iconPath" wx:for-index="idx" data-current="{{idx}}" src="{{currentTab == idx ? item.selectedIconPath : item.iconPath }}"></image>
|
||||
</view>
|
||||
</view> -->
|
||||
<van-tabbar active="{{ active }}" bind:change="onChange">
|
||||
<van-tabbar-item info="3" data-url="{{item.pagePath}}" url="{{item.pagePath}}" wx:for="{{items}}">
|
||||
<image
|
||||
slot="icon"
|
||||
src="{{ item.iconPath }}"
|
||||
data-url="{{ item.pagePath }}"
|
||||
mode="aspectFit"
|
||||
style="width: 30px; height: 18px;"
|
||||
/>
|
||||
<image
|
||||
slot="icon-active"
|
||||
src="{{ item.selectedIconPath }}"
|
||||
mode="aspectFit"
|
||||
style="width: 30px; height: 18px;"
|
||||
data-url="{{ item.pagePath }}"
|
||||
/>
|
||||
{{item.text}}
|
||||
</van-tabbar-item>
|
||||
</van-tabbar>
|
||||
<t-dialog
|
||||
visible="{{ dialog_visible }}"
|
||||
title="温馨提示"
|
||||
content="{{dialog_content}}"
|
||||
>
|
||||
<view slot="cancel-btn" class="dialog dialog_cancel_btn" bindtap="cancelDialog">
|
||||
取消
|
||||
</view>
|
||||
<view slot="confirm-btn" class="dialog dialog_confirm_btn" bindtap="confirmDialog">
|
||||
确定
|
||||
</view>
|
||||
</t-dialog>
|
||||
@@ -0,0 +1,83 @@
|
||||
/* page {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
height: 100%;
|
||||
}
|
||||
|
||||
.nav-tabs {
|
||||
width: 100%;
|
||||
display: flex;
|
||||
position: fixed;
|
||||
bottom: 0;
|
||||
}
|
||||
|
||||
.tab-list {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
flex-direction: column-reverse;
|
||||
background: #fcfcfc;
|
||||
height: 120rpx;
|
||||
|
||||
}
|
||||
|
||||
.tab-text {
|
||||
font-size: 24rpx;
|
||||
line-height: 35rpx;
|
||||
color: #5f5f5f;
|
||||
}
|
||||
|
||||
.iconPath {
|
||||
width:54rpx;
|
||||
height: 54rpx;
|
||||
}
|
||||
|
||||
.tab-content {
|
||||
flex: 1;
|
||||
}
|
||||
|
||||
.default {
|
||||
line-height: 75rpx;
|
||||
text-align: center;
|
||||
flex: 1;
|
||||
color: #eee;
|
||||
font-weight: bold;
|
||||
font-size: 28rpx;
|
||||
}
|
||||
|
||||
.active {
|
||||
line-height: 75rpx;
|
||||
text-align: center;
|
||||
background-color: #fff;
|
||||
flex: 1;
|
||||
font-weight: bold;
|
||||
font-size: 28rpx;
|
||||
}
|
||||
.active .tab-text {
|
||||
color: rgb(116,162,250);
|
||||
}
|
||||
|
||||
.show {
|
||||
display: block;
|
||||
flex: 1;
|
||||
}
|
||||
|
||||
.hidden {
|
||||
display: none;
|
||||
flex: 1;
|
||||
} */
|
||||
|
||||
.dialog{
|
||||
width: 50%;
|
||||
text-align: center;
|
||||
height: 100rpx;
|
||||
line-height: 100rpx;
|
||||
}
|
||||
.dialog_cancel_btn{
|
||||
border-top: 1px solid #E9E9E9;
|
||||
border-right: 1px solid #E9E9E9;
|
||||
}
|
||||
.dialog_confirm_btn{
|
||||
border-top: 1px solid #E9E9E9;
|
||||
color: #3CC7C0;
|
||||
}
|
||||
Reference in New Issue
Block a user