收藏
回答

小程序直播组件中获取用户openid,扫码进入直播间,在app.vue中无法获取二维码参数?

用户使用微信扫码直接进入了直播间,App.vue 中 onshow方法 未被调用

测试场景:小程序首页写了个扫码按钮,二维码是在直播间生成的海报,在App.vue中onshow方法里调用了下图方法

扫码后直接跳转到了直播间,控制台未打印任何信息

使用的uniapp,不知道是不是语法不同问题?

let livePlayer  = requirePlugin("live-player-plugin");
onShow: function(options) {
	const sceneList = [1007, 1008, 1014, 1044, 1045, 1046, 1047, 1048, 1049, 1073, 1154, 1155]
  	    if (sceneList.includes(options.scene)) {
  	        livePlayer.getShareParams()
  		.then(res => {
  	            console.log('get room id', res.room_id) 
		    alert(res.room_id)
		    livePlayer.getOpenid({ room_id: res.room_id })
	            .then(r => {
			console.log(r.openid)
			alert(r.openid)
		    }).cache(e=> {
			console.log('get openid',e)
		    })
		}).catch(err => {
		   console.log('get share params', err)
		})
	    }
		
	}

最后一次编辑于  2021-07-01
回答关注问题邀请回答
收藏
登录 后发表内容