当前位置: 首页 > article >正文

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

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

官方文档:

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

	/*
	* 在调用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 {
          // 错误处理
        }
      })

http://www.kler.cn/a/455959.html

相关文章:

  • C# OpenCV机器视觉:产品计数
  • springboot493基于java的美食信息推荐系统的设计与实现(论文+源码)_kaic
  • vuex - 第一天
  • MongoDB 常用操作指南(Docker 环境下)
  • empire靶机
  • [Wireshark] 使用Wireshark抓包https数据包并显示为明文、配置SSLKEYLOGFILE变量(附下载链接)
  • Android --- 在AIDL进程间通信中,为什么使用RemoteCallbackList 代替 ArrayList?
  • 自动化测试模型(一)
  • Word表格另起一页解决办法
  • FIR数字滤波器设计——窗函数设计法——滤波器的时域截断
  • DBeaver——设置字体大小以及SQL快捷键
  • 开源诊断工具Arthas
  • yarn list --pattern vuex-module-decorators
  • 【Rust自学】8.1. Vector
  • LeetCode75. 颜色分类(2024冬季每日一题 40)
  • PhPMyadmin-cms漏洞复现
  • xdoj最长的整数序列
  • node.js和js
  • MYSQL无法被连接问题
  • diffusion model evolution