Browse Source

修改语音同译的方式

306132416@qq.com 5 years ago
parent
commit
0ab53661bd
1 changed files with 22 additions and 15 deletions
  1. 22 15
      pages/index/index.vue

+ 22 - 15
pages/index/index.vue

@@ -89,7 +89,7 @@
 		    </view>
 		    <view class="tip">说出股票代码</view>
 			  <!-- <view>{{resultText}}</view> -->
-		   <!-- <button class="btn" type="default" @click="recordStop">说完了</button> -->
+		   <button class="btn" type="default" @click="recordStop">说完了</button>
 		  </view>
 		</view>
 		<uni-popup ref="popup" type="bottom">
@@ -208,11 +208,11 @@ export default {
 	  // 识别错误事件  
 	  ASRManager.onError = (res) => {
 	    _this.isShowVoice = false;
-	    uni.showToast({
-			title:'请再试一次',
-	    	icon:'none',
-			duration:2000
-	    })
+	  //   uni.showToast({
+			// title:'请再试一次',
+	  //   	icon:'none',
+			// duration:2000
+	  //   })
 	  }
 	  
 	  // 录音停止回调
@@ -622,9 +622,9 @@ export default {
 		cancelModal(){
 			          // 需要在 popup 组件,指定 ref 为 popup
 			     this.$refs.popup.close();
-		  },
+		},
 		//情况聊天记录
-		 cleanChatRecord(){
+		cleanChatRecord(){
 			 if(getApp().globalData.user_id=='') return false;
 			 let that = this;
 			 uni.request({
@@ -661,7 +661,7 @@ export default {
 			 });
 		 },
          // 语音识别
-		 show() {
+		show() {
 		    const _this = this;
 		    // 获取是否授权信息
 		    uni.getSetting({
@@ -670,11 +670,19 @@ export default {
 		          if (res.authSetting['scope.record']) {
 		            start();
 		          } else { // 拒绝授权,打开授权设置
-		            uni.openSetting({
-		              success() {
-		                start();
-		              }
-		            })
+					  uni.showModal({
+						title: '麦克风授权',
+						content: '点击确定重新获取授权。',
+						success: function(res) {
+							if (res.confirm) {
+								uni.openSetting({
+									success: res => {
+										console.log('授权成功');
+									}
+								});
+							}
+						}
+					  });
 		          }
 		        } else {
 		          start();
@@ -707,7 +715,6 @@ export default {
 			// }) 
    //        },
 		 longPressStart(){
-			 this.isShowVoice = true;
 			 this.show();
 		 },
 		 touchMoveEnd(){