企信唤起跳转小程序及分享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 {
          // 错误处理
        }
      })
相关推荐
yuanyxh11 小时前
Mac 软件推荐
前端·javascript·程序员
万少11 小时前
AtomCode开发微信小程序《谁去呀》 全流程
前端·javascript·后端
某人辛木11 小时前
Web自动化测试
前端·python·pycharm·pytest
Kagol12 小时前
Superpowers GSD gstack AgentSkills深度测评
前端·人工智能
excel13 小时前
JavaScript 字符串与模板字面量:从表象到本质理解
前端
京东云开发者13 小时前
当AI成为导演-如何用AI创作动漫短剧
前端
李白的天不白14 小时前
使用 SmartAdmin 进行前后端开发
java·前端
乘风gg14 小时前
🤡PUA AI Coding 工具 的 10 条终极语录
前端·ai编程·claude
学Linux的语莫14 小时前
Vue 3 入门教程
前端·javascript·vue.js
怕浪猫14 小时前
第一章、Chrome DevTools Protocol (CDP) 详解
前端·javascript·chrome