更新记录
1.0.0(2025-05-05)
初始化
平台兼容性
Vue2 | Vue3 |
---|---|
√ | √ |
App | 快应用 | 微信小程序 | 支付宝小程序 | 百度小程序 | 字节小程序 | QQ小程序 |
---|---|---|---|---|---|---|
HBuilderX 4.63,Android:5.0,iOS:不确定,HarmonyNext:不确定 | × | × | × | × | × | × |
钉钉小程序 | 快手小程序 | 飞书小程序 | 京东小程序 | 鸿蒙元服务 |
---|---|---|---|---|
× | × | × | × | × |
H5-Safari | Android Browser | 微信浏览器(Android) | QQ浏览器(Android) | Chrome | IE | Edge | Firefox | PC-Safari |
---|---|---|---|---|---|---|---|---|
× | × | × | × | × | × | × | × | × |
xwq-wx-share 微信分享、登录功能封装(目前只支持Android端)
注意!
插件需要打自定义基座运行!
插件需要打自定义基座运行!
插件需要打自定义基座运行!
使用说明文档
参数名称 | 类型 | 必填 | 默认值 | 描述 |
---|---|---|---|---|
type | string | Y | - | 设置要分享的类型,可选:text、image、video、music、web、 |
imageUrl | string | Y | - | 分享图片链接 |
imgThumb | string | N | - | 分享缩略图,支持本地路径,例如:/static/img/xxxx.png,大小<32kb,除了text类型其他都支持 |
scene | string | Y | - | Session -好友 Timeline -朋友圈 Favorite -收藏 |
text | string | Y | - | 文本内容 纯文本分享 |
title | string | Y | - | 分享小程序、网页、视频 、音乐类型标题 |
summary | string | Y | - | 分享卡片的描述内容 |
videoUrl | string | Y | - | 分享视频链接 |
videoLowBandUrl | string | N | - | 低清晰度视频链接 |
musicUrl | string | Y | - | 分享音乐地址 |
musicLowBandUrl | string | N | - | 低码率备用链接 |
webUrl | string | Y | - | 分享网页地址 |
filePath | string | Y | - | 分享文件地址,暂不支持该类型分享 |
初始化SDK配置
import { useWxSDK } from "@/uni_modules/xwq-wx-share";
import type{ UseWxOption, UseWxBack, SuccessBackType, FailBackType, ShareOptions,AuthorLoginOptions } from "@/uni_modules/xwq-wx-share/utssdk/interface.uts";
const useWxUtils : UseWxBack = useWxSDK({
appId: 'wx0b173f5922c84a3b', //微信开放平台AppID
success: (res : SuccessBackType) => {
console.log('初始化成功', res)
},
fail: (res : FailBackType) => {
console.log('初始化失败', res)
}
} as UseWxOption);
文本分享
const webShare = () => {
useWxUtils.share({
type: 'text',
title: '内容',
scene: 'Session'
} as ShareOptions)
}
图片分享
const webShare = () => {
useWxUtils.share({
type: 'image',
summary: '图片分享描述内容',
title: '图片分享描述标题',
imgThumb: 'https://example.com/avart-userDefault-img.png',
// imgThumb: '/static/girl.jpg',
// imageUrl:'/static/girl.jpg',
imageUrl:'https://example.com/201908/buche3.png',
scene: 'Session'
} as ShareOptions)
};
网页分享
const webShare = () => {
useWxUtils.share({
type: 'web',
summary: '副标题副标题',
title: '描述内容描述内容',
webUrl: 'https://www.baidu.com',
imgThumb: '/static/logo.png',
// imgThumb:'https://example.com/AI_report_eight_menu_icon01_active.png',
scene: 'Session'
} as ShareOptions)
};
音乐分享
const webShare = () => {
useWxUtils.share({
type: 'music',
summary: '歌手 - 专辑',
title: '歌曲名称-搀扶',
imgThumb: 'https://example.com/avart-userDefault-img.png',
musicUrl:'https://example.com/73b2100fa7ab427bea8b9e0636df993c.mp3',
scene: 'Session'
} as ShareOptions)
};
视频分享
const videoShare=()=>{
useWxUtils.share({
type: 'video',
summary: '视频描述内容',
title: '视频标题',
imgThumb: 'https://example.com/avart-userDefault-img.png',
videoUrl:'https://example.com/vip_member_video.mp4',
scene: 'Session'
} as ShareOptions)
};
微信授权登录
const wxLogin=()=>{
useWxUtils.login({
// scope:'snsapi_userinfo',
success:(res:SuccessBackType)=>{
console.log(res)
},
fail:(res:FailBackType)=>{
console.log(res)
}
} as AuthorLoginOptions)
}
打开微信
const openWx=()=>{
useWxUtils.openWx()
};
判断是否安装微信客户端
const isWXAppInstalled=()=>{
const status=useWxUtils.isWXAppInstalled()
console.log('status==',status)
};