当前位置: 首页 > news >正文

uniapp踩坑之项目:简易版不同角色显示不一样的tabbar和页面

1.

pages下创建三个不同用户身份的“我的”页面。

显示第几个tabbar,0是管理员 1是财务 2是司机

2.

在uni_modules文件夹创建底部导航cc-myTabbar文件夹,在cc-myTabbar文件夹创建components文件夹,在components文件夹创建cc-myTabbar.vue组件

3.

在utils文件夹创建tabBar.js

4.

pages.json里指定路径

5.

在单页面引入底部导航组件

 

//cc-myTabbar.vue 底部导航组件
<template><view class="page-total"><view class="tab-list"><view class="list" v-for="(item,index) in TabBarList" @click="onTabBar(item,index)" :style="{marginTop: (item.name == '') ?  '-88rpx' : '0px'}" :key="item.index"><image :src="item.acImg" mode="widthFix" v-show="tabBarShow ===index" :style="{width: (item.name == '') ?  '100rpx' : '54rpx',borderRadius: (item.name == '') ?  '24rpx' : '0rpx'}"></image><image :src="item.img" mode="widthFix" v-show="tabBarShow != index" :style="{width: (item.name == '') ?  '100rpx' : '54rpx',borderRadius: (item.name == '') ?  '24rpx' : '0rpx'}"></image><text :class="{'action':tabBarShow===index}">{{item.name}}</text></view></view></view>
</template><script>
import tabBar from "@/utils/tabBar.js"
// 判断当前登陆用户角色
// 0 为管理员
// 1 为财务
// 2 为司机// 三元表达式判断当前登陆的用户角色
// var user_type = uni.getStorageSync("userType")
var user_type = 0
let type = user_type === 0 ? 'admin' : user_type === 1 ? "finance" : "driver"const state = {list: tabBar[type]
}
// console.log(user_type, 'user_type');
// console.log(type, 'type');
// console.log(state, 'state');
export default {data () {return {TabBarList: state.list,codeheight: 0,isOverall: 0,phoneModel: '',};},props: {tabBarShow: {type: Number,default: 0,}},mounted () {try {const res = uni.getSystemInfoSync();let that = this;// 获取系统信息uni.getSystemInfo({success (res) {console.log(res.brand) //手机牌子console.log(res.model) //手机型号console.log(res.screenWidth) //屏幕宽度console.log(res.screenHeight) //屏幕高度that.codeheight = Math.round(res.screenHeight);that.phoneModel = res.modelif (res.model.search('iPhone')) {that.isOverall = 0;} else if (Math.round(res.screenHeight) > 740) {that.isOverall = 1;}console.log(that.isOverall);}});} catch (e) {// error}},methods: {// 底部导航 跳转onTabBar (item, index) {// this.tabBarShow = index;// console.log(item, 'item');// console.log(index, 'index');if (user_type == 2) { // 司机switch (item.name) {case '首页':uni.switchTab({url: '/pages/homePage/homePage'})break;case ''://   uni.switchTab({//     url: '/pages/scan/scan'//   })// 允许从相机和相册扫码uni.scanCode({success: function (res) {console.log('条码类型:' + res.scanType);console.log('条码内容:' + res.result);}});break;case '我的':uni.switchTab({url: '/pages/mineDriver/mineDriver'})break;}} else if (user_type == 0) { //管理员switch (item.name) {case '首页':uni.switchTab({url: '/pages/homePage/homePage'})break;case ''://   uni.switchTab({//     url: '/pages/scan/scan'//   })// 允许从相机和相册扫码uni.scanCode({success: function (res) {console.log('条码类型:' + res.scanType);console.log('条码内容:' + res.result);}});break;case '我的':uni.switchTab({url: '/pages/mine/mine'})break;}} else { // 财务switch (item.name) {case '首页':uni.switchTab({url: '/pages/homePage/homePage'})break;case ''://   uni.switchTab({//     url: '/pages/scan/scan'//   })// 允许从相机和相册扫码uni.scanCode({success: function (res) {console.log('条码类型:' + res.scanType);console.log('条码内容:' + res.result);}});break;case '我的':uni.switchTab({url: '/pages/mineFinance/mineFinance'})break;}}}}
}
</script><style scoped lang="scss">
@import 'cc-myTabbar.scss';
</style>//在components文件夹里创建cc-myTabbar.scss
//cc-myTabbar.scss
/* 主要颜色 */
$base: #508AF1; // 基础颜色.page-total {position: fixed;left: 0;bottom: 0;width: 100%;// height: 100rpx;
}.tab-list {display: flex;justify-content: space-between;align-items: center;width: 100%;height: 140rpx;padding-bottom: 20rpx;background-color: #FFFFFF;// border-top: 1px solid #e8e8e8;.list {display: flex;flex-direction: column;align-items: center;justify-content: center;width: 38%;height: 120rpx;image {width: 48rpx;height: 48rpx;background-color: white;}text {color: #707070;font-weight: 900;font-size: 24rpx;margin-top: 10rpx;}.action {color: $base;}}
}
//tabBar.js
// 小程序管理者
const admin = [{pagePath: "/pages/homePage/homePage",index: 0,name: '首页',img: '/static/images/tabBar/tab_01.png',acImg: '/static/images/tabBar/tab_02.png'},// {//   index: 2,//   name: '',//   img: '/static/images/tabBar/tab_03.png',//   acImg: '/static/images/tabBar/tab_04.png'// },{pagePath: "/pages/mine/mine",index: 1,name: '我的',img: '/static/images/tabBar/tab_05.png',acImg: '/static/images/tabBar/tab_06.png'},
]
// 财务
const finance = [{pagePath: "/pages/homePage/homePage",index: 0,name: '首页',img: '/static/images/tabBar/tab_01.png',acImg: '/static/images/tabBar/tab_02.png'},// {//   index: 1,//   name: '',//   img: '/static/images/tabBar/tab_03.png',//   acImg: '/static/images/tabBar/tab_04.png'// },{pagePath: "/pages/mineFinance/mineFinance",index: 1,name: '我的',img: '/static/images/tabBar/tab_05.png',acImg: '/static/images/tabBar/tab_06.png'},
]// 司机
const driver = [{pagePath: "/pages/homePage/homePage",index: 0,name: '首页',img: '/static/images/tabBar/tab_01.png',acImg: '/static/images/tabBar/tab_02.png'},// {//   pagePath: "/pages/scan/scan",//   index: 1,//   name: '',//   img: '/static/images/tabBar/tab_03.png',//   acImg: '/static/images/tabBar/tab_04.png'// },{pagePath: "/pages/mineDriver/mineDriver",index: 1,name: '我的',img: '/static/images/tabBar/tab_05.png',acImg: '/static/images/tabBar/tab_06.png'},
]export default {admin,finance,driver
}
// pages.json
{"pages": [{"path": "pages/homePage/homePage","style": {"navigationBarTitleText": "首页"// "navigationStyle": "custom"}},{"path": "pages/login","style": {"navigationBarTitleText": "登录"}},{"path": "pages/register","style": {"navigationBarTitleText": "注册"}},{"path": "pages/work/work","style": {"navigationBarTitleText": "工作台"}},{"path": "pages/mine/mine", //管理员"style": {"navigationBarTitleText": "我的"}},{"path": "pages/mineDriver/mineDriver", // 司机"style": {"navigationBarTitleText": "我的"}},{"path": "pages/mineFinance/mineFinance", // 财务"style": {"navigationBarTitleText": "我的"}},{"path": "pages/mine/avatar/index","style": {"navigationBarTitleText": "修改头像"}},{"path": "pages/mine/info/index","style": {"navigationBarTitleText": "个人信息"}},{"path": "pages/mine/info/edit","style": {"navigationBarTitleText": "编辑资料"}},{"path": "pages/mine/pwd/index","style": {"navigationBarTitleText": "修改密码"}},{"path": "pages/mine/setting/index","style": {"navigationBarTitleText": "应用设置"}},{"path": "pages/mine/help/index","style": {"navigationBarTitleText": "常见问题"}},{"path": "pages/mine/about/index","style": {"navigationBarTitleText": "关于我们"}},],"tabBar": {"custom": true, // 隐藏tabBar"color": "#000000","selectedColor": "#508af1", // 选中颜色"borderStyle": "white","backgroundColor": "#ffffff","list": [{"pagePath": "pages/homePage/homePage"// "iconPath": "static/images/tabbar/tab_01.png",// "selectedIconPath": "static/images/tabbar/tab_02.png",// "text": "首页"},// {//   "pagePath": "pages/work/work",//   "iconPath": "static/images/tabbar/work.png",//   "selectedIconPath": "static/images/tabbar/work_.png",//   "text": "工作台"// },{"pagePath": "pages/mine/mine"// "iconPath": "static/images/tabbar/tab_09.png",// "selectedIconPath": "static/images/tabbar/tab_10.png",// "text": "我的"},{"pagePath": "pages/mineDriver/mineDriver"// "iconPath": "static/images/tabbar/tab_09.png",// "selectedIconPath": "static/images/tabbar/tab_10.png",// "text": "我的"},{"pagePath": "pages/mineFinance/mineFinance"// "iconPath": "static/images/tabbar/tab_09.png",// "selectedIconPath": "static/images/tabbar/tab_10.png",// "text": "我的"}]},"globalStyle": {"navigationBarTextStyle": "black","navigationBarTitleText": "RuoYi","navigationBarBackgroundColor": "#FFFFFF"}
}
// 单页面 
// mine.vue管理员版"我的"页面 / mineDriver.vue司机版"我的"页面 / mineFinance.vue财务版"我的"页面<template><view class="page"><!-- tabBarShow:显示第几个tabbar 0是管理员 1是财务 2是司机--><cc-myTabbar :tabBarShow="0"></cc-myTabbar> </view>
</template><script>export default {data() {return {};},onReady() {uni.hideTabBar()},methods: {}}
</script><style scoped lang="scss">page {padding-bottom: 140rpx;}
</style>

上一篇文章,

vue2踩坑之项目:vue2+element实现前端导出_vue2导出 type为text/plain 找不到状态code值-CSDN博客文章浏览阅读392次,点赞8次,收藏9次。vue2踩坑之项目:vue2+element实现前端导出。安装插件依赖 npm i --save xlsx@0.17.0 file-saver@2.0.5,单页面引入 前端导出插件_vue2导出 type为text/plain 找不到状态code值https://blog.csdn.net/weixin_43928112/article/details/135685385

相关文章:

uniapp踩坑之项目:简易版不同角色显示不一样的tabbar和页面

1. pages下创建三个不同用户身份的“我的”页面。 显示第几个tabbar&#xff0c;0是管理员 1是财务 2是司机 2. 在uni_modules文件夹创建底部导航cc-myTabbar文件夹&#xff0c;在cc-myTabbar文件夹创建components文件夹&#xff0c;在components文件夹创建cc-myTabbar.vue组件…...

源支付V7开心1.9修复版,非网络上泛滥不能那种

源支付V7开心1.9修复版&#xff0c;非网络上泛滥不能那种 修复版源码&#xff0c;非网络泛滥版&#xff0c;防止源码泛滥&#xff0c;会员专属源码, 本站会员免费下载所有资源 注&#xff1a;开发不易&#xff0c;仅限交流学习使用&#xff0c;如商业使用&#xff0c;请支持正…...

Gitlab和Jenkins集成 实现CI (二)

Gitlab和Jenkins集成 实现CI (一) Gitlab和Jenkins集成 实现CI (二) Gitlab和Jenkins集成 实现CI (三) 配置Gitlab api token 配置 Gitlab 进入gitlab #mermaid-svg-t84fR8wrT4sB4raQ {font-family:"trebuchet ms",verdana,arial,sans-serif;font-size:16px;fill:…...

Java:内部类、枚举、泛型以及常用API --黑马笔记

内部类 内部类是类中的五大成分之一&#xff08;成员变量、方法、构造器、内部类、代码块&#xff09;&#xff0c;如果一个类定义在另一个类的内部&#xff0c;这个类就是内部类。 当一个类的内部&#xff0c;包含一个完整的事物&#xff0c;且这个事物没有必要单独设计时&a…...

【持续更新】2024牛客寒假算法基础集训营3 题解 | JorbanS

A - 智乃与瞩目狸猫、幸运水母、月宫龙虾 string solve() {string a, b; cin >> a >> b;if (isupper(a[0])) a[0] a - A;if (isupper(b[0])) b[0] a - A;return a[0] b[0] ? yes : no; }B - 智乃的数字手串 string solve() {cin >> n;int cnt 0;for (…...

Java基于微信小程序的驾校报名小程序,附源码

博主介绍&#xff1a;✌程序员徐师兄、7年大厂程序员经历。全网粉丝12w、csdn博客专家、掘金/华为云/阿里云/InfoQ等平台优质作者、专注于Java技术领域和毕业项目实战✌ &#x1f345;文末获取源码联系&#x1f345; &#x1f447;&#x1f3fb; 精彩专栏推荐订阅&#x1f447;…...

Android中AGP与Gradle、AS、JDK的版本关系

文章目录 AGP版本所要求的Gradle、JDK、SDK Build Tools最小版本Android Studio所要求的AGP最小版本 本文介绍了 在Android开发中由于AGP与gradle、JDK、AS等版本不匹配导致的编译失败问题屡见不鲜&#xff0c;尤其是对于新手而言更是叫苦不迭。新手经常遇到拿到别人的工程代码…...

web 前端实现一个根据域名的判断 来显示不同的logo 和不同的标题

1.需求 有可能我做一个后台 web端 我想实现一套代码的逻辑 显示不同的公司主题logo以及内容&#xff0c;但是实际上 业务逻辑一样 2.实现 建一个store oem.ts 这个名为是 oem系统 oem.ts import { defineStore } from pinia;import { store } from /store;const oemDataLis…...

复制和粘贴文本时剥离格式的5种方法(MacWindows)

您可能每天复制和粘贴多次。虽然它是一个非常方便的功能&#xff0c;但最大的烦恼之一就是带来了特殊的格式。从网络上获取一些文本&#xff0c;您经常会发现粘贴到文档中时&#xff0c;它保持原始样式。 我们将展示如何使用一些简单的技巧在不格式化的情况下复制和粘贴。 1.…...

SpringBoot实现即时通讯

SpringBoot实现即时通讯 功能简述 好友管理群组管理聊天模式&#xff1a;私聊、群聊消息类型&#xff1a;系统消息、文本、语音、图片、视频会话列表、发送消息、接收消息 核心代码 package com.qiangesoft.im.core;import com.alibaba.fastjson2.JSONObject; import com.q…...

【每日一题】LeetCode——反转链表

&#x1f4da;博客主页&#xff1a;爱敲代码的小杨. ✨专栏&#xff1a;《Java SE语法》 | 《数据结构与算法》 | 《C生万物》 ❤️感谢大家点赞&#x1f44d;&#x1f3fb;收藏⭐评论✍&#x1f3fb;&#xff0c;您的三连就是我持续更新的动力❤️ &#x1f64f;小杨水平有…...

精通Python爬虫:掌握日志配置

源码分享 https://docs.qq.com/sheet/DUHNQdlRUVUp5Vll2?tabBB08J2 在开发Python爬虫时&#xff0c;日志记录是一个不可或缺的特性&#xff0c;它帮助我们捕捉运行时信息、调试代码和监控爬虫的健康状况。合理地配置日志系统是提高爬虫可维护性的关键。本篇技术博客将详细介绍…...

Python_百度贴吧评论情感分析

一、评论爬取 以百度贴吧中“美团骑手吧”为例&#xff0c;对页面中的帖子评论进行爬取&#xff0c;并将结果以json的格式保存到本地中。 from lxml import etree import requests import json# 根据网页url获取评论 def GetComments(url):# 使用requests库发送GET请求&#…...

如何运行心理学知识(心流)来指导工作和生活

如何运用心流来指导工作和生活 如何联系我 作者&#xff1a;鲁伟林 邮箱&#xff1a;thinking_fioa163.com或vlinyes163.com GitHub&#xff1a;https://github.com/thinkingfioa/ReadingSummary 版权声明&#xff1a;文章和记录为个人所有&#xff0c;如果转载或个人学习…...

精简还是全能?如何在 Full 和 Lite 之间做出最佳选择!关于Configuration注解的Full模式与Lite模式(SpringBoot2)

&#x1f3c3;‍♂️ 微信公众号: 朕在debugger© 版权: 本文由【朕在debugger】原创、需要转载请联系博主&#x1f4d5; 如果文章对您有所帮助&#xff0c;欢迎关注、点赞、转发和订阅专栏&#xff01; 前言 关于 Configuration 注解&#xff0c;相信在座的各位 Javaer 都…...

springboot微信小程序uniapp学习计划与日程管理系统

基于springboot学习计划与日程管理系统&#xff0c;确定学习计划小程序的目标&#xff0c;明确用户需求&#xff0c;学习计划小程序的主要功能是帮助用户制定学习计划&#xff0c;并跟踪学习进度。页面设计主要包括主页、计划学习页、个人中心页等&#xff0c;然后用户可以利用…...

236.二叉树的最近公共祖先

​​题目来源&#xff1a; leetcode题目&#xff0c;网址&#xff1a;236. 二叉树的最近公共祖先 - 力扣&#xff08;LeetCode&#xff09; 解题思路&#xff1a; 分别获得从根节点到两个目标节点的链路&#xff0c;寻找到最后一个相同节点即可。 解题代码&#xff1a; /***…...

ETL是什么,有哪些ETL工具?就业前景如何?

ETL是什么 ETL&#xff08;Extract-Transform-Load&#xff09;&#xff0c;用来描述将数据从来源端经过抽取(extract)、转换(transform)、加载(load)至目标端的过程。ETL一词较常用在数据仓库&#xff0c;但其对象并不限于数据仓库。它可以自动化数据处理过程&#xff0c;减少…...

无人机系统组装与调试,多旋翼无人机组装与调试技术详解,无人机飞控系统原理

多旋翼无人机飞控系统的组装 在开始组装前&#xff0c;确保您已准备好所有必要的工具和材料。这包括螺丝刀、电烙铁、焊台、杜邦线、飞控板、GPS模块、电机、桨叶等。 飞控安装 安全开关安装&#xff0c;将安全开关固定在机架上。将安全开关的线插到飞控SWITCH插口上。 电调…...

Log360,引入全新安全与风险管理功能,助力企业积极抵御网络威胁

ManageEngine在其SIEM解决方案中推出了安全与风险管理新功能&#xff0c;企业现在能够更主动地减轻内部攻击和防范入侵。 SIEM 这项新功能为Log360引入了安全与风险管理仪表板&#xff0c;Log360是ManageEngine的统一安全信息与事件管理&#xff08;SIEM&#xff09;解决方案…...

在HarmonyOS ArkTS ArkUI-X 5.0及以上版本中,手势开发全攻略:

在 HarmonyOS 应用开发中&#xff0c;手势交互是连接用户与设备的核心纽带。ArkTS 框架提供了丰富的手势处理能力&#xff0c;既支持点击、长按、拖拽等基础单一手势的精细控制&#xff0c;也能通过多种绑定策略解决父子组件的手势竞争问题。本文将结合官方开发文档&#xff0c…...

FastAPI 教程:从入门到实践

FastAPI 是一个现代、快速&#xff08;高性能&#xff09;的 Web 框架&#xff0c;用于构建 API&#xff0c;支持 Python 3.6。它基于标准 Python 类型提示&#xff0c;易于学习且功能强大。以下是一个完整的 FastAPI 入门教程&#xff0c;涵盖从环境搭建到创建并运行一个简单的…...

为什么需要建设工程项目管理?工程项目管理有哪些亮点功能?

在建筑行业&#xff0c;项目管理的重要性不言而喻。随着工程规模的扩大、技术复杂度的提升&#xff0c;传统的管理模式已经难以满足现代工程的需求。过去&#xff0c;许多企业依赖手工记录、口头沟通和分散的信息管理&#xff0c;导致效率低下、成本失控、风险频发。例如&#…...

iOS性能调优实战:借助克魔(KeyMob)与常用工具深度洞察App瓶颈

在日常iOS开发过程中&#xff0c;性能问题往往是最令人头疼的一类Bug。尤其是在App上线前的压测阶段或是处理用户反馈的高发期&#xff0c;开发者往往需要面对卡顿、崩溃、能耗异常、日志混乱等一系列问题。这些问题表面上看似偶发&#xff0c;但背后往往隐藏着系统资源调度不当…...

Golang——6、指针和结构体

指针和结构体 1、指针1.1、指针地址和指针类型1.2、指针取值1.3、new和make 2、结构体2.1、type关键字的使用2.2、结构体的定义和初始化2.3、结构体方法和接收者2.4、给任意类型添加方法2.5、结构体的匿名字段2.6、嵌套结构体2.7、嵌套匿名结构体2.8、结构体的继承 3、结构体与…...

mac:大模型系列测试

0 MAC 前几天经过学生优惠以及国补17K入手了mac studio,然后这两天亲自测试其模型行运用能力如何&#xff0c;是否支持微调、推理速度等能力。下面进入正文。 1 mac 与 unsloth 按照下面的进行安装以及测试&#xff0c;是可以跑通文章里面的代码。训练速度也是很快的。 注意…...

阿里云Ubuntu 22.04 64位搭建Flask流程(亲测)

cd /home 进入home盘 安装虚拟环境&#xff1a; 1、安装virtualenv pip install virtualenv 2.创建新的虚拟环境&#xff1a; virtualenv myenv 3、激活虚拟环境&#xff08;激活环境可以在当前环境下安装包&#xff09; source myenv/bin/activate 此时&#xff0c;终端…...

yaml读取写入常见错误 (‘cannot represent an object‘, 117)

错误一&#xff1a;yaml.representer.RepresenterError: (‘cannot represent an object’, 117) 出现这个问题一直没找到原因&#xff0c;后面把yaml.safe_dump直接替换成yaml.dump&#xff0c;确实能保存&#xff0c;但出现乱码&#xff1a; 放弃yaml.dump&#xff0c;又切…...

聚六亚甲基单胍盐酸盐市场深度解析:现状、挑战与机遇

根据 QYResearch 发布的市场报告显示&#xff0c;全球市场规模预计在 2031 年达到 9848 万美元&#xff0c;2025 - 2031 年期间年复合增长率&#xff08;CAGR&#xff09;为 3.7%。在竞争格局上&#xff0c;市场集中度较高&#xff0c;2024 年全球前十强厂商占据约 74.0% 的市场…...

跨平台商品数据接口的标准化与规范化发展路径:淘宝京东拼多多的最新实践

在电商行业蓬勃发展的当下&#xff0c;多平台运营已成为众多商家的必然选择。然而&#xff0c;不同电商平台在商品数据接口方面存在差异&#xff0c;导致商家在跨平台运营时面临诸多挑战&#xff0c;如数据对接困难、运营效率低下、用户体验不一致等。跨平台商品数据接口的标准…...