企信唤起跳转小程序及分享API功能

initWxConfig()函数的调用情况 ,请移步上一篇文章......🛫

官方文档:

跳转到小程序页面:https://developer.work.weixin.qq.com/document/path/96897
分享接口:https://developer.work.weixin.qq.com/document/path/97582

javascript 复制代码
	/*
	* 在调用wx.agentConfig之前,必须确保先成功调用wx.config
	* 如需调用agentConfig,只需传入字符串:initWxAgentConfig
	*/
    await initWxConfig('initWxAgentConfig')
    // 要批量掩藏的菜单项
    await this.$wx?.hideMenuItems({
      menuList: ["menuItem:copyUrl","menuItem:share:wechat","menuItem:favorite","menuItem:share:email","menuItem:openWithSafari"] 
      });
      
      
      
	/* 
	* 自定义分享卡片的内容  
	* 官方文档:https://developer.work.weixin.qq.com/document/path/91120
	* shareLink: 构造网页授权链接,企信重定向链接
	* appid: 第三方应用id(即ww或wx开头的suite_id),注意与企业的网页授权登录不同。区分测试、生产环境
	* redirect_uri:授权后重定向的回调链接地址,注意域名需要设置为第三方应用的可信域名,请使用【urlencode】对链接进行处理
	*/
    const shareLink = `https://open.weixin.qq.com/connect/oauth2/authorize?appid=${appid}&redirect_uri=${URL}&response_type=code&scope=snsapi_base&state=#wechat_redirect` 
	this.$wx.onMenuShareAppMessage({
	 title: `${wxShare_title }`, // 分享标题
	 desc: `${wxShare_desc }`, // 分享描述
	 link: shareLink, // 分享链接;在微信上分享时,该链接的域名必须与企业某个应用的可信域名一致
	 imgUrl: `${wxShare_img}`, // 分享图标
	 success: function () {
	   // 用户确认分享后执行的回调函数
	   console.log(`成功分享到企业微信的其他会话`)
	 },
	 cancel: function () {
	   // 用户取消分享后执行的回调函数
	   console.log(`取消分享到企业微信的其他会话`)
	 }
	})



	/*
	* 此接口仅在企业微信3.0.36及以后版本支持,微信端不支持(微信开发者工具也不支持)。
	* 必须先成功调用agentConfig,否则调用时会报"no permission"错误。
	* agentConfig中所填 agentid 对应应用,必须与要跳转的小程序应用同属于一个企业,否则会报错 "not allow to cross corp"。
	* 跳转的小程序必须已经关联到工作台,否则会报错 "not allow to cross corp"。
	*/
      this.$wx.invoke('launchMiniprogram', {
        "appid": "wx......", // 需跳转的小程序appid
        "path": "pages/webview/index", // 所需跳转的小程序内页面路径及参数。非必填
      	}, function (res) {
        console.log('invoke', res)
        if (res.err_msg == "launchMiniprogram:ok") {
          // 正常
        } else {
          // 错误处理
        }
      })
相关推荐
夏幻灵9 分钟前
HTML5里最常用的十大标签
前端·html·html5
Mr Xu_23 分钟前
Vue 3 中 watch 的使用详解:监听响应式数据变化的利器
前端·javascript·vue.js
未来龙皇小蓝26 分钟前
RBAC前端架构-01:项目初始化
前端·架构
程序员agions35 分钟前
2026年,微前端终于“死“了
前端·状态模式
万岳科技系统开发35 分钟前
食堂采购系统源码库存扣减算法与并发控制实现详解
java·前端·数据库·算法
2501_9151063236 分钟前
app 上架过程,安装包准备、证书与描述文件管理、安装测试、上传
android·ios·小程序·https·uni-app·iphone·webview
程序员猫哥_42 分钟前
HTML 生成网页工具推荐:从手写代码到 AI 自动生成网页的进化路径
前端·人工智能·html
龙飞0543 分钟前
Systemd -systemctl - journalctl 速查表:服务管理 + 日志排障
linux·运维·前端·chrome·systemctl·journalctl
2501_915106321 小时前
使用 Sniffmaster TCP 抓包和 Wireshark 网络分析
网络协议·tcp/ip·ios·小程序·uni-app·wireshark·iphone
我爱加班、、1 小时前
Websocket能携带token过去后端吗
前端·后端·websocket