Skip to content

wechat

wechat: Object

微信相关办法

Type declaration

NameType
WECHAT_METHOD_TO_SCOPE{ addPhoneContact: string = SCOPE.ADD_PHONE_CONTACT; getFuzzyLocation: string = SCOPE.USER_FUZZY_LOCATION; getLocation: string = SCOPE.USER_LOCATION; getWeRunData: string = SCOPE.WERUN; openBluetoothAdapter: string = SCOPE.BLUETOOTH; saveImageToPhotosAlbum: string = SCOPE.WRITE_PHOTOS_ALBUM; saveVideoToPhotosAlbum: string = SCOPE.WRITE_PHOTOS_ALBUM; startLocationUpdate: string = SCOPE.USER_LOCATION; startLocationUpdateBackground: string = SCOPE.USER_LOCATION_BACKGROUND; startRecord: string = SCOPE.RECORD }
WECHAT_METHOD_TO_SCOPE.addPhoneContactstring
WECHAT_METHOD_TO_SCOPE.getFuzzyLocationstring
WECHAT_METHOD_TO_SCOPE.getLocationstring
WECHAT_METHOD_TO_SCOPE.getWeRunDatastring
WECHAT_METHOD_TO_SCOPE.openBluetoothAdapterstring
WECHAT_METHOD_TO_SCOPE.saveImageToPhotosAlbumstring
WECHAT_METHOD_TO_SCOPE.saveVideoToPhotosAlbumstring
WECHAT_METHOD_TO_SCOPE.startLocationUpdatestring
WECHAT_METHOD_TO_SCOPE.startLocationUpdateBackgroundstring
WECHAT_METHOD_TO_SCOPE.startRecordstring
WECHAT_SCOPE{ ADD_PHONE_CONTACT: string = 'addPhoneContact'; BLUETOOTH: string = 'bluetooth'; CAMERA: string = 'camera'; RECORD: string = 'record'; USER_FUZZY_LOCATION: string = 'userFuzzyLocation'; USER_LOCATION: string = 'userLocation'; USER_LOCATION_BACKGROUND: string = 'userLocationBackground'; WERUN: string = 'werun'; WRITE_PHOTOS_ALBUM: string = 'writePhotosAlbum' }
WECHAT_SCOPE.ADD_PHONE_CONTACTstring
WECHAT_SCOPE.BLUETOOTHstring
WECHAT_SCOPE.CAMERAstring
WECHAT_SCOPE.RECORDstring
WECHAT_SCOPE.USER_FUZZY_LOCATIONstring
WECHAT_SCOPE.USER_LOCATIONstring
WECHAT_SCOPE.USER_LOCATION_BACKGROUNDstring
WECHAT_SCOPE.WERUNstring
WECHAT_SCOPE.WRITE_PHOTOS_ALBUMstring
addPhoneContact(options?: any) => Promise<any>
authorize(scope: string) => Promise<boolean>
authorizeWithFallback(scope: string, modalOptions: ShowModalOptions) => Promise<undefined | boolean>
checkUpdateManager(options: { showCancel: undefined | boolean = false }) => void
compareVersion(ver1: string, ver2: string) => -1 | 0 | 1
decryptPhoneNumber(e: any) => Promise<any>
decryptWeRunData() => Promise<any>
getAuthorizedByMethod(method: string) => Promise<undefined | boolean>
getAuthorizedByScope(scope: string) => Promise<undefined | boolean>
getBaseLibVersion() => any
getFuzzyLocation(options?: any) => Promise<any>
getImageInfo(src: string) => Promise<any>
getLocation(options?: any) => Promise<any>
getRecorderManager() => Recorder
getSubscriptionsSetting() => Promise<SubscriptionsSetting>
getWeRunData(options?: any) => Promise<any>
openBluetoothAdapter(options?: any) => Promise<any>
openSetting(scope: string) => Promise<undefined | boolean | OpenSettingSuccessCallbackResult>
saveImageToPhotosAlbumFunction
saveVideoToPhotosAlbum(options?: any) => Promise<any>
startLocationUpdate(options?: any) => Promise<any>
startLocationUpdateBackground(options?: any) => Promise<any>
startRecord(options?: any) => Promise<any>

WECHAT_METHOD_TO_SCOPE: { addPhoneContact: string = SCOPE.ADD_PHONE_CONTACT; getFuzzyLocation: string = SCOPE.USER_FUZZY_LOCATION; getLocation: string = SCOPE.USER_LOCATION; getWeRunData: string = SCOPE.WERUN; openBluetoothAdapter: string = SCOPE.BLUETOOTH; saveImageToPhotosAlbum: string = SCOPE.WRITE_PHOTOS_ALBUM; saveVideoToPhotosAlbum: string = SCOPE.WRITE_PHOTOS_ALBUM; startLocationUpdate: string = SCOPE.USER_LOCATION; startLocationUpdateBackground: string = SCOPE.USER_LOCATION_BACKGROUND; startRecord: string = SCOPE.RECORD }

-


WECHAT_METHOD_TO_SCOPE.addPhoneContact: string

-


WECHAT_METHOD_TO_SCOPE.getFuzzyLocation: string

-


WECHAT_METHOD_TO_SCOPE.getLocation: string

-


WECHAT_METHOD_TO_SCOPE.getWeRunData: string

-


WECHAT_METHOD_TO_SCOPE.openBluetoothAdapter: string

-


WECHAT_METHOD_TO_SCOPE.saveImageToPhotosAlbum: string

-


WECHAT_METHOD_TO_SCOPE.saveVideoToPhotosAlbum: string

-


WECHAT_METHOD_TO_SCOPE.startLocationUpdate: string

-


WECHAT_METHOD_TO_SCOPE.startLocationUpdateBackground: string

-


WECHAT_METHOD_TO_SCOPE.startRecord: string

-


WECHAT_SCOPE: { ADD_PHONE_CONTACT: string = 'addPhoneContact'; BLUETOOTH: string = 'bluetooth'; CAMERA: string = 'camera'; RECORD: string = 'record'; USER_FUZZY_LOCATION: string = 'userFuzzyLocation'; USER_LOCATION: string = 'userLocation'; USER_LOCATION_BACKGROUND: string = 'userLocationBackground'; WERUN: string = 'werun'; WRITE_PHOTOS_ALBUM: string = 'writePhotosAlbum' }

-


WECHAT_SCOPE.ADD_PHONE_CONTACT: string

-


WECHAT_SCOPE.BLUETOOTH: string

-


WECHAT_SCOPE.CAMERA: string

-


WECHAT_SCOPE.RECORD: string

-


WECHAT_SCOPE.USER_FUZZY_LOCATION: string

-


WECHAT_SCOPE.USER_LOCATION: string

-


WECHAT_SCOPE.USER_LOCATION_BACKGROUND: string

-


WECHAT_SCOPE.WERUN: string

-


WECHAT_SCOPE.WRITE_PHOTOS_ALBUM: string

-


addPhoneContact: (options?: any) => Promise<any>

-


authorize: (scope: string) => Promise<boolean>

用户授权 返回用户对某项权限的授权结果。未有授权记录的,则发起一次授权询问


authorizeWithFallback: (scope: string, modalOptions: ShowModalOptions) => Promise<undefined | boolean>

请求用户授权权限:

  1. 若用户此前已授权并同意过指定权限,将会返回 true。
  2. 若用户从未授权过指定权限,发起授权并返回结果。
  3. 若用户此前已拒绝授权指定权限,引导用户前往设置页,并返回用户在设置页面的对相关权限的选择结果。 一般在项目中不单独使用,需要授权的 API 已通过 generateMethodWithAuthorize 方法进行包装,直接使用 wechat.getLocation() 即可

checkUpdateManager: (options: { showCancel: undefined | boolean = false }) => void

检查更新版本


compareVersion: (ver1: string, ver2: string) => -1 | 0 | 1

比较版本


decryptPhoneNumber: (e: any) => Promise<any>

解密手机号


decryptWeRunData: () => Promise<any>

解密微信运动信息


getAuthorizedByMethod: (method: string) => Promise<undefined | boolean>

获取 method 名称对应权限的授权情况


getAuthorizedByScope: (scope: string) => Promise<undefined | boolean>

获取 scope 名称对应权限的授权情况


getBaseLibVersion: () => any

获取基础库版本


getFuzzyLocation: (options?: any) => Promise<any>

-


getImageInfo: (src: string) => Promise<any>

由于 uni.getImageInfo 使用 Promise 和 success 回调行为不一致,使用回调获取 image info 会时代码比较冗长,故使用该方法对 Taro.getImageInfo 进行封装


getLocation: (options?: any) => Promise<any>

-


getRecorderManager: () => Recorder

获取录音管理器


getSubscriptionsSetting: () => Promise<SubscriptionsSetting>

获取订阅消息设置


getWeRunData: (options?: any) => Promise<any>

-


openBluetoothAdapter: (options?: any) => Promise<any>

-


openSetting: (scope: string) => Promise<undefined | boolean | OpenSettingSuccessCallbackResult>

打开设置页面,并在用户返回小程序时,获取对应权限的授权情况。


saveImageToPhotosAlbum: Function

保存图片到系统相册(支持传入网络图片)

See

官方文档


saveVideoToPhotosAlbum: (options?: any) => Promise<any>

-


startLocationUpdate: (options?: any) => Promise<any>

-


startLocationUpdateBackground: (options?: any) => Promise<any>

-


startRecord: (options?: any) => Promise<any>

-


源码

wechat.js