企信唤起跳转小程序及分享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 {
          // 错误处理
        }
      })
相关推荐
Li_Ning211 小时前
【vue3】实现pdf在线预览的几种方式
前端·pdf
水瓶丫头站住1 小时前
Qt的QTableWidget样式设置
前端·qt
2401_897605651 小时前
AI前端开发技能提升与ScriptEcho:拥抱AI时代的前端开发新范式
前端·人工智能
老K(郭云开)5 小时前
最新版Edge浏览器集成ActiveX控件之金山WpsDocFrame控件
前端·javascript·chrome·3d·中间件
Anyexyz5 小时前
Windows 11 卸载 Edge
前端·windows·edge
一路向前的月光7 小时前
React(6)
前端·javascript·react.js
众智创新团队7 小时前
singleTaskAndroid的Activity启动模式知识点总结
前端
青柠t8 小时前
微信小程序 - 模版语法
微信小程序·小程序
祁许8 小时前
【Vue】打包vue3+vite项目发布到github page的完整过程
前端·javascript·vue.js·github
我的86呢!8 小时前
uniapp开发h5部署到服务器
前端·javascript·vue.js·uni-app