From 60bdd6e881fbefc8c375eb9e9d71009d6c63859d Mon Sep 17 00:00:00 2001
From: hejianhao <15708179461@qq.com>
Date: 星期日, 18 五月 2025 16:35:16 +0800
Subject: [PATCH] H5工单列表、工单详情、诉求监督

---
 H5/store/index.js |   61 +++++++++++++++++++++++++++++-
 1 files changed, 59 insertions(+), 2 deletions(-)

diff --git a/H5/store/index.js b/H5/store/index.js
index c111b4a..b3c0662 100644
--- a/H5/store/index.js
+++ b/H5/store/index.js
@@ -5,13 +5,70 @@
 const store = new Vuex.Store({
 	state: {
 		isList: false,
+		innerAudioContext: null,
+		playFlag: false //是否在播放
 	},
 	mutations: {
 		SET_ISLIST(state, data) {
 			state.isList = data
-		}
+		},
 	},
-	actions: {}
+	actions: {
+		// 开始播放
+		playRecording({
+			state,
+			dispatch
+		}, url) {
+			if (state.innerAudioContext) {
+				state.innerAudioContext.play()
+				return
+			}
+			state.innerAudioContext = uni.createInnerAudioContext();
+			state.innerAudioContext.autoplay = true;
+			// state.innerAudioContext.src =
+			// 	'https://haitunyingyu.obs.cn-southwest-2.myhuaweicloud.com/admin/6660c5497ff34ee5b2bddaed01dd3880.wav';	
+			state.innerAudioContext.src = url
+			state.innerAudioContext.onPlay(() => {
+				state.playFlag = true;
+			});
+			state.innerAudioContext.onError((res) => {
+				// console.log('播放错误', res);
+				dispatch('stopPlaying')
+			});
+			state.innerAudioContext.onEnded((res) => {
+				// console.log('播放自然结束', res);
+				dispatch('stopPlaying')
+			});
+		},
+		// 暂停播放
+		pausePlaying({
+			state
+		}) {
+			if (state.innerAudioContext) {
+				try {
+					state.innerAudioContext.pause();
+					state.playFlag = false;
+				} catch (e) {
+					//TODO handle the exception
+				}
+			}
+		},
+		// 停止播放
+		stopPlaying({
+			state
+		}) {
+			if (state.innerAudioContext) {
+				try {
+					state.innerAudioContext.stop();
+					state.innerAudioContext.destroy()
+					state.innerAudioContext = null
+					state.playFlag = false;
+				} catch (e) {
+					//TODO handle the exception
+				}
+			}
+		}
+	}
 })
 
 export default store
\ No newline at end of file

--
Gitblit v1.7.1