123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147 |
- <template>
- <view class="tabbar align-center" >
- <view v-for="(item, index) in tabbarList" :key="index" @click="switchTabs(item)"
- class="tablist" v-if="item.isshowed">
- <view class="tabbar-list" >
- <image :src="actindex==index?item.selectedIconPath:item.iconPath"></image>
- <text class="fs24 base-textcol"
- :class="actindex==index?'actcolor':'morecolor'">{{item.Text}}</text>
- </view>
- </view>
- </view>
- </template>
- <script>
- import {getUserInfo} from '@/api/user'
- export default {
- name: "tabbar",
- props: {
- actindex: {
- type: Number,
- default: 0,
- }
- },
- data() {
- return {
- tabbarList: [],
- userinfoa:[],
- isuser:false
- };
- },
- mounted() {
- this.themeicon()
-
- this.$nextTick(()=>{
- if(uni.getStorageSync('AppToken')){
- this.getUserInfos()
- }else{
- this.isuser=true
- this.tabbarList[2].isshowed=true
- }
- })
- },
- methods: {
- getUserInfos(){
- getUserInfo().then(
- res => {
- if(res.code==200){
- if(res.user!=null){
- this.userinfoa=res.user
- }
- }else{
- uni.showToast({
- icon:'none',
- title: "请求失败",
- });
- }
- },
- rej => {}
- );
- },
- switchTabs(item) {
- console.log(12223)
- uni.switchTab({
- url: item.url
- })
- },
- themeicon() {
- this.tabbarList = [{
- iconPath: "/static/images/home.png",
- selectedIconPath: "/static/images/home_on.png",
- Text: '首页',
- url: '/pages/home/index',
- isshowed:true
- },
- {
- iconPath: "/static/images/ENCYCLOPEDIA.png",
- selectedIconPath: "/static/images/ENCYCLOPEDIA_on.png",
- Text: '学习',
- url: '/pages/course/index',
- isshowed:true
- },
- {
- iconPath: "/static/images/ENCYCLOPEDIA.png",
- selectedIconPath: "/static/images/ENCYCLOPEDIA_on.png",
- Text: '健康百科',
- url: '/pages/healthy/index',
- isshowed:true
- },
- {
- iconPath: "/static/images/mall.png",
- selectedIconPath: "/static/images/mall_on.png",
- Text: '健康产品',
- url: '/pages/shopping/index',
- isshowed:true
- },
- {
- iconPath: "/static/images/mine.png",
- selectedIconPath: "/static/images/mine_on.png",
- Text: '我的',
- url: '/pages/user/index',
- isshowed:true
- },
- ]
-
- }
- }
- }
- </script>
- <style lang="scss" scoped>
- .tabbar {
- display: flex;
- position: fixed;
- bottom: 0;
- left: 0;
- right: 0;
- background-color: #fff;
- z-index: 1000;
- height: 50px;
- // padding: 20rpx 0rpx;
- box-sizing: border-box;
- image{
- margin-bottom: 4rpx;
- width: 48rpx;
- height: 48rpx;
- }
- }
- .tablist {
- width: 25%;
- }
- .morecolor{
- color: #626468;
- }
- .actcolor{
- color: #018C39;
- }
- .tabbar-list{
- height: 100%;
- display: flex;
- flex-direction: column;
- align-items: center;
- justify-content: center;
- font-size: 10px;
- text-align: center;
- }
- </style>
|