代码
const scene = wx.getLaunchOptionsSync();
//3微信群聊 4企业微信群聊
if ([3, 4].indexOf(scene.chatType) < 0) {
//群聊中打开
}
//群待办1160 群聊卡片1008
if ([1008, 160].indexOf(scene.scene) >= 0) {
//群代办或者群卡片中打开,会携带群id
}
//话题页面打开1179 群公告1185
else if ([1179, 1185].indexOf(scene.scene) >= 0) {
//群公告或者话题页面打开
} else {
//其他情况下打开
}
参考
https://developers.weixin.qq.com/miniprogram/dev/api/base/app/life-cycle/wx.getLaunchOptionsSync.html
https://developers.weixin.qq.com/miniprogram/dev/reference/scene-list.html
https://developers.weixin.qq.com/miniprogram/dev/api/open-api/group/wx.getGroupEnterInfo.html