<template>
<view style="height: 100vh">
<chat bind:queryCallback="getQueryCallback" bind:openWebview="openWebview"
bind:openMiniProgram="openMiniProgram" />
</view>
</template>
<script setup>
import {
reactive,
getCurrentInstance,
ref
} from 'vue'
import {
onReady,
onLoad,
onUnload,
onHide
} from "@dcloudio/uni-app"
let userInfo = ref({})
let plugin = requirePlugin("chatbot");
onLoad((option) => {
userInfo.value = uni.getStorageSync('userInfo');
let userName = ''
if (userInfo.value?.image) {
userName = userInfo.value?.name
}
let userImage = ''
if (userInfo.value?.image_logo) {
userImage = userInfo.value?.image_logo
}
console.log('userInfo.value.openid')
console.log(userInfo.value.openid)
plugin.init({
appid: "我的APPID", //微信对话开放平台小程序插件appid
openid: userInfo.value.openid, // 小程序用户的openid,必填项
userHeader: userImage, // 用户头像,不传会弹出登录框
userName: userName, // 用户昵称,不传会弹出登录框
anonymous: false, // 是否允许匿名用户登录,版本1.2.9后生效, 默认为false,设为true时,未传递userName、userHeader两个字段时将弹出登录框
success: (res) => {
console.log('res')
console.log(res)
}, //非必填
fail: (error) => {
console.log('error')
console.log(error)
}, //非必填
});
})
</script>
<style>
</style>
引入方法用小程序分包引入
您好,请提供下完整的代码片段 谢谢。