setting
getSetting
例
import { getSetting } from '@/util/function/wx/setting'// 获取权限列表getSetting().then((res) => {console.log(res)})// 获取相册权限是否存在getSetting('scope.writePhotosAlbum').then((res) => {console.log(res)})
参数
| 参数 | 类型 | 是否必填 | 说明 |
|---|---|---|---|
| scope | String | N | 要验证的权限,如果不传则返回所有权限,如果传则返回 Boolean |
authorize
例
import { authorize } from '@/util/function/wx/setting'// 获取相册权限authorize('scope.writePhotosAlbum').then((res) => {console.log(res)})
参数
| 参数 | 类型 | 是否必填 | 说明 |
|---|---|---|---|
| scope | String | Y | 字符有效值 ‘scope.userInfo’: ‘用户信息’, ‘scope.userLocation’: ‘地理位置’, ‘scope.userLocationBackground’: ‘后台定位’, ‘scope.werun’: ‘微信运动步数’, ‘scope.record’: ‘录音’, ‘scope.writePhotosAlbum’: ‘相册’, ‘scope.camera’: ‘摄像头’, |
| again | Boolean | N | 是否进行2次授权请求默认 true |
openSetting
调起客户端小程序设置界面,返回用户设置的操作结果。设置界面只会出现小程序已经向用户请求过的权限。
例
import { openSetting } from '@/util/function/wx/setting'// 获取相册权限openSetting('scope.writePhotosAlbum').then((res) => {console.log(res)})// 返回所有权限openSetting('').then((res) => {console.log(res)})
参数
| 参数 | 类型 | 是否必填 | 说明 |
|---|---|---|---|
| scope | String | Y | 字符有效值 ‘scope.userInfo’: ‘用户信息’, ‘scope.userLocation’: ‘地理位置’, ‘scope.userLocationBackground’: ‘后台定位’, ‘scope.werun’: ‘微信运动步数’, ‘scope.record’: ‘录音’, ‘scope.writePhotosAlbum’: ‘相册’, ‘scope.camera’: ‘摄像头’, |
| withSubscriptions | Boolean | N | 是否同时获取用户订阅消息的订阅状态,默认不获取。注意:withSubscriptions 只返回用户勾选过订阅面板中的“总是保持以上选择,不再询问”的订阅消息。默认 false |
file
chooseImage
例
import { chooseImage } from '@/util/function/wx/file/index.js';chooseImage(true, false, {}).then((res) => {console.log(res[0])})
参数
| 参数 | 类型 | 是否必填 | 说明 |
|---|---|---|---|
| compress | Boolean | N | 是否进行2次压缩(默认 false ) |
| getInfo | Boolean | N | 是否得到详情信息(默认 false ) |
| config | Object | N | 默认配置 https://developers.weixin.qq.com/miniprogram/dev/api/media/image/wx.chooseImage.html |
compressImages
例
import { compressImages } from '@/util/function/wx/file/index.js';compressImages(url).then((res) => {console.log(res)})
参数
| 参数 | 类型 | 是否必填 | 说明 |
|---|---|---|---|
| paths | Array/String | Y | 图片路径或图片路径数组 |
| quality | Number | N | 压缩程度(默认 80 ) |
getImageInfos
例
import { chooseImage } from '@/util/function/wx/file/index.js';getImageInfos(paths).then((res) => {console.log(res)})
参数
| 参数 | 类型 | 是否必填 | 说明 |
|---|---|---|---|
| paths | Array / String | Y | 图片路径数组或图片路径 |
saveImage
例
import { saveImage } from '@/util/function/wx/file/index.js';saveImage('url').then((res) => {console.log(res)})
参数
| 参数 | 类型 | 是否必填 | 说明 |
|---|---|---|---|
| filePath | String | Y | 图片路径 |
chooseMedia
例
import { chooseMedia } from '@/util/function/wx/file/index.js';chooseMedia().then((res) => {console.log(res)})
参数
| 参数 | 类型 | 是否必填 | 说明 |
|---|---|---|---|
| config | Object | N | 默认配置 https://developers.weixin.qq.com/miniprogram/dev/api/media/video/wx.chooseMedia.html |
chooseMessageFile
例
import { chooseMessageFile } from '@/util/function/wx/file/index.js';chooseMessageFile().then((res) => {console.log(res)})
参数
| 参数 | 类型 | 是否必填 | 说明 |
|---|---|---|---|
| config | Object | N | 默认配置 https://developers.weixin.qq.com/miniprogram/dev/api/media/image/wx.chooseMessageFile.html |
