1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677 |
- import { modalStore } from '@/store/modal';
- const modal = modalStore()
- // 隐藏TabBar
- const hideBar = () => {
- // 关闭tabBar
- const currentPage = getCurrentPages()
- if (!currentPage) {
- return
- }
- const currentTabBar = currentPage[0]?.getTabBar?.();
- // console.log('打开了', currentTabBar)
- currentTabBar?.setData({ show: false });
- // uni.hideTabBar({
- // success: () => {},
- // fail: () => {} // 捕获报错,防止没有tabbar页面调用后控制台报错
- // })
- }
- // 显示TabBar
- const showBar = () => {
-
- // 打开tabBar
- const currentPage = getCurrentPages()
- if (!currentPage) {
- return
- }
- const currentTabBar = currentPage[0]?.getTabBar?.();
- // console.log('打开了', currentTabBar)
- currentTabBar?.setData({ show: true });
- // uni.showTabBar({
- // success: () => {},
- // fail: () => {} // 捕获报错,防止没有tabbar页面调用后控制台报错
- // })
- }
- // 打开授权弹框
- export function showAuthModal(type = 'login') {
- if (modal.auth !== '') {
- // 注意:延迟修改,保证下面的 closeAuthModal 先执行掉
- setTimeout(() => {
- hideBar()
- modal.$patch((state) => {
- state.auth = type
- })
- }, 500)
- closeAuthModal()
- } else {
- hideBar()
- modal.$patch((state) => {
- state.auth = type
- })
- }
- }
- // 关闭授权弹框
- export function closeAuthModal() {
- showBar()
- modal.$patch((state) => {
- state.auth = ''
- })
- }
- // 打开分享弹框
- export function showShareModal() {
- hideBar()
- modal.$patch((state) => {
- state.share = true
- })
- }
- // 关闭分享弹框
- export function closeShareModal() {
- showBar()
- modal.$patch((state) => {
- state.share = false
- })
- }
|