Browse Source

添加防抖

306132416@qq.com 6 years ago
parent
commit
e757233e4f

+ 1 - 0
js_sdk/jiuai-debounce/jiuai-debounce.js

@@ -0,0 +1 @@
+export default{a:{},canDoFunction(e={}){if(!this.a[e.key]){this.lockKey(e.key);e.success&&e.success();if(e.time){setTimeout(()=>{this.releaseKey(e.key)},e.time)}}else{e.fail&&e.fail()}},releaseKey(key){delete this.a[key]},lockKey(key){this.a[key]=true}}

+ 2 - 1
main.js

@@ -1,6 +1,7 @@
 import Vue from 'vue'
 import App from './App'
-
+import jiuaiDebounce from '@/js_sdk/jiuai-debounce/jiuai-debounce.js'
+Vue.prototype.$jiuaiDebounce=jiuaiDebounce;
 Vue.config.productionTip = false
 
 App.mpType = 'app'

+ 1 - 1
pages/chat/chat.vue

@@ -40,7 +40,7 @@
       ASRManager.onError = (res) => {
         _this.isShow = false;
         uni.showToast({
-			title:'系统正在识别,请稍后再试',
+			title:'发生错误,请稍后再试',
         	icon:'none',
 			duration:2000
         })

+ 19 - 10
pages/index/index.vue

@@ -92,7 +92,7 @@
 						<view class="uni-share-content-text">个人中心</view>
 					</view>
 					<view class="uni-share-content-box" @click.stop="goSharePage">
-						<view class="uni-share-content-image"><image src="/static/icon/share-icon.png" class="image" /></view>
+						<view class="uni-share-content-image"><image src="/static/icon/share-icon1.png" class="image" /></view>
 						<view class="uni-share-content-text">去分享</view>
 					</view>
 					<!--  <view  class="uni-share-content-box" @click.stop='tabVoice' >
@@ -206,7 +206,7 @@ export default {
 		this.userHeadUrl = getApp().globalData.user_headUrl || '../../static/userDefault.png',
 		getApp().globalData.isAuth ? this.isAuth = true : this.isAuth = false ;
 		getApp().globalData.user_id ? this.getUserStorage(): this.title = 'RABOT' ;
-		getApp().globalData.isAuth ? this.getHistory() : this.isAuth = false ;
+		getApp().globalData.user_id ? this.getHistory() : this.title = 'RABOT' ;
 	},
 	methods: {
 		userLogin(){
@@ -359,11 +359,12 @@ export default {
 						});
 					}
 					else {
-						uni.showToast({
-							title:res.data.msg,
-							icon:'none',
-							duration:1500
-						})
+						// uni.showToast({
+						// 	title:res.data.msg,
+						// 	icon:'none',
+						// 	duration:1500
+						// })
+						return false
 						}
 					}
 			});
@@ -612,9 +613,17 @@ export default {
 			 });
 		 },
          // 语音识别
-        asrStart () {
-                this.$refs.weixinAsr.show();
-              },
+        asrStart () {
+			let that = this;
+			this.$jiuaiDebounce.canDoFunction({
+				key:"asrStart",//基于此值判断是否可以操作,如两个方法传入了同样的key,则会混淆,建议传入调用此事件的方法名,简单好梳理
+				time:3000,//如果传入time字段,则为定时器后,自动解除锁定状态,单位(毫秒)
+				success:()=>{//成功中调用应该操作的方法,被锁定状态不会执行此代码块内的方法
+				     that.$refs.weixinAsr.show();
+					 console.log(666)
+				 }
+			}) 
+          },
          asrResult (res) {
                 //this.arsRes = res;
 				res = res.substring(0,res.length-1)

+ 2 - 2
pages/selfInfo/selfInfo.vue

@@ -11,12 +11,12 @@
 		<view class="self-search-box">
 			<view class="search-content">
 				<view class="search-content-value">{{userTime || 0}}</view>
-				<view class="search-content-text">剩余查询(次)</view>
+				<view class="search-content-text">剩余查询次数</view>
 			</view>
 			<view class="line"></view>
 			<view class="search-content">
 				<view class="search-content-value">{{userTotalTime || 0}}</view>
-				<view class="search-content-text">累计查询(次)</view>
+				<view class="search-content-text">总查询次数</view>
 			</view>
 			<view class="share-detail" @click.stop="goShareDetail">
 				<text>明细></text>

BIN
static/icon/share-icon.png


BIN
static/icon/share-icon1.png