更新记录

0.0.6(2023-03-22)

  • 新增 getVoice 方法,用于获取语音消息
  • 修复 getImage 方法里的 MsgType 参数错误问题

0.0.5(2022-09-11)

  • 修复 调用 sendCustomMsg 方法时出现的 数据格式 错误问题

0.0.4(2022-09-11)

  • 修复 调用 sendCustomMsg 方法时出现的 data 以声明错误
查看更多

平台兼容性

阿里云 腾讯云 支付宝云
×

云函数类插件通用教程

使用云函数类插件的前提是:使用HBuilderX 2.9+


sherer-wechat-utils

微信小程序和公众号便捷程序

WechatSalon 的使用方法

const { WechatSalon } = require('sherer-wechat-utils');

const token = "Your token"; // 小程序或公众号的令牌(Token)
const appid = "Your appid"; // 小程序或公众号的AppId(安全模式时必要)
const encodingAESKey = "Your encodingAESKey"; // 小程序或公众号的消息加解密密钥(encodingAESKey, 安全模式时必要)

let result;
let salon = new WechatSalon(event, { appid, token, encodingAESKey });
let check = await salon.run({
    subscribe: async res => { // 关注事件
        // 您的逻辑代码
        result = salon.getText("欢迎关注");
    },
    unsubscribe: async res => { // 取消关注事件
        // 您的逻辑代码
    },
    Scan: async res => { // 扫码事件
        // 您的逻辑代码
    },
    Location: async res => { // 上报地理位置事件
        // 您的逻辑代码
    },
    Click: async res => { // 自定义菜单点击事件
        // 您的逻辑代码
    },
    View: async res => { // 自定义菜单跳转事件
        // 您的逻辑代码
    },
    TemplateSendJobFinish: async res => { // 模板消息发送任务完成事件
        // 您的逻辑代码
    },
    ViewMiniProgram: async res => { // 跳转小程序事件
        // 您的逻辑代码
    },
    text: async res => { // 文本消息
        // 您的逻辑代码
        result = salon.getImage("图片 mediaId");
    },
    image: async res => { // 图片消息
        // 您的逻辑代码
    },
    voice: async res => { // 语音消息
        // 您的逻辑代码
    },
    video: async res => { // 视频消息
        // 您的逻辑代码
    },
    shortvideo: async res => { // 短视频消息
        // 您的逻辑代码
    },
    location: async res => { // 位置消息
        // 您的逻辑代码
    },
    link: async res => { // 链接消息
        // 您的逻辑代码
    },
});

return check || result;

隐私、权限声明

1. 本插件需要申请的系统权限列表:

2. 本插件采集的数据、发送的服务器地址、以及数据用途说明:

3. 本插件是否包含广告,如包含需详细说明广告表达方式、展示频率:

许可协议

MIT协议

使用中有什么不明白的地方,就向插件作者提问吧~ 我要提问