鸿蒙微信开发库:一键搞定分享授权
·
介绍
今天我们来讲讲微信开放平台的三方库 相信很多同学在开发的时候都会遇到各种各样的坑,这是鸿蒙版本基于微信第三方简化封装的库,分享文字、分享图片、分享网页、分享小程序、打开小程序、打开微信,让大家开发更加便捷!
安装教程
ohpm install @free/wechat
使用说明
注意:必须要保证AGC签名和微信上保持一致
1、初始化,配置wxId以及handle监听方法
WeChat.install.setConfig({wxId:"wxc4daXXXXXXXXXXX",handleWant:want});
2、基础分享配置参数(可选)
interface HandlerAction{
onResp?: (req: BaseResp) => void // 请求完成回调
onReq?: (req: BaseReq) => void // 请求回调
}
interface MessageConfig extends HandlerAction{
title?: string // 标题
description?: string // 介绍
thumb?: Resource | string //
thumb64?: Resource | string // 图片太大需要压缩的thumb, 尽量自行处理图片.
shareType?: number // 分享类型 会话: 0, 朋友圈1
}
3、分享文字
WeChat.install.shareText("text",{onResp:(resp)=>{}})
4、分享图片
WeChat.install.shareImage("https://img.ixintu.com/download/jpg/201911/e25b904bc42a74d7d77aed81e66d772c.jpg!con",{onResp:(resp)=>{}})
5、分享网页
WeChat.install.shareWeb("https://developer.huawei.com/consumer/cn/",{onResp:(resp)=>{}})
6、分享小程序
WeChat.install.shareMini({username:"username",path:"path"},{onResp:(resp)=>{}})
7、打开微信
WeChat.install.openWX("weixin://dl/business/?t=YODfF8dNclo",{onResp:(resp)=>{}})
8、打开小程序
WeChat.install.openMini({username:"username",path:"path"},"path",{onResp:(resp)=>{}})
9、微信授权
WeChat.install.sendAuth({scope:"snsapi_userinfo",state:"session"},"path",{onResp:(resp)=>{}})
更多推荐

所有评论(0)