企信唤起跳转小程序及分享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 {
          // 错误处理
        }
      })
相关推荐
GISer_Jing1 小时前
AI营销增长:4大核心能力+前端落地指南
前端·javascript·人工智能
明远湖之鱼1 小时前
一种基于 Service Worker 的渐进式渲染方案的基本原理
前端
前端小端长2 小时前
Vue 中 keep-alive 组件的原理与实践详解
前端·vue.js·spring
FeelTouch Labs2 小时前
Nginx核心架构设计
运维·前端·nginx
雪球工程师团队3 小时前
别再“苦力”写后台,Spec Coding “跑” 起来
前端·ai编程
m0_471199633 小时前
【场景】前端怎么解决离线收银、数据同步异常等场景问题
前端·javascript
Curvatureflight3 小时前
前端性能优化实战:从3秒到300ms的加载速度提升
前端·人工智能·性能优化
用户99045017780093 小时前
ruoyi集成dmn规则引擎
前端
袋鱼不重3 小时前
AI入门知识点:什么是 AIGC、多模态、RAG、Function Call、Agent、MCP?
前端·aigc·ai编程