更新记录
1.0.0(2026-02-12)
1.0.0
平台兼容性
<script setup>
import { onMounted } from "vue";
import * as UTSQyShare from "@/uni_modules/hzy-qy";
import * as UTSDingTalkShare from "@/uni_modules/hzy-dd";
// 替换为你在企业微信管理后台获取的值
const SCHEMA = "";
const APP_ID = "";
const AGENT_ID = "";
const DING_TALK_APP_ID = "";
onMounted(() => {
// 企业微信注册
UTSQyShare.registerApp({ schema: SCHEMA });
// 钉钉注册
UTSDingTalkShare.registerApp({ appId: DING_TALK_APP_ID });
});
// 分享文字 正常
const shareToWeCom = () => {
// 示例:分享文字到企业微信
UTSQyShare.shareText({
appId: APP_ID,
agentId: AGENT_ID,
text: "来自 App 的分享内容",
success: () => {
uni.showToast({ title: "已调起企业微信", icon: "success" });
},
fail: (err) => {
uni.showToast({ title: err?.errMsg || "分享失败", icon: "none" });
},
});
};
// 分享图片 正常
const shareImgToWeCom = () => {
// 示例:分享图片到企业微信
UTSQyShare.shareImage({
appId: APP_ID,
agentId: AGENT_ID,
filePath: "https://resource.boyups.cn/boyu_app/bksw.jpeg",
fileName: "image",
success: () => {
uni.showToast({ title: "已调起企业微信", icon: "success" });
},
fail: (err) => {
uni.showToast({ title: err?.errMsg || "分享失败", icon: "none" });
},
});
};
// 分享文件 正常
const shareFileToWeCom = () => {
// 示例:分享文件到企业微信
UTSQyShare.shareFile({
appId: APP_ID,
agentId: AGENT_ID,
filePath: "https://resource.boyups.cn/boyu_app/hNX10yBwJJ.txt",
});
};
// 分享视频 正常
const shareVideoToWeCom = () => {
// 示例:分享视频到企业微信
UTSQyShare.shareVideo({
appId: APP_ID,
agentId: AGENT_ID,
filePath: "https://resource.boyups.cn/boyu_app/video.mp4",
});
};
// 分享链接 正常
const shareLinkToWeCom = () => {
// 示例:分享网页链接到企业微信
UTSQyShare.shareLink({
appId: APP_ID,
agentId: AGENT_ID,
thumbUrl:
"https://www.baidu.com/img/PCtm_d9c8750bed0b3c7d089fa7d55720d6cf.png", // 缩略图图片
webpageUrl: "https://work.weixin.qq.com/", // 链接指向的网页
title: "标题",
description: "网页描述",
success: () => {
uni.showToast({ title: "已调起企业微信", icon: "success" });
},
fail: (err) => {
uni.showToast({ title: err?.errMsg || "分享失败", icon: "none" });
},
});
};
// 分享小程序 正常
const shareMiniProgramToWeCom = () => {
// 示例:分享小程序到企业微信(需替换为你关联的小程序 username)
UTSQyShare.shareMiniProgram({
appId: APP_ID,
agentId: AGENT_ID,
schema: SCHEMA,
username: "gh_xxxxxxxxxxx@app",
path: "/pages/index/index",
title: "企业微信小程序分享",
description: "来自 App 的小程序分享",
hdImagePath: "https://resource.boyups.cn/boyu_app/bksw.jpeg",
success: () => {
uni.showToast({ title: "已调起企业微信", icon: "success" });
},
fail: (err) => {
uni.showToast({ title: err?.errMsg || "分享失败", icon: "none" });
},
});
};
// 钉钉分享文本 正常
const shareTextToDingTalk = () => {
UTSDingTalkShare.shareText({
text: "来自 App 的分享内容",
success: () => {
uni.showToast({ title: "已调起钉钉", icon: "success" });
},
fail: (err) => {
uni.showToast({ title: err?.errMsg || "分享失败", icon: "none" });
},
});
};
// 钉钉分享图片 正常
const shareImgToDingTalk = () => {
UTSDingTalkShare.shareImage({
picUrl: "https://resource.boyups.cn/boyu_app/bksw.jpeg",
picPath: "https://resource.boyups.cn/boyu_app/bksw.jpeg",
success: () => {
uni.showToast({ title: "已调起钉钉", icon: "success" });
},
fail: (err) => {
uni.showToast({ title: err?.errMsg || "分享失败", icon: "none" });
},
});
};
// 钉钉分享链接 正常
const shareLinkToDingTalk = () => {
UTSDingTalkShare.shareLink({
url: "https://work.weixin.qq.com/",
title: "标题",
description: "网页描述",
thumbUrl: "https://resource.boyups.cn/boyu_app/bksw.jpeg", // 缩略图图片
success: () => {
uni.showToast({ title: "已调起钉钉", icon: "success" });
},
fail: (err) => {
uni.showToast({ title: err?.errMsg || "分享失败", icon: "none" });
},
});
};
</script>
<template>
<view class="content">
<button type="primary" class="button_item" @click="shareToWeCom">
企业微信分享(文字)
</button>
<button type="primary" class="button_item" @click="shareImgToWeCom">
企业微信分享(图片)
</button>
<button type="primary" class="button_item" @click="shareFileToWeCom">
企业微信分享(文件)
</button>
<button type="primary" class="button_item" @click="shareVideoToWeCom">
企业微信分享(视频)
</button>
<button type="primary" class="button_item" @click="shareLinkToWeCom">
企业微信分享(链接)
</button>
<button type="primary" class="button_item" @click="shareMiniProgramToWeCom">
企业微信分享(小程序)
</button>
<button type="primary" class="button_item" @click="shareTextToDingTalk">
钉钉分享(文本)
</button>
<button type="primary" class="button_item" @click="shareImgToDingTalk">
钉钉分享(图片)
</button>
<button type="primary" class="button_item" @click="shareLinkToDingTalk">
钉钉分享(链接)
</button>
</view>
</template>
<style lang="scss" scoped>
.content {
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
padding: 0 32rpx;
.button_item {
width: 100%;
margin: 32rpx 0;
}
}
</style>

收藏人数:
购买普通授权版(
试用
赞赏(0)
下载 0
赞赏 0
下载 11222103
赞赏 1859
赞赏
京公网安备:11010802035340号