企业微信小程序 分享参数
-
wx.qy.sendChatMessage
分享前提条件: 必须是从企业微信聊天框侧边栏打开
优点: 只需要一步就可以直接分享,单对单分享
注意: 小程序消息打开后的路径,注意要以.html
作为后缀代码示例:
wx.qy.getContext({ success: (res) => { var entry = res.entry // 返回进入小程序的入口类型 if (entry === 'single_chat_tools') { wx.qy.sendChatMessage({ msgtype: 'miniprogram', // 消息类型,必填 enterChat: true, miniprogram: { appid: title: , // 小程序消息的title imgUrl: '', // 小程序消息的封面图。 page: url // 小程序消息打开后的路径,注意要`以.html`作为后缀,否则在微信端打开会提示找不到页面 }, success: (res) => { } } } })
-
<button open-type="share" />
按钮分享
优点:需要两步才可以完成分享,单对多分享
缺点:分享成功没有回调
注意:小程序消息打开后的路径,路径不能带.html
代码示例:onShareAppMessage (e) { return { title: '', path: '', imageUrl: '' } },
微信小程序onShow , 页面onShow 获取option
-
app.js
中 onShow , 可以直接获取到optiononShow (option) { console.log('路由', option.path) console.log('路由参数', option.query) }
-
页面
中onShow, 通过函数获取onShow() { const pages = getCurrentPages() // 获取加载的页面 const currentPage = pages[pages.length - 1] // 获取当前页面的对象 const url = currentPage.route // 当前页面url const options = currentPage.options // 如果要获取url中所带的参数可以查看options }
android 与ios 点击微信小程序右上角圆点(关闭按钮)有什么区别
android 点击右上角圆点,不会关闭小程序,相当于热启动, ios 点击右上角圆点,会直接关闭小程序,相当于冷启动
企业微信聊天窗口侧边栏打开小程序(android 与 ios 区别)
参考上边知道
android 与ios 点击微信小程序右上角圆点(关闭按钮)有什么区别,如果需要把小程序配置再侧边栏,
获取参数,初始化调用将会有不同
获取参数: 从app.js 的 onShow
中获取参数,保存全局,页面直接从全局获取
初始化页面: 变动函数 需要在onShow 中调用