1.0.0 • Published 1 year ago

zhiji-wx v1.0.0

Weekly downloads
-
License
MIT
Repository
-
Last release
1 year ago
npm i zhiji-wx

/src/configuration.ts

import * as zhijiWx from 'zhiji-wx';

@Configuration({
  imports: [
    zhijiWx
  ],
})

配置 config

{
  "wx": {
    "appid": "string", //小程序appid
    "appsecret": "string", //小程序秘钥
    "url": "https://api.weixin.qq.com" //请求 url 非必填
  }
}

ZhijiWxService 文档

概述

封装一些微信相关的方法,小程序 openid 获取等

依赖

该服务依赖以下外部库:

  • @midwayjs/axios: 用于进行 HTTP 请求。

方法

getOpenid

async getOpenid(code:string): Promise<any>

发送请求到微信 API。

  • 参数:

    • code: 小程序 code,使用 wx.login 获取。
  • 返回: 返回微信的 openid 等数据。

getToken

getToken( ): string

返回微信 token。

getMobile

async getMobile(code: string,token:string,resKey:stgring): Promise<any>

获取小程序绑定手机号。

  • 参数:

    • code: 微信获取手机号组件返回 code。
    • token: token 使用 getToken 获取
    • resKey: 要返回的 key,不填可以返回所有 key。
1.0.0

1 year ago