当前位置: 首页 > 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;解决方案…...

深度学习在微纳光子学中的应用

深度学习在微纳光子学中的主要应用方向 深度学习与微纳光子学的结合主要集中在以下几个方向&#xff1a; 逆向设计 通过神经网络快速预测微纳结构的光学响应&#xff0c;替代传统耗时的数值模拟方法。例如设计超表面、光子晶体等结构。 特征提取与优化 从复杂的光学数据中自…...

【CSS position 属性】static、relative、fixed、absolute 、sticky详细介绍,多层嵌套定位示例

文章目录 ★ position 的五种类型及基本用法 ★ 一、position 属性概述 二、position 的五种类型详解(初学者版) 1. static(默认值) 2. relative(相对定位) 3. absolute(绝对定位) 4. fixed(固定定位) 5. sticky(粘性定位) 三、定位元素的层级关系(z-i…...

Keil 中设置 STM32 Flash 和 RAM 地址详解

文章目录 Keil 中设置 STM32 Flash 和 RAM 地址详解一、Flash 和 RAM 配置界面(Target 选项卡)1. IROM1(用于配置 Flash)2. IRAM1(用于配置 RAM)二、链接器设置界面(Linker 选项卡)1. 勾选“Use Memory Layout from Target Dialog”2. 查看链接器参数(如果没有勾选上面…...

【JavaSE】绘图与事件入门学习笔记

-Java绘图坐标体系 坐标体系-介绍 坐标原点位于左上角&#xff0c;以像素为单位。 在Java坐标系中,第一个是x坐标,表示当前位置为水平方向&#xff0c;距离坐标原点x个像素;第二个是y坐标&#xff0c;表示当前位置为垂直方向&#xff0c;距离坐标原点y个像素。 坐标体系-像素 …...

基于matlab策略迭代和值迭代法的动态规划

经典的基于策略迭代和值迭代法的动态规划matlab代码&#xff0c;实现机器人的最优运输 Dynamic-Programming-master/Environment.pdf , 104724 Dynamic-Programming-master/README.md , 506 Dynamic-Programming-master/generalizedPolicyIteration.m , 1970 Dynamic-Programm…...

大语言模型(LLM)中的KV缓存压缩与动态稀疏注意力机制设计

随着大语言模型&#xff08;LLM&#xff09;参数规模的增长&#xff0c;推理阶段的内存占用和计算复杂度成为核心挑战。传统注意力机制的计算复杂度随序列长度呈二次方增长&#xff0c;而KV缓存的内存消耗可能高达数十GB&#xff08;例如Llama2-7B处理100K token时需50GB内存&a…...

高效线程安全的单例模式:Python 中的懒加载与自定义初始化参数

高效线程安全的单例模式:Python 中的懒加载与自定义初始化参数 在软件开发中,单例模式(Singleton Pattern)是一种常见的设计模式,确保一个类仅有一个实例,并提供一个全局访问点。在多线程环境下,实现单例模式时需要注意线程安全问题,以防止多个线程同时创建实例,导致…...

#Uniapp篇:chrome调试unapp适配

chrome调试设备----使用Android模拟机开发调试移动端页面 Chrome://inspect/#devices MuMu模拟器Edge浏览器&#xff1a;Android原生APP嵌入的H5页面元素定位 chrome://inspect/#devices uniapp单位适配 根路径下 postcss.config.js 需要装这些插件 “postcss”: “^8.5.…...

scikit-learn机器学习

# 同时添加如下代码, 这样每次环境(kernel)启动的时候只要运行下方代码即可: # Also add the following code, # so that every time the environment (kernel) starts, # just run the following code: import sys sys.path.append(/home/aistudio/external-libraries)机…...

iview框架主题色的应用

1.下载 less要使用3.0.0以下的版本 npm install less2.7.3 npm install less-loader4.0.52./src/config/theme.js文件 module.exports {yellow: {theme-color: #FDCE04},blue: {theme-color: #547CE7} }在sass中使用theme配置的颜色主题&#xff0c;无需引入&#xff0c;直接可…...