UNPKG

coa-wx-isv

Version:

一个轻量的微信SDK服务商版 for Node.js

65 lines (64 loc) 3.38 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.WxIsvMpService = void 0; const WxIsvServiceBase_1 = require("../libs/WxIsvServiceBase"); class WxIsvMpService extends WxIsvServiceBase_1.WxIsvServiceBase { /** * 获取展示的公众号信息 * 使用本接口可以获取扫码关注组件所展示的公众号信息 * 详见 https://developers.weixin.qq.com/doc/oplatform/Third-party_Platforms/2.0/api/subscribe_component/getshowwxaitem.html * @param accessToken 小程序接口调用令牌 */ async getShowItem(accessToken) { return (await this.request('GET', '/wxa/getshowwxaitem', {}, { access_token: accessToken })); } /** * 获取可以用来设置的公众号列表 * 通过本接口可以获取扫码关注组件允许展示的公众号列表 * 详见 https://developers.weixin.qq.com/doc/oplatform/Third-party_Platforms/2.0/api/subscribe_component/getwxamplinkforshow.html * @param accessToken 小程序接口调用令牌 * @param page 页码,从 0 开始 * @param num 每页记录数,最大为 20 */ async getShowItemList(accessToken, page = 0, num = 20) { return (await this.request('GET', '/wxa/getwxamplinkforshow', {}, { page, num, access_token: accessToken })); } /** * 设置展示的公众号信息 * 使用本接口可以设置扫码关注组件所展示的公众号信息 * 详见 https://developers.weixin.qq.com/doc/oplatform/Third-party_Platforms/2.0/api/subscribe_component/updateshowwxaitem.html * @param accessToken * @param mpAppId 新的公众号 appid * @param subscribe 是否打开扫码关注组件,0 关闭,1 开启,默认为1 */ async updateShowItem(accessToken, mpAppId, subscribe = 1) { return (await this.request('POST', '/wxa/updateshowwxaitem', { appid: mpAppId, wxa_subscribe_biz_flag: subscribe }, { access_token: accessToken })); } /** * 获取公众号关联的小程序 * 详见 https://developers.weixin.qq.com/doc/oplatform/openApi/OpenApiDoc/officalaccount-management/link-miniprogram/getLinkMiniprogram.html * @param accessToken 接口调用凭证 */ async getLinkMiniprogram(accessToken) { return await this.request('POST', '/cgi-bin/wxopen/wxamplinkget', {}, { access_token: accessToken }); } /** * 公众号关联小程序 * 详见 https://developers.weixin.qq.com/doc/oplatform/openApi/OpenApiDoc/officalaccount-management/link-miniprogram/linkMiniprogram.html * @param accessToken 接口调用凭证 * @param appWxaId 小程序appid */ async linkMiniprogram(accessToken, appWxaId) { return await this.request('POST', '/cgi-bin/wxopen/wxamplink', { appid: appWxaId, notify_users: 0, show_profile: 0 }, { access_token: accessToken }); } /** * 公众号解除关联小程序 * 详见 https://developers.weixin.qq.com/doc/oplatform/openApi/OpenApiDoc/officalaccount-management/link-miniprogram/unlinkMiniprogram.html * @param accessToken 接口调用凭证 * @param appWxaId 小程序appid */ async unlinkMiniprogram(accessToken, appWxaId) { return await this.request('POST', '/cgi-bin/wxopen/wxampunlink', { appid: appWxaId }, { access_token: accessToken }); } } exports.WxIsvMpService = WxIsvMpService;