<template>
    <view class="search-voice-content">
		<speech  key="speech-test" ref="speechTest" @success="speechSuccess"></speech>
		<view class="desc-model">
			<textarea class="desc" v-model="desc" placeholder="请详细描述您的病情(5-200字内）" maxlength="200" />
			<button type="primary" class="submit-BT" @click="submit()">提交</button>				
		</view>
		<button type="default"  @click="speechHandle" class="speechHandle submit-BT">
			<text class="zhcx-iconfont zhcx-icon-yuyin"></text>
		</button>
    </view>
</template>
<script>
	import {notEmpty} from '@/libs';
	import speech from '@/components/Speech';
	import {searchSubmit} from '@/api/patient';
	export default {
		components:{
			speech
		},
		data() {
			return {
				speechModel:false,
				desc:""
			}
		},
		methods: {
			speechHandle(){
				// #ifdef H5
					uni.showToast({
						icon:"none",
						title:"请使用小程序打开！"
					})
					return;
				// #endif
				this.$refs.speechTest.startRecordHanlle()
			},
			speechSuccess(res){
				let word=res.data.result[0];
				this.desc=word;
			},
			submit(){
				searchSubmit({
					diseaseDesc:this.desc,
					seekTime:parseTime(new Date())
				}).then((res)=>{
					if(res.code===0){
						/**检索成功返回ai推荐数据 */
						uni.setStorageSync('aidiagnoseInfo',res.data)
						uni.navigateTo({
							url: '/views/patientItems/diagnose/index'
						});
					}
				})				
			}
		}
	}
</script>

<style lang="scss" scoped>
	.search-voice-content{
		.submit-BT{
			display: block;
			width: 702upx;
			height: 98upx;
			line-height: 98upx;
			text-align: center;
			color: #fff;
			font-size: 32upx;
			letter-spacing: 4upx;
			margin-top: 40upx;
			background-color: #3384FF;
		}	
		.speechHandle{
			width:100upx;
			height:100upx;
			position: fixed;
			bottom: 0;
			left: 50%;
			transform: translateX(-50%);
			z-index: 5;
			display: flex;
			justify-content: center;
			align-items: center;
			flex-direction: column;
			line-height: 1;
			margin: 0;
			letter-spacing: 2upx;
			font-size: 20upx;
			color: #fff;
			background-color: #409eff;
			border-color: #409eff;
			border-radius: 50upx 50upx 0 0;
			.zhcx-icon-yuyin{
				font-size: 100upx;
			}
		}			
	}
</style>
