From 87294c97b4c071837b9cf1f0e3a31ff13bf3e40b Mon Sep 17 00:00:00 2001
From: MrShi <1878285526@qq.com>
Date: 星期五, 10 四月 2026 11:08:06 +0800
Subject: [PATCH] 页面

---
 app/pages/index/index.vue |  148 +++++++++++++++++++------------------------------
 1 files changed, 58 insertions(+), 90 deletions(-)

diff --git a/app/pages/index/index.vue b/app/pages/index/index.vue
index 123f636..75bb71a 100644
--- a/app/pages/index/index.vue
+++ b/app/pages/index/index.vue
@@ -1,111 +1,79 @@
 <template>
-	<view class="index">
-		<view class="index_list">
-			<view class="index_list_item">
-				<view class="index_list_item_info">
-					<text>SHE浜嬩欢涓婃姤</text>
-					<text>FAC/NM</text>
-				</view>
-				<image src="/static/bg_a.png" mode="widthFix"></image>
-			</view>
-			<view class="index_list_item">
-				<view class="index_list_item_info">
-					<text>璺岀粖婊戦闄╀笂鎶�</text>
-					<text>TAG</text>
-				</view>
-				<image src="/static/bg_b.png" mode="widthFix"></image>
-			</view>
-		</view>
+	<view style="padding: 40rpx;">
+		<button @click="speak('璁㈠崟宸叉敹鍒帮紝寮�濮嬫挱鎶�')">寮�濮嬫挱鎶�</button>
 	</view>
 </template>
 
 <script>
-	import { mapState } from 'vuex'
 	export default {
-		computed: {
-			...mapState(['userInfo'])
-		},
 		data() {
 			return {
-				title: 'Hello'
+				tts: null // 鍘熺敓TTS瀵硅薄
 			}
 		},
-		onLoad() {
 
+		onReady() {
+			this.initTTS() // 椤甸潰娓叉煋瀹屾垚鍒濆鍖栬闊�
 		},
+
 		methods: {
-			jump(type) {
-				switch (type) {
-					case 1:
-						uni.navigateTo({
-							url: '/pages/reporting_she/reporting_she'
-						})
-						break;
-					case 2:
-						uni.navigateTo({
-							url: '/pages/riskReporting/riskReporting'
-						})
-						break;
-					case 3:
-						uni.navigateTo({
-							url: '/pages/report_dca/report_dca'
-						})
-						break;
+			// ========== 鍒濆鍖栧畨鍗撳師鐢熻闊� ==========
+			initTTS() {
+				if (uni.getSystemInfoSync().platform !== 'android') {
+					console.log('浠呮敮鎸佸畨鍗�')
+					return
 				}
-			}
-		}
-	}
-</script>
 
-<style lang="scss" scoped>
-	.index {
-		width: 100vw;
-		padding: 30rpx;
-		box-sizing: border-box;
-		height: calc(100vh - 44px - 50px);
-		background: linear-gradient( 180deg, #B5D2FF 0%, #FFFFFF 100%);
-		.index_list {
-			width: 100%;
-			display: flex;
-			flex-direction: column;
-			margin-top: 12rpx;
-			.index_list_item {
-				width: 100%;
-				height: 200rpx;
-				margin-bottom: 30rpx;
-				position: relative;
-				.index_list_item_info {
-					width: 100%;
-					height: 100%;
-					padding: 0 48rpx;
-					box-sizing: border-box;
-					display: flex;
-					justify-content: center;
-					flex-direction: column;
-					position: relative;
-					z-index: 99;
-					text {
-						&:nth-child(1) {
-							font-weight: bold;
-							font-size: 34rpx;
-							color: #FFFFFF;
+				try {
+					// 瀵煎叆瀹夊崜鍘熺敓绫�
+					const TextToSpeech = plus.android.importClass('android.speech.tts.TextToSpeech')
+					const Locale = plus.android.importClass('java.util.Locale')
+
+					// 鍒涘缓TTS
+					this.tts = new TextToSpeech(plus.android.runtimeMainActivity(), {
+						onInit: (status) => {
+							if (status == 0) {
+								// 璁剧疆涓枃
+								this.tts.setLanguage(Locale.CHINA)
+								console.log('璇煶鍒濆鍖栨垚鍔�')
+							}
 						}
-						&:nth-child(2) {
-							font-weight: 400;
-							font-size: 26rpx;
-							color: rgba(255,255,255,0.6);
-							margin-top: 10rpx;
-						}
-					}
+					})
+				} catch (e) {
+					console.log('鍒濆鍖栧け璐�', e)
 				}
-				image {
-					width: 100%;
-					height: 100%;
-					position: absolute;
-					top: 0;
-					left: 0;
+			},
+
+			// ========== 璇煶鎾姤锛堟牳蹇冩柟娉曪級 ==========
+			speak(text) {
+				if (!this.tts) {
+					uni.showToast({
+						title: '璇煶鏈噯澶囧ソ',
+						icon: 'none'
+					})
+					return
 				}
+
+				try {
+					// 瀹夊崜鍘熺敓鎾姤锛圦UEUE_FLUSH = 绔嬪嵆鎾姤锛屾墦鏂笂涓�鏉★級
+					this.tts.speak(text, 0, null)
+				} catch (err) {
+					console.log('鎾姤澶辫触', err)
+				}
+			},
+
+			// 鍋滄鎾姤
+			stopSpeak() {
+				if (this.tts) this.tts.stop()
+			}
+		},
+
+		// 椤甸潰閿�姣佹椂鍏抽棴璇煶
+		onUnload() {
+			if (this.tts) {
+				this.tts.stop()
+				this.tts.shutdown()
 			}
 		}
 	}
-</style>
+</script>
\ No newline at end of file

--
Gitblit v1.9.3