更新记录
1.0.20260420(2026-04-18)
- 修正已知问题
1.0.20260419(2026-04-18)
- 修复已知问题
1.0.20260418(2026-04-18)
- 发布无支付版
查看更多
平台兼容性
uni-app(4.57)
| Vue2 |
Vue3 |
Chrome |
Safari |
app-vue |
app-nvue |
Android |
iOS |
鸿蒙 |
| - |
√ |
× |
× |
× |
× |
√ |
√ |
√ |
| 微信小程序 |
支付宝小程序 |
抖音小程序 |
百度小程序 |
快手小程序 |
京东小程序 |
鸿蒙元服务 |
QQ小程序 |
飞书小程序 |
小红书小程序 |
快应用-华为 |
快应用-联盟 |
| × |
× |
× |
× |
× |
× |
× |
× |
× |
× |
× |
× |
uni-app x(4.57)
| Chrome |
Safari |
Android |
iOS |
鸿蒙 |
微信小程序 |
| - |
- |
√ |
√ |
√ |
- |
引入插件
点击插件试用引入到项目
- 按下方修改 Android / iOS / Harmony 需要修改的内容
- 打包自定义基座包
- 按照下方示例测试
- 先插件试用,完全符合需求后购买
- 本插件为无支付版本,不包含微信支付相关接口
SDK Version
- iOS SDK 2.0.5
- Android SDK 6.8.34
- Harmony SDK 1.0.16
iOS
- 替换
uni_modules/cms-weixinnopay/utssdk/app-ios/Info.plist 文件,将其中【appId】替换为你自己的应用 appId
Android
Harmony 鸿蒙
- 参照链接创建
harmony-configs/entry/src/main/module.json5 文件:定义 querySchemes
- 在
harmony-configs/entry/src/main/module.json5 的 module 下增加 "querySchemes": ["weixin","wxopensdk"]
- 在
harmony-configs/entry/src/main/module.json5 的 module/abilities/skills/actions 下增加 "wxentity.action.open"
插件引入
import * as wxUtils from "@/uni_modules/cms-weixinnopay";
插件方法
| 方法 |
描述 |
参数 |
兼容性 |
| isInstalled(): boolean |
是否安装微信 |
无 |
Android / iOS / Harmony |
| openApp(): boolean |
打开微信 |
无 |
Android / iOS / Harmony |
| registerApp(RegisterAppOption): boolean |
注册 App |
见下方 |
Android / iOS / Harmony |
| login(LoginWxOption): void |
授权登录 |
见下方 |
Android / iOS / Harmony |
| sendText(SendWxMessageOption): void |
分享文本 |
见下方 |
Android / iOS / Harmony |
| sendImage(SendWxMessageOption): void |
分享图片 |
见下方 |
Android / iOS / Harmony |
| sendVideo(SendWxMessageOption): void |
分享视频 |
见下方 |
Android / iOS / Harmony |
| sendLink(SendWxMessageOption): void |
分享链接 |
见下方 |
Android / iOS / Harmony |
| sendMiniProgram(SendWxMessageOption): void |
分享小程序 |
见下方 |
Android / iOS / Harmony |
| openMiniProgram(SendWxMessageOption): void |
打开小程序 |
见下方 |
Android / iOS / Harmony |
| openWWService(SendWxMessageOption): void |
打开微信客服 |
见下方 |
Android / iOS / Harmony |
RegisterAppOption
| 参数 |
类型 |
描述 |
必填 |
| appId |
string |
微信应用 appId |
是 |
| universalLink |
string |
iOS Universal Link |
iOS 平台必填 |
LoginWxOption
| 参数 |
类型 |
描述 |
必填 |
| scope |
string |
应用授权作用域 |
否 |
| state |
string |
自定义字符串,授权成功后会原样返回 |
否 |
| success(code: string, state: string): void |
function |
授权成功回调,code 为微信返回数据,state 为原样返回值 |
否 |
| fail(errCode, errMsg): void |
function(number, string) |
授权失败回调 |
否 |
SendWxMessageOption
| 参数 |
类型 |
描述 |
必填 |
| scene |
number |
分享场景:0 对话,1 朋友圈,2 收藏(默认 0) |
否 |
| title |
string |
消息标题(sendLink/sendMiniProgram/openMiniProgram/sendVideo 有效) |
否 |
| desc |
string |
消息描述(sendLink/sendMiniProgram/openMiniProgram/sendVideo 有效) |
否 |
| thumbUrl |
string |
消息封面(sendLink/sendMiniProgram/openMiniProgram/sendVideo 有效) |
否 |
| text |
string |
文本内容 |
sendText 必填 |
| imagePath |
string |
图片路径(支持本地路径或网络地址) |
sendImage 必填 |
| entranceMiniProgramUsername |
string |
图片消息携带小程序入口用户名(iOS 可用) |
否 |
| entranceMiniProgramPath |
string |
图片消息携带小程序入口路径(iOS 可用) |
否 |
| videoUrl |
string |
视频链接 |
sendVideo 必填 |
| videoLowBandUrl |
string |
低带宽视频链接(sendVideo 有效) |
否 |
| webpageUrl |
string |
网页链接 / 小程序兼容低版本网页链接 |
sendLink 必填 |
| userName |
string |
小程序原始 ID |
sendMiniProgram/openMiniProgram 必填 |
| path |
string |
小程序 path |
否 |
| withShareTicket |
boolean |
小程序是否使用 shareTicket(sendMiniProgram 有效) |
否 |
| miniprogramType |
number |
小程序类型:正式版 0,测试版 1,体验版 2(默认 0) |
否 |
| corpId |
string |
微信客服企业 ID |
openWWService 必填 |
| url |
string |
微信客服 URL |
openWWService 必填 |
| success() |
function |
成功回调 |
否 |
| fail(errCode, errMsg) |
function(number, string) |
失败回调 |
否 |
错误码
- 小于 0 的错误码为微信自身错误码,不在下方列表中
| 错误码 |
描述 |
| 9010001 |
未安装微信 |
| 9010002 |
未调用 registerApp |
| 9010003 |
iOS send fail |
| 9010004 |
鸿蒙分享仅支持分享到对话 |
| 9020001 |
sendImage: imagePath 未填写 |
| 9030001 |
sendVideo: videoUrl 未填写 |
| 9030002 |
sendVideo: 鸿蒙 SDK 暂不支持分享视频 |
| 9040001 |
sendLink: webpageUrl 未填写 |
| 9050001 |
sendMiniProgram/openMiniProgram: userName 未填写 |
| 9060001 |
openWWService: corpId 未填写 |
| 9060002 |
openWWService: url 未填写 |
| 9060003 |
openWWService: 当前微信版本不支持 |
| 9070001 |
sendText: text 未填写 |
| 9080001 |
openMiniProgram: 鸿蒙 SDK 暂不支持打开微信小程序 |
uni-app 示例
所有方法需在 registerApp() 调用之后执行
<template>
<view>
<button type="primary" @click="registerWx">注册微信</button>
<button type="primary" @click="isWXAppInstalled">是否安装微信</button>
<button type="primary" @click="openApp">打开微信</button>
<button type="primary" @click="login">登录</button>
<button type="primary" @click="sendText">分享文本</button>
<button type="primary" @click="sendLink">分享网页</button>
<button type="primary" @click="sendMiniProgram">分享小程序</button>
<button type="primary" @click="openMiniProgram">打开小程序</button>
<button type="primary" @click="openWWService">打开客服</button>
</view>
</template>
<script>
import * as wxUtils from "@/uni_modules/cms-weixinnopay";
export default {
methods: {
registerWx() {
wxUtils.registerApp({
// 填写你的 appId
appId: "",
// iOS 必填,填写你的 universalLink
universalLink: ""
});
},
isWXAppInstalled() {
uni.showToast({
title: wxUtils.isInstalled() ? "已安装微信" : "未安装微信",
icon: "none"
});
},
openApp() {
wxUtils.openApp();
},
login() {
wxUtils.login({
state: "cms-weixinnopay-login",
success(code, state) {
console.log("login success", { code, state });
},
fail(errCode, errMsg) {
console.log("login fail", { errCode, errMsg });
}
});
},
sendText() {
wxUtils.sendText({
text: "你好微信",
scene: 0,
success() {
console.log("sendText success");
},
fail(errCode, errMsg) {
console.log("sendText fail", { errCode, errMsg });
}
});
},
sendLink() {
wxUtils.sendLink({
title: "UTS 微信网页",
desc: "分享描述",
thumbUrl: "https://env-00jxt1cobn8u-static.normal.cloudstatic.cn/kuaiqucan/108.png",
webpageUrl: "https://ext.dcloud.net.cn",
scene: 0,
success() {
console.log("sendLink success");
},
fail(errCode, errMsg) {
console.log("sendLink fail", { errCode, errMsg });
}
});
},
sendMiniProgram() {
wxUtils.sendMiniProgram({
title: "UTS 小程序",
desc: "分享小程序",
webpageUrl: "https://ext.dcloud.net.cn",
userName: "gh_xxxxx",
path: "pages/index/index",
miniprogramType: 0,
scene: 0,
success() {
console.log("sendMiniProgram success");
},
fail(errCode, errMsg) {
console.log("sendMiniProgram fail", { errCode, errMsg });
}
});
},
openMiniProgram() {
wxUtils.openMiniProgram({
userName: "gh_xxxxx",
path: "pages/index/index",
miniprogramType: 0,
success() {
console.log("openMiniProgram success");
},
fail(errCode, errMsg) {
console.log("openMiniProgram fail", { errCode, errMsg });
}
});
},
openWWService() {
wxUtils.openWWService({
corpId: "",
url: "",
success() {
console.log("openWWService success");
},
fail(errCode, errMsg) {
console.log("openWWService fail", { errCode, errMsg });
}
});
}
}
};
</script>
uni-app x 示例
所有方法需在 registerApp() 调用之后执行
<template>
<scroll-view class="page-scroll-view">
<button type="primary" @click="registerWx">注册微信</button>
<button type="primary" @click="isWXAppInstalled">是否安装微信</button>
<button type="primary" @click="openApp">打开微信</button>
<button type="primary" @click="login">登录</button>
<button type="primary" @click="sendText">分享文本</button>
<button type="primary" @click="sendLink">分享网页</button>
<button type="primary" @click="sendMiniProgram">分享小程序</button>
<button type="primary" @click="openMiniProgram">打开小程序</button>
<button type="primary" @click="openWWService">打开客服</button>
</scroll-view>
</template>
<script setup lang="uts">
import { onMounted } from 'vue'
import * as wxUtils from "@/uni_modules/cms-weixinnopay";
onMounted(() => {
wxUtils.registerApp({
// 填写你的 appId
appId: "",
// iOS 必填,填写你的 universalLink
universalLink: ""
} as wxUtils.RegisterAppOption)
})
const registerWx = () => {
wxUtils.registerApp({
appId: "",
universalLink: ""
} as wxUtils.RegisterAppOption)
}
const isWXAppInstalled = () => {
uni.showToast({
title: wxUtils.isInstalled() ? "已安装微信" : "未安装微信",
icon: "none"
})
}
const openApp = () => {
wxUtils.openApp()
}
const login = () => {
wxUtils.login({
state: "cms-weixinnopay-login",
success(code: string, state: string) {
console.log('login success', { code, state })
},
fail(errCode: number, errMsg: string) {
console.log('login fail', { errCode, errMsg })
}
} as wxUtils.LoginWxOption)
}
const sendText = () => {
wxUtils.sendText({
text: "你好微信",
scene: 0,
success() {
console.log('sendText success')
},
fail(errCode: number, errMsg: string) {
console.log('sendText fail', { errCode, errMsg })
}
} as wxUtils.SendWxMessageOption)
}
const sendLink = () => {
wxUtils.sendLink({
title: "UTS 微信网页",
desc: "分享描述",
thumbUrl: "https://env-00jxt1cobn8u-static.normal.cloudstatic.cn/kuaiqucan/108.png",
webpageUrl: "https://ext.dcloud.net.cn",
scene: 0,
success() {
console.log('sendLink success')
},
fail(errCode: number, errMsg: string) {
console.log('sendLink fail', { errCode, errMsg })
}
} as wxUtils.SendWxMessageOption)
}
const sendMiniProgram = () => {
wxUtils.sendMiniProgram({
title: "UTS 小程序",
desc: "分享小程序",
webpageUrl: "https://ext.dcloud.net.cn",
userName: "gh_xxxxx",
path: "pages/index/index",
miniprogramType: 0,
scene: 0,
success() {
console.log('sendMiniProgram success')
},
fail(errCode: number, errMsg: string) {
console.log('sendMiniProgram fail', { errCode, errMsg })
}
} as wxUtils.SendWxMessageOption)
}
const openMiniProgram = () => {
wxUtils.openMiniProgram({
userName: "gh_xxxxx",
path: "pages/index/index",
miniprogramType: 0,
success() {
console.log('openMiniProgram success')
},
fail(errCode: number, errMsg: string) {
console.log('openMiniProgram fail', { errCode, errMsg })
}
} as wxUtils.SendWxMessageOption)
}
const openWWService = () => {
wxUtils.openWWService({
corpId: "",
url: "",
success() {
console.log('openWWService success')
},
fail(errCode: number, errMsg: string) {
console.log('openWWService fail', { errCode, errMsg })
}
} as wxUtils.SendWxMessageOption)
}
</script>
<style>
.page-scroll-view {
height: 100%;
}
</style>
openMiniProgram / sendMiniProgram 注意事项
参考:https://developers.weixin.qq.com/doc/oplatform/Mobile_App/Launching_a_Mini_Program/Launching_a_Mini_Program.html
- 已认证开放平台账号:移动应用可跳转任意合法小程序
- 未认证开放平台账号:移动应用仅可跳转同一开放平台账号下小程序
需要帮助?有其他插件需求?
可通过插件页面联系方式联系作者。