代码提交
This commit is contained in:
31
hooks/useImage.js
Normal file
31
hooks/useImage.js
Normal file
@ -0,0 +1,31 @@
|
||||
/**
|
||||
* @name: useImage
|
||||
* @author: kahu4
|
||||
* @date: 2023-11-07 16:34
|
||||
* @description:useImage
|
||||
* @update: 2023-11-07 16:34
|
||||
* */
|
||||
|
||||
export function useImage() {
|
||||
|
||||
/**
|
||||
* options?: PreviewImageOptions
|
||||
* @param options {PreviewImageOptions}
|
||||
* @returns {Promise<unknown>}
|
||||
*/
|
||||
function preview(options) {
|
||||
return new Promise((resolve, reject) => {
|
||||
uni.previewImage({
|
||||
indicator: 'default',
|
||||
loop: true,
|
||||
...options,
|
||||
success: () => resolve(true),
|
||||
fail: (err) => reject(err)
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
return {
|
||||
preview
|
||||
}
|
||||
}
|
215
hooks/useInterface.js
Normal file
215
hooks/useInterface.js
Normal file
@ -0,0 +1,215 @@
|
||||
/**
|
||||
* @name: useInterface
|
||||
* @author: kahu4
|
||||
* @date: 2023-10-30 11:56
|
||||
* @description:封装uni app界面相关接口,利于维护
|
||||
* @update: 2023-10-30 11:56
|
||||
* */
|
||||
|
||||
/**
|
||||
* 封装uni app界面相关接口,利于维护
|
||||
* @returns { any }
|
||||
*/
|
||||
export const useInterface = () => {
|
||||
/**
|
||||
* 使用uni的toast
|
||||
* @param options
|
||||
* @returns {Promise<unknown>}
|
||||
*/
|
||||
function toast(options) {
|
||||
return new Promise((resolve, reject) => {
|
||||
uni.showToast({
|
||||
icon: 'none',
|
||||
mask: false,
|
||||
...options,
|
||||
success: () => resolve(true),
|
||||
fail: (error) => reject(error)
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
/**
|
||||
* 使用uni的loading
|
||||
* @param options
|
||||
* @returns {Promise<unknown>}
|
||||
*/
|
||||
function loading(options) {
|
||||
return new Promise((resolve, reject) => {
|
||||
uni.showLoading({
|
||||
icon: 'none',
|
||||
mask: true,
|
||||
...options,
|
||||
success: () => resolve(true),
|
||||
fail: (error) => reject(error)
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
function hideLoading() {
|
||||
uni.hideLoading()
|
||||
}
|
||||
|
||||
/**
|
||||
* 动态设置当前页面的标题
|
||||
* @param title
|
||||
* @returns {Promise<unknown>}
|
||||
*/
|
||||
function setNavTitle(title) {
|
||||
return new Promise((resolve, reject) => {
|
||||
uni.setNavigationBarTitle({
|
||||
title,
|
||||
success: () => resolve(true),
|
||||
fail: (error) => reject(error)
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置页面导航条颜色。如果需要进入页面就设置颜色,请延迟执行,防止被框架内设置颜色逻辑覆盖
|
||||
* @param options
|
||||
* @param timeout
|
||||
* @returns {Promise<unknown>}
|
||||
*/
|
||||
function setNavBgColor(options, timeout = 500) {
|
||||
return new Promise((resolve, reject) => {
|
||||
const setNavigationBarColor = () => uni.setNavigationBarColor({
|
||||
...options,
|
||||
success: () => resolve(true),
|
||||
fail: (error) => reject(error)
|
||||
})
|
||||
if (timeout === 0) {
|
||||
setNavigationBarColor()
|
||||
} else {
|
||||
setTimeout(() => {
|
||||
uni.setNavigationBarColor({
|
||||
...options,
|
||||
success: () => resolve(true),
|
||||
fail: (error) => reject(error)
|
||||
})
|
||||
}, timeout)
|
||||
}
|
||||
|
||||
})
|
||||
}
|
||||
|
||||
/**
|
||||
* 页面滚动到元素或者指定位置
|
||||
* @param options
|
||||
* @returns {Promise<unknown>}
|
||||
*/
|
||||
function scrollTo(options) {
|
||||
return new Promise((resolve, reject) => {
|
||||
uni.pageScrollTo({
|
||||
...options,
|
||||
success: () => resolve(true),
|
||||
fail: (error) => reject(error)
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
/**
|
||||
* 监听窗口尺寸变化事件
|
||||
* 如App端设置软键盘弹出方式为adjustResize ,则在键盘弹出时,会触发此事件。
|
||||
* 横竖屏切换时,会触发此事件。
|
||||
* @param callback
|
||||
*/
|
||||
function pageResize(callback) {
|
||||
uni.onWindowResize(callback)
|
||||
}
|
||||
|
||||
/**
|
||||
* 取消监听窗口尺寸变化事件
|
||||
* callback为调用pageResize时传入的callback
|
||||
* @param callback
|
||||
*/
|
||||
function unPageResize(callback) {
|
||||
uni.offWindowResize(callback)
|
||||
}
|
||||
|
||||
/**
|
||||
* 逻辑触发页面下拉刷新
|
||||
* page.json相关字段 "enablePullDownRefresh": true
|
||||
* @returns {Promise<unknown>}
|
||||
*/
|
||||
function startPullDownRefresh() {
|
||||
return new Promise((resolve, reject) => {
|
||||
uni.startPullDownRefresh({
|
||||
success: () => resolve(true),
|
||||
fail: (error) => reject(error)
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
/**
|
||||
* 停止下拉刷新
|
||||
*/
|
||||
function stopPullDownRefresh() {
|
||||
uni.stopPullDownRefresh()
|
||||
}
|
||||
|
||||
/**
|
||||
* 返回uni app的SelectorQuery 对象实例
|
||||
* @docs https://uniapp.dcloud.net.cn/api/ui/nodes-info.html
|
||||
* @returns {UniNamespace.SelectorQuery}
|
||||
*/
|
||||
function createSelectorQuery() {
|
||||
return uni.createSelectorQuery()
|
||||
}
|
||||
|
||||
/**
|
||||
* 创建并返回一个 IntersectionObserver 对象实例。
|
||||
* @param _this
|
||||
* @param options
|
||||
* @docs https://uniapp.dcloud.net.cn/api/ui/intersection-observer.html
|
||||
* @returns {UniNamespace.IntersectionObserver}
|
||||
*/
|
||||
function createObserver(_this, options) {
|
||||
return uni.createIntersectionObserver(_this, options)
|
||||
}
|
||||
|
||||
/**
|
||||
* 创建并返回一个 MediaQueryObserver 对象实例。
|
||||
* @param _this
|
||||
* @docs https://uniapp.dcloud.net.cn/api/ui/media-query-observer.html
|
||||
* @returns {UniNamespace.MediaQueryObserver}
|
||||
*/
|
||||
function createMediaObserver(_this) {
|
||||
return uni.createMediaQueryObserver(_this)
|
||||
}
|
||||
|
||||
/**
|
||||
* 创建一个动画实例 animation。调用实例的方法来描述动画。最后通过动画实例的export方法导出动画数据传递给组件的animation属性。
|
||||
* @param options
|
||||
* @docs https://uniapp.dcloud.net.cn/api/ui/animation.html
|
||||
* @returns {UniNamespace.Animation}
|
||||
*/
|
||||
function createAnimation(options) {
|
||||
return uni.createAnimation(options)
|
||||
}
|
||||
|
||||
/**
|
||||
* 小程序获取菜单按钮信息
|
||||
* @returns {UniNamespace.GetMenuButtonBoundingClientRectRes}
|
||||
*/
|
||||
function getMenuButtonInfo() {
|
||||
return uni.getMenuButtonBoundingClientRect()
|
||||
}
|
||||
|
||||
return {
|
||||
toast,
|
||||
loading,
|
||||
hideLoading,
|
||||
setNavTitle,
|
||||
setNavBgColor,
|
||||
scrollTo,
|
||||
pageResize,
|
||||
unPageResize,
|
||||
startPullDownRefresh,
|
||||
stopPullDownRefresh,
|
||||
createSelectorQuery,
|
||||
createObserver,
|
||||
createMediaObserver,
|
||||
createAnimation,
|
||||
getMenuButtonInfo
|
||||
}
|
||||
}
|
@ -30,11 +30,12 @@ export const usePage = getPage => {
|
||||
// 加载中
|
||||
const loading = ref(false)
|
||||
|
||||
// 是否有数据
|
||||
const listEmpty = ref(false)
|
||||
|
||||
const dataList = ref([])
|
||||
|
||||
const handleGetDataList = async () => {
|
||||
console.log('--> % handleGetDataList % loading:\n', loading.value)
|
||||
console.log('--> % handleGetDataList % loadend:\n', loadend.value)
|
||||
if (loading.value || loadend.value) return
|
||||
|
||||
loading.value = true
|
||||
@ -47,10 +48,14 @@ export const usePage = getPage => {
|
||||
news: news.value,
|
||||
isIntegral: isIntegral.value,
|
||||
})
|
||||
console.log('--> % handleGetDataList % products:\n', products)
|
||||
listEmpty.value = false
|
||||
if (products) {
|
||||
if (products.length <= 0) {
|
||||
loadend.value = true
|
||||
if(page.value === 1){
|
||||
listEmpty.value = true
|
||||
} else {
|
||||
loadend.value = true
|
||||
}
|
||||
}
|
||||
dataList.value = dataList.value.concat(products)
|
||||
}
|
||||
@ -60,18 +65,19 @@ export const usePage = getPage => {
|
||||
const handleRefresh = () => {
|
||||
loadend.value = false
|
||||
loading.value = false
|
||||
page.value = 1
|
||||
dataList.value = []
|
||||
handleGetDataList()
|
||||
}
|
||||
|
||||
onReady(() => {
|
||||
console.log('onReady')
|
||||
// handleGetDataList()
|
||||
})
|
||||
|
||||
onReachBottom(() => {
|
||||
if (loading.value) return
|
||||
if (loading.value || loadend.value) return
|
||||
page.value += 1
|
||||
handleGetDataList()
|
||||
})
|
||||
|
||||
// 通过返回值暴露所管理的状态
|
||||
@ -83,6 +89,9 @@ export const usePage = getPage => {
|
||||
keyword,
|
||||
loading,
|
||||
loadend,
|
||||
listEmpty,
|
||||
news,
|
||||
sid,
|
||||
refresh: handleRefresh,
|
||||
}
|
||||
}
|
||||
|
207
hooks/useRouter.js
Normal file
207
hooks/useRouter.js
Normal file
@ -0,0 +1,207 @@
|
||||
/**
|
||||
* @name: 封装uni跳转
|
||||
* @author: kahu4
|
||||
* @date: 2023-10-30 10:52
|
||||
* @description:useRouter.js
|
||||
* @update: 2023-10-30 10:52
|
||||
* */
|
||||
const PARAMS_KEY = 'details' // 路由参数key
|
||||
|
||||
/**
|
||||
* 封装Router
|
||||
*/
|
||||
export const useRouter = () => {
|
||||
/**
|
||||
* 原uni.navigateTo,uni.redirectTo,uni.reLaunch方法封装
|
||||
* 使用此方法的跳转获取参数必须使用本hooks的getParams方法获取路由参数
|
||||
* 注意:2.8.9+以后版本可以使用events参数传递一个方法对象和新打开的页面建立一个channel通讯,getOpenerEventChannel获取到这个channel
|
||||
* @docs: https://uniapp.dcloud.net.cn/api/router.html#navigateto
|
||||
* @param options{any} 原始参数
|
||||
* @param config{{type?:'navigateTo'|'redirectTo'|'reLaunch',data?:any,timeout?:number}}
|
||||
* type:跳转类型,默认navigateTo ; data:跳转参数,默认空对象 ; timeout:跳转延时,默认0
|
||||
* @returns {Promise<boolean>}
|
||||
*/
|
||||
function push(options = {}, config = {}) {
|
||||
// 合并默认参数
|
||||
config = {
|
||||
type: 'navigateTo',
|
||||
data: {},
|
||||
timeout: 0,
|
||||
...config
|
||||
}
|
||||
checkUrl(options)
|
||||
processingParameter(options, config.data)
|
||||
const funcMap = {
|
||||
navigateTo: uni.navigateTo,
|
||||
redirectTo: uni.redirectTo,
|
||||
reLaunch: uni.reLaunch,
|
||||
}
|
||||
return new Promise((resolve, reject) => {
|
||||
const pushTab = () => funcMap[config.type]({
|
||||
...options,
|
||||
success: () => {
|
||||
resolve(true)
|
||||
},
|
||||
fail: (error) => {
|
||||
reject(error)
|
||||
}
|
||||
})
|
||||
if (config.timeout !== 0) {
|
||||
setTimeout(() => {
|
||||
pushTab()
|
||||
}, config.timeout)
|
||||
} else {
|
||||
pushTab()
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
/**
|
||||
* 原uni.switchTab方法封装
|
||||
* @param options{any}原始参数
|
||||
* @param timeout{number}延时跳转时间默认0
|
||||
* @returns {Promise<boolean>}
|
||||
*/
|
||||
function pushToTab(options, timeout = 0) {
|
||||
checkUrl(options)
|
||||
return new Promise((resolve, reject) => {
|
||||
const switchTab = () => uni.switchTab({
|
||||
...options,
|
||||
success: () => {
|
||||
resolve(true)
|
||||
},
|
||||
fail: (error) => {
|
||||
reject(error)
|
||||
}
|
||||
})
|
||||
if (timeout !== 0) {
|
||||
setTimeout(() => {
|
||||
switchTab()
|
||||
}, timeout)
|
||||
} else {
|
||||
switchTab()
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
/**
|
||||
* 返回
|
||||
* @param options{any} 默认参数对象
|
||||
* @param timeout{number} 延时跳转
|
||||
* @returns {Promise<unknown>}
|
||||
*/
|
||||
function goBack(options, timeout = 0) {
|
||||
return new Promise((resolve, reject) => {
|
||||
const back = () => {
|
||||
const currentPageList = getCurrentPageList();
|
||||
// 如果页面栈,说明只有一个页面,直接重定向到首页
|
||||
if (currentPageList.length === 1) {
|
||||
pushToTab({url: '/pages/index/index'})
|
||||
return
|
||||
}
|
||||
uni.navigateBack({
|
||||
...options,
|
||||
success: () => {
|
||||
resolve(true)
|
||||
},
|
||||
fail: (error) => {
|
||||
reject(error)
|
||||
}
|
||||
});
|
||||
}
|
||||
if (timeout !== 0) {
|
||||
setTimeout(() => {
|
||||
back()
|
||||
}, timeout)
|
||||
} else {
|
||||
back()
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取跳转页参数解析对象
|
||||
* @param options{any} onLoad函数的原始参数
|
||||
* @returns {any}
|
||||
*/
|
||||
function getParams(options) {
|
||||
if (typeof options !== 'object') return {}
|
||||
if (!options[PARAMS_KEY]) return {}
|
||||
return JSON.parse(decodeURIComponent(options[PARAMS_KEY]));
|
||||
}
|
||||
|
||||
/**
|
||||
* 预加载页面
|
||||
* @param url
|
||||
* @returns {Promise<boolean>}
|
||||
*/
|
||||
function preLoad(url) {
|
||||
return new Promise((resolve, reject) => {
|
||||
uni.preloadPage({
|
||||
url,
|
||||
success: () => {
|
||||
resolve(true)
|
||||
},
|
||||
fail: (error) => {
|
||||
reject({
|
||||
message: `${ url }预加载失败,请检查路径`,
|
||||
error
|
||||
})
|
||||
}
|
||||
});
|
||||
})
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取当前页面对象
|
||||
* @returns {{prePage: ((Page.PageInstance<AnyObject, {}> & {})|null), currentPages: Array<Page.PageInstance<AnyObject, {}> & {}>, nowPage: ((Page.PageInstance<AnyObject, {}> & {})|null)}}
|
||||
*/
|
||||
function getCurrentPage() {
|
||||
const currentPages = getCurrentPages();
|
||||
return {
|
||||
currentPages,
|
||||
prePage: currentPages.length - 2 >= 0 ? currentPages[currentPages.length - 2] : null,
|
||||
nowPage: currentPages.length - 1 >= 0 ? currentPages[currentPages.length - 1] : null,
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取所有页面对象
|
||||
* @returns {Array<Page.PageInstance<AnyObject, {}> & {}>}
|
||||
*/
|
||||
function getCurrentPageList() {
|
||||
return getCurrentPages()
|
||||
}
|
||||
|
||||
return {
|
||||
push,
|
||||
pushToTab,
|
||||
goBack,
|
||||
getParams,
|
||||
preLoad,
|
||||
getCurrentPage,
|
||||
getCurrentPageList
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 校验URL
|
||||
* @param options
|
||||
*/
|
||||
const checkUrl = (options) => {
|
||||
if (!options.url) throw new Error('options 必须携带url参数')
|
||||
}
|
||||
|
||||
/**
|
||||
* 处理参数
|
||||
* 如果有参数的情况,使用encodeURIComponent + JSON.stringify格式化掉
|
||||
* @param options
|
||||
* @param data
|
||||
*/
|
||||
const processingParameter = (options, data) => {
|
||||
if (Object.keys(data).length > 0) {
|
||||
options.url = `${ options.url }?${ PARAMS_KEY }=${ encodeURIComponent(JSON.stringify(data)) }`
|
||||
}
|
||||
return options
|
||||
}
|
62
hooks/useScreen.js
Normal file
62
hooks/useScreen.js
Normal file
@ -0,0 +1,62 @@
|
||||
/**
|
||||
* @name: 设置屏幕相关事件
|
||||
* @author: kahu4
|
||||
* @date: 2023-10-30 14:16
|
||||
* @description:useScreen
|
||||
* @update: 2023-10-30 14:16
|
||||
* */
|
||||
|
||||
/**
|
||||
* 设置屏幕相关事件
|
||||
* @returns {{getScreenLight: (function(): Promise<unknown>), setScreenLight: (function(number): Promise<unknown>), setScreenKeepLight: (function(*): Promise<unknown>)}}
|
||||
*/
|
||||
export const useScreen = ()=>{
|
||||
/**
|
||||
* 设置屏幕亮度
|
||||
* @param value{number} 亮度值 0-1
|
||||
* @returns {Promise<unknown>}
|
||||
*/
|
||||
function setScreenLight(value){
|
||||
return new Promise((resolve, reject) => {
|
||||
uni.setScreenBrightness({
|
||||
value,
|
||||
success:()=>resolve(true),
|
||||
fail:(error)=>reject(error)
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
/**
|
||||
* 获得屏幕亮度
|
||||
* @returns {Promise<number>}
|
||||
*/
|
||||
function getScreenLight(){
|
||||
return new Promise((resolve, reject) => {
|
||||
uni.getScreenBrightness({
|
||||
success:({value})=>resolve(value),
|
||||
fail:(error)=>reject(error)
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置是否保持常亮状态。仅在当前应用生效,离开应用后设置失效。
|
||||
* @param isKeepOn
|
||||
* @returns {Promise<unknown>}
|
||||
*/
|
||||
function setScreenKeepLight(isKeepOn){
|
||||
return new Promise((resolve, reject) => {
|
||||
uni.setKeepScreenOn({
|
||||
keepScreenOn:isKeepOn,
|
||||
success:()=>resolve(true),
|
||||
fail:(error)=>reject(error)
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
return{
|
||||
setScreenLight,
|
||||
getScreenLight,
|
||||
setScreenKeepLight
|
||||
}
|
||||
}
|
50
hooks/useShearPlate.js
Normal file
50
hooks/useShearPlate.js
Normal file
@ -0,0 +1,50 @@
|
||||
/**
|
||||
* @name: 剪切版封装
|
||||
* @author: kahu4
|
||||
* @date: 2023-10-30 14:06
|
||||
* @description:useShearPlate
|
||||
* @update: 2023-10-30 14:06
|
||||
* */
|
||||
export const useShearPlate = () => {
|
||||
/**
|
||||
* 设置剪切版
|
||||
* @param text{string} 设置的内容
|
||||
* @param toast{string} 是否需要toast提示
|
||||
* @returns {Promise<unknown>}
|
||||
*/
|
||||
function setData(text, toast = '') {
|
||||
return new Promise((resolve, reject) => {
|
||||
uni.setClipboardData({
|
||||
data:text,
|
||||
showToast:false,
|
||||
success:()=>{
|
||||
if(toast){
|
||||
uni.showToast({title:toast})
|
||||
}
|
||||
return resolve(true)
|
||||
},
|
||||
fail:(error)=> {
|
||||
reject(error)
|
||||
}
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取当前剪切板内容
|
||||
* @returns {Promise<unknown>}
|
||||
*/
|
||||
function getData() {
|
||||
return new Promise((resolve, reject) => {
|
||||
uni.getClipboardData({
|
||||
success: (res) => resolve(res),
|
||||
fail: (error) => reject(error)
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
return {
|
||||
setData,
|
||||
getData,
|
||||
}
|
||||
}
|
97
hooks/useSystem.js
Normal file
97
hooks/useSystem.js
Normal file
@ -0,0 +1,97 @@
|
||||
/**
|
||||
* @name: useSystem
|
||||
* @author: kahu4
|
||||
* @date: 2023-10-30 12:23
|
||||
* @description:useSystem
|
||||
* @update: 2023-10-30 12:23
|
||||
* */
|
||||
|
||||
/**
|
||||
*
|
||||
* @returns {{getDeviceInfo: (function(): UniNamespace.GetDeviceInfoResult), getAppBaseInfo: (function(): UniNamespace.GetAppBaseInfoResult), getAppAuthorizeSetting: (function(): UniNamespace.GetAppAuthorizeSettingResult), getSystemSetting: (function(): UniNamespace.GetsystemsettingResult), getWindowInfo: (function(): UniNamespace.GetWindowInfoResult), getSystemInfo: (function(): Promise<unknown>), openAppAuthorizeSetting: (function(): Promise<unknown>)}}
|
||||
*/
|
||||
export const useSystem = ()=>{
|
||||
/**
|
||||
* 获取系统信息
|
||||
* @docs https://uniapp.dcloud.net.cn/api/system/info.html
|
||||
* @returns {Promise<UniNamespace.GetSystemInfoOptions>}
|
||||
*/
|
||||
function getSystemInfo(){
|
||||
return new Promise((resolve, reject) => {
|
||||
uni.getSystemInfo({
|
||||
success:(res)=>resolve(res),
|
||||
fail:(error)=>reject(error)
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取设备信息
|
||||
* @docs https://uniapp.dcloud.net.cn/api/system/getDeviceInfo.html
|
||||
* @returns {UniNamespace.GetDeviceInfoResult}
|
||||
*/
|
||||
function getDeviceInfo(){
|
||||
return uni.getDeviceInfo()
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取窗口信息
|
||||
* @docs https://uniapp.dcloud.net.cn/api/system/getWindowInfo.html
|
||||
* @returns {UniNamespace.GetWindowInfoResult}
|
||||
*/
|
||||
function getWindowInfo(){
|
||||
return uni.getWindowInfo()
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取微信 APP 基础信息
|
||||
* @docs https://uniapp.dcloud.net.cn/api/system/getAppBaseInfo.html
|
||||
* @returns {UniNamespace.GetAppBaseInfoResult}
|
||||
*/
|
||||
function getAppBaseInfo(){
|
||||
return uni.getAppBaseInfo()
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取App授权信息
|
||||
* @docs https://uniapp.dcloud.net.cn/api/system/getappauthorizesetting.html
|
||||
* @returns {UniNamespace.GetAppAuthorizeSettingResult}
|
||||
*/
|
||||
function getAppAuthorizeSetting(){
|
||||
return uni.getAppAuthorizeSetting()
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取设备设置
|
||||
* @docs https://uniapp.dcloud.net.cn/api/system/getsystemsetting.html
|
||||
* @returns {UniNamespace.GetsystemsettingResult}
|
||||
*/
|
||||
function getSystemSetting(){
|
||||
return uni.getSystemSetting()
|
||||
}
|
||||
|
||||
/**
|
||||
* 打开用户授权
|
||||
* @docs https://uniapp.dcloud.net.cn/api/system/openappauthorizesetting.html
|
||||
* @returns {Promise<unknown>}
|
||||
*/
|
||||
function openAppAuthorizeSetting(){
|
||||
return new Promise((resolve, reject) => {
|
||||
uni.openAppAuthorizeSetting({
|
||||
success:()=>resolve(true),
|
||||
fail:(error)=>reject(error)
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
return{
|
||||
getSystemInfo,
|
||||
getDeviceInfo,
|
||||
getWindowInfo,
|
||||
getAppBaseInfo,
|
||||
getAppAuthorizeSetting,
|
||||
getSystemSetting,
|
||||
openAppAuthorizeSetting
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user