原子操作

飞道科技

@dfeidao/atom-wxapp > api_interface接口类

External module: api_interface接口类

Index

Interfaces

Functions


Functions

add_card

add_card(cardList: Array<object>): Promise<boolean>

Defined in api/interface/add-card.ts:15

批量添加卡券

see: 微信官方文档

example:

import add_card from '@dfeidao/atom-wxapp/api/interface/add-card';
await add_card([{ cardId: '', cardExt: '{"code": "", "openid": "", "timestamp": "", "signature":""}' }]);

Parameters:

Name Type Description
cardList Array<object> 需要添加的卡券列表[{ cardId: ‘’, cardExt: ‘{“code”: “”, “openid”: “”, “timestamp”: “”, “signature”:””}’ }]

Returns: Promise<boolean>


authorize

authorize(scope: “scope.userInfo” | “scope.userLocation” | “scope.address” | “scope.invoiceTitle” | “scope.werun” | “scope.record” | “scope.writePhotosAlbum”): Promise<boolean>

Defined in api/interface/authorize.ts:16

提前向用户发起授权请求

description: 调用后会立刻弹窗询问用户是否同意授权小程序使用某项功能或获取用户的某些数据,但不会实际调用对应接口。如果用户之前已经同意授权,则不会出现弹窗,直接返回成功。

see: 微信官方文档

example:

import authorize from '@dfeidao/atom-wxapp/api/interface/authorize';
const res = await authorize('scope.record');

Parameters:

Name Type Description
scope “scope.userInfo” | “scope.userLocation” | “scope.address” | “scope.invoiceTitle” | “scope.werun” | “scope.record” | “scope.writePhotosAlbum” 需要获取权限的 scope’scope.userInfo’ | ‘scope.userLocation’ | ‘scope.address’ | ‘scope.invoiceTitle’ | ‘scope.werun’ | ‘scope.record’ | ‘scope.writePhotosAlbum’

Returns: Promise<boolean>


check_is_soter_enrolled_in_device

check_is_soter_enrolled_in_device(checkAuthMode: “fingerPrint” | “facial” | “speech”): Promise<object>

Defined in api/interface/check-is-soter-enrolled-in-device.ts:15

获取设备内是否录入如指纹等生物信息的接口

see: 微信官方文档

example:

import check_is_soter_enrolled_in_device from '@dfeidao/atom-wxapp/api/interface/check-is-soter-enrolled-in-device';
const res = await check_is_soter_enrolled_in_device('fingerPrint');

Parameters:

Name Type Description
checkAuthMode “fingerPrint” | “facial” | “speech” 认证方式 fingerPrint 指纹识别 facial 人脸识别 speech 声纹识别(暂未支持)

Returns: Promise<object>


check_is_support_soter_authentication

check_is_support_soter_authentication(): Promise<object>

Defined in api/interface/check-is-supper-soter-authentication.ts:14

获取本机支持的 SOTER 生物认证方式

see: 微信官方文档

example:

import check_is_support_soter_authentication from '@dfeidao/atom-wxapp/api/interface/check-is-supper-soter-authentication';
const res = await check_is_support_soter_authentication();

Returns: Promise<object>


check_session

check_session(): Promise<object>

Defined in api/interface/check-session.ts:14

检查登录状态是否过期

see: 微信官方文档

example:

import check_session from '@dfeidao/atom-wxapp/api/interface/check-session';
const res = await check_session();

Returns: Promise<object>


choose_address

choose_address(): Promise<object>

Defined in api/interface/choose-address.ts:15

获取用户收货地址

description: 调起用户编辑收货地址原生界面,并在编辑完成后返回用户选择的地址。

see: 微信官方文档

example:

import choose_address from '@dfeidao/atom-wxapp/api/interface/choose-address';
const res = await choose_address();

Returns: Promise<object>


choose_invoice_title

choose_invoice_title(): Promise<object>

Defined in api/interface/choose-invoice-title.ts:14

选择用户的发票抬头

see: 微信官方文档

example:

import choose_invoice_title from '@dfeidao/atom-wxapp/api/interface/choose-invoice-title';
const res = await choose_invoice_title();

Returns: Promise<object>


get_open_setting

get_open_setting(): Promise<object>

Defined in api/interface/get-open-setting.ts:15

调起客户端小程序设置界面,返回用户设置的操作结果

description: 设置界面只会出现小程序已经向用户请求过的权限。注意:2.3.0 版本开始,用户发生点击行为后,才可以跳转打开设置页,管理授权信息。

see: 微信官方文档

example:

import get_open_setting from '@dfeidao/atom-wxapp/api/interface/get-open-setting';
const res = await get_open_setting();

Returns: Promise<object>


get_setting

get_setting(): Promise<object>

Defined in api/interface/get-setting.ts:15

获取用户的当前设置

description: 返回值中只会出现小程序已经向用户请求过的权限。

see: 微信官方文档

example:

import get_setting from '@dfeidao/atom-wxapp/api/interface/get-setting';
const res = await get_setting();

Returns: Promise<object>


get_user_info

get_user_info(withCredentials?: undefined | false | true, lang?: undefined | string): Promise<object>

Defined in api/interface/get-user-info.ts:21

Parameters:

Name Type
Optional withCredentials undefined | false | true
Optional lang undefined | string

Returns: Promise<object>


get_we_run_data

get_we_run_data(): Promise<object>

Defined in api/interface/get-we-run-data.ts:15

获取用户过去三十天微信运动步数

description: 需要先调用 login 原子操作。步数信息会在用户主动进入小程序时更新。

see: 微信官方文档 login

example:

import get_we_run_data from '@dfeidao/atom-wxapp/api/interface/get-we-run-data';
const res = await get_we_run_data();

Returns: Promise<object>


login

login(): Promise<LoginResponse>

Defined in api/interface/login.ts:15

调用接口获取登录凭证(code)

description: 通过凭证进而换取用户登录态信息,包括用户的唯一标识(openid)及本次登录的会话密钥(session_key)等。用户数据的加解密通讯需要依赖会话密钥完成。

see: 微信官方文档

example:

import login from '@dfeidao/atom-wxapp/api/interface/login';
const res = await login();

Returns: Promise<LoginResponse>


navigate_back_mini_program(extraData?: undefined | object): Promise<boolean>

Defined in api/interface/navigate-back-mini-program.ts:16

返回到上一个小程序

description: 只有在当前小程序是被其他小程序打开时可以调用成功

see: 微信官方文档

example:

import navigate_back_mini_program from '@dfeidao/atom-wxapp/api/interface/navigate-back-mini-program';
const res = await navigate_back_mini_program({ foo: 'bar' });

Parameters:

Name Type Description
Optional extraData undefined | object 需要返回给上一个小程序的数据

Returns: Promise<boolean>


navigate_to_mini_program(appId: string, path?: undefined | string, extraData?: undefined | object, envVersion?: undefined | string): Promise<boolean>

Defined in api/interface/navigate-to-mini-program.ts:18

打开另一个小程序

see: 微信官方文档

example:

import navigate_to_mini_program from '@dfeidao/atom-wxapp/api/interface/navigate-to-mini-program';
const res = await navigate_to_mini_program('', 'page/index/index?id=123', { foo: 'bar' }, 'develop');

Parameters:

Name Type Description
appId string 要打开的小程序 appId
Optional path undefined | string 打开的页面路径,如果为空则打开首页
Optional extraData undefined | object 需要传递给目标小程序的数据
Optional envVersion undefined | string 要打开的小程序版本。仅在当前小程序为开发版或体验版时此参数有效。如果当前小程序是正式版,则打开的小程序必定是正式版。

Returns: Promise<boolean>


open_card

open_card(cardList: Array<object>): Promise<boolean>

Defined in api/interface/open-card.ts:14

查看微信卡包中的卡券

see: 微信官方文档

example:

import open_card from '@dfeidao/atom-wxapp/api/interface/open-card';
const res = await open_card([{ cardId: '', code: '' }]);

Parameters:

Name Type
cardList Array<object>

Returns: Promise<boolean>


request_payment

request_payment(systemid: string, trade_no: string, fee: string, des: string, openid: string, time_start: string, time_expire: string, usercode: string, attach: object): Promise<boolean>

Defined in api/interface/request-payment.ts:42

发起微信支付

see: 微信官方文档

example:

import request_payment from '@dfeidao/atom-wxapp/api/interface/request-payment';
const res = await request_payment('6611', 'dd1233215', '1000', '特惠商品', '', '20190318172530', '', '', {});

Parameters:

Name Type Description
systemid string 项目systemid
trade_no string 订单单号(最大长度32)
fee string 商品金额
des string 商品描述(最大长度128,不能为空)
openid string 微信用户唯一标示
time_start string 订单生成时间,格式为yyyyMMddHHmmss,如2009年12月25日9点10分10秒表示为20091225091010。
time_expire string 订单失效时间,格式为yyyyMMddHHmmss,如2009年12月27日9点10分10秒表示为20091227091010。注意:最短失效时间间隔必须大于5分钟 且存活时间不得超过两小时
usercode string 用户code
attach object 附加数据,原样返回;序列化后的字符串字节长度不能超过127

Returns: Promise<boolean>


start_soter_authentication

start_soter_authentication(requestAuthModes: Array<”fingerPrint” | “facial” | “speech”>, challenge: string, authContent?: undefined | string): Promise<object>

Defined in api/interface/start-soter-authentication.ts:17

开始 SOTER 生物认证

see: 微信官方文档

example:

import start_soter_authentication from '@dfeidao/atom-wxapp/api/interface/start-soter-authentication';
const res = await start_soter_authentication(['fingerPrint'], '123456', '请用指纹解锁');

Parameters:

Name Type Description
requestAuthModes Array<”fingerPrint” | “facial” | “speech”> 请求使用的可接受的生物认证方式 fingerPrint 指纹识别 facial 人脸识别 speech 声纹识别(暂未支持)
challenge string 挑战因子。挑战因子为调用者为此次生物鉴权准备的用于签名的字符串关键识别信息,将作为 resultJSON 的一部分,供调用者识别本次请求。例如:如果场景为请求用户对某订单进行授权确认,则可以将订单号填入此参数。
Optional authContent undefined | string 验证描述,即识别过程中显示在界面上的对话框提示内容

Returns: Promise<object>