更新:增加“我的”相关功能
This commit is contained in:
@@ -1,5 +1,51 @@
|
||||
/**
|
||||
* 页面跳转
|
||||
*/
|
||||
export const onPageJump = (path: string) => {
|
||||
uni.navigateTo({
|
||||
url: path
|
||||
})
|
||||
}
|
||||
|
||||
/**
|
||||
* 拨打电话
|
||||
*/
|
||||
export const makePhoneCall = (phoneNumber: string, title: string, t: Function) => {
|
||||
uni.showModal({
|
||||
title: title,
|
||||
content: phoneNumber,
|
||||
confirmText: t('common.confirm'),
|
||||
cancelText: t('common.cancel'),
|
||||
success: (res: any) => {
|
||||
if (res.confirm) {
|
||||
uni.makePhoneCall({
|
||||
phoneNumber: phoneNumber,
|
||||
success: () => {
|
||||
console.log('拨打电话成功')
|
||||
},
|
||||
fail: (error: any) => {
|
||||
console.error('拨打电话失败:', error)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
/**
|
||||
* 复制到剪贴板
|
||||
*/
|
||||
export const copyToClipboard = (content: string, title: string, t: Function) => {
|
||||
uni.setClipboardData({
|
||||
data: content,
|
||||
success: () => {
|
||||
uni.showToast({
|
||||
title: title + t('user.copySuccess'),
|
||||
icon: 'none'
|
||||
})
|
||||
},
|
||||
fail: (error) => {
|
||||
console.error('复制失败:', error)
|
||||
}
|
||||
})
|
||||
}
|
||||
54
utils/system.ts
Normal file
54
utils/system.ts
Normal file
@@ -0,0 +1,54 @@
|
||||
interface SystemInfo {
|
||||
statusBarHeight?: number;
|
||||
[key: string]: any;
|
||||
}
|
||||
|
||||
interface MenuButtonRect {
|
||||
top: number;
|
||||
height: number;
|
||||
[key: string]: any;
|
||||
}
|
||||
|
||||
interface LeftIcon {
|
||||
left: string;
|
||||
width: string;
|
||||
}
|
||||
|
||||
const SYSTEM_INFO: SystemInfo = uni.getSystemInfoSync();
|
||||
|
||||
export const getStatusBarHeight = (): number => SYSTEM_INFO.statusBarHeight || 0;
|
||||
|
||||
export const getTitleBarHeight = (): number => {
|
||||
if (uni.getMenuButtonBoundingClientRect) {
|
||||
const { top, height }: MenuButtonRect = uni.getMenuButtonBoundingClientRect();
|
||||
return height + (top - getStatusBarHeight()) * 2;
|
||||
} else {
|
||||
return 44;
|
||||
}
|
||||
}
|
||||
|
||||
export const getNavBarHeight = (): number => getStatusBarHeight() + getTitleBarHeight();
|
||||
|
||||
export const getLeftIconLeft = (): number => {
|
||||
// #ifdef MP-TOUTIAO
|
||||
const { leftIcon: { left, width } }: { leftIcon: LeftIcon } = tt.getCustomButtonBoundingClientRect();
|
||||
return left + parseInt(width);
|
||||
// #endif
|
||||
|
||||
// #ifndef MP-TOUTIAO
|
||||
return 0;
|
||||
// #endif
|
||||
}
|
||||
|
||||
export const getNavbarHeight2 = () => {
|
||||
const systemInfo = uni.getSystemInfoSync()
|
||||
statusBarHeight.value = systemInfo.statusBarHeight || 0
|
||||
|
||||
let navBarHeight = 44
|
||||
if (systemInfo.model.indexOf('iPhone') !== -1 && parseInt(systemInfo.model.slice(-2)) >= 11) {
|
||||
navBarHeight = 48
|
||||
}
|
||||
|
||||
const totalHeight = statusBarHeight.value + navBarHeight
|
||||
navbarHeight.value = totalHeight + 'px'
|
||||
}
|
||||
Reference in New Issue
Block a user