0.1.1 • Published 3 years ago

alipay-mini-api-promise v0.1.1

Weekly downloads
-
License
MIT
Repository
github
Last release
3 years ago

alipay-mini-api-promise

介绍

支付宝小程序 api(my) 转成 promise 数组形式,使用友好。

安装

npm install alipay-mini-api-promise

使用

import { promisifyAll } from 'alipay-mini-api-promise'
const myP = promisifyAll(my)

async function test() {
  const [err,res] = await myP.scan({ type: 'qr' })
  return data
}

使用注意

1.未处理 my.ap 下面的api,建议直接使用 my.ap 的形式 2.部分回调形式的监听回调的 api ,建议使用原始形式,如 my.onGyroscopeChange

最佳实践

app.ts 引入

// app.ts
import { promisifyAll } from 'alipay-mini-api-promise'
const myP = promisifyAll(my)

App({
  globalData: {myP}
})

封装 utils 文件

myP = getApp().globalData
export { myP }

页面使用:

import { myP } from 'utils'
myP.scan({ type: 'qr' })

todo

  • my.ap 的校验实现

  • myP 挂载到 my.$p 下面,方便调用

感谢

wechat-miniprogram/miniprogram-api-promise

贡献

issue

LICENSE

MIT

0.1.1

3 years ago

0.1.0

3 years ago

0.0.5

3 years ago

0.0.4

3 years ago

0.0.3

3 years ago

0.0.2

3 years ago

0.0.1

3 years ago

1.0.0

3 years ago