<template>
    <view>
		<tn-nav-bar fixed  customBack>
			<view slot="back" class='tn-custom-nav-bar__back' @click="goBack">
				<text class='icon tn-icon-left'></text>
		
			</view>
			<view slot="default" style="display: flex;">
				<view style="flex:1;">
					<text :style="{fontSize:(wxFontSize)+'px'}">速立保AI</text>
				</view>
			</view>
		</tn-nav-bar>
        <!-- index.wxml -->
		 <!-- <navigationBar></navigationBar> -->
		 <!-- <button open-type="contact" bindcontact="handleContact" session-from="sessionFrom">111</button> -->
		 <agent-ui :agentConfig="agentConfig"  showBotAvatar="true" chatMode="bot"></agent-ui>

        
    </view>
</template>

<script>
import agentUi from '@/components/agent-ui/index';
// index.js
export default {
    components: {
        agentUi
    },
    data() {
        return {
            agentConfig: {
                type: 'bot',
                // 值为'bot'或'model'。当type='bot'时，botId必填；当type='model'时，modelName和model必填
                botId: 'bot-df4c8ed6',
                // agent id
                showBotAvatar:true,// 是否在对话框左侧显示头像
				allowWebSearch: true,
				// 允许客户端选择启用联网搜索
				allowUploadFile: true,
				// 允许上传文件
				allowPullRefresh: true // 允许下拉刷新
                // 具体的模型版本
                // logo: 'https://cloud1-6g83nk504b196aa9-1328241815.tcloudbaseapp.com/resources/2025-03/lowcode-2171303',
                // 图标(只在model模式下生效)
                // welcomeMessage: '' // 欢迎语(只在model模式下生效)
            }
        };
    },
    methods: {
		goBack() {
			const pages = getCurrentPages()
			// 有可返回的页面则直接返回，uni.navigateBack 默认返回失败之后会自动刷新页面 ，无法继续返回
			if (pages.length > 1) {
				uni.navigateBack()
				return;
			}else{
				uni.reLaunch({
					url: '/pages/index/index'
				})
			}
		},
	}
};
</script>
<style lang="scss" scoped>
	/* 胶囊*/
	.tn-custom-nav-bar__back {
		width: 60%;
		height: 100%;
		position: relative;
		display: flex;
		justify-content: space-evenly;
		align-items: center;
		box-sizing: border-box;
		 
		border-radius: 1000rpx;
		border: 1rpx solid rgba(255, 255, 255, 0.5);
		 
		font-size: 18px;
	
		.icon {
			display: block;
			flex: 1;
			margin: auto;
			text-align: center;
		}
	
		&:before {
			content: " ";
			width: 1rpx;
			height: 110%;
			position: absolute;
			top: 22.5%;
			left: 0;
			right: 0;
			margin: auto;
			transform: scale(0.5);
			transform-origin: 0 0;
			pointer-events: none;
			box-sizing: border-box;
			opacity: 0.7;
			background-color: #FFFFFF;
		}
	}
	
</style>
