Selaa lähdekoodia

声音播放形式修改

shish 4 vuotta sitten
vanhempi
commit
fbb142fb6d

+ 4 - 4
hdPad/src/components/vKeyboard/VKeyboard.vue

@@ -102,7 +102,7 @@ export default {
 		},
 		//键盘键入
 		typing(input) {
-			this.$util.hitRemind()
+			this.$innerAudioContext.play()
 			this.keys.push(input);
 			//app中v-model不生效,改用事件方式在外处理
 			//this.$emit('typing', this.keys.join(''))
@@ -113,7 +113,7 @@ export default {
 		},
 		//退格键
 		backspace() {
-			this.$util.hitRemind()
+			this.$innerAudioContext.play()
 			if (this.keys.length) {
 				this.keys.pop()
 			}
@@ -124,12 +124,12 @@ export default {
 		},
 		//键入回车
 		enter() {
-			this.$util.hitRemind()
+			this.$innerAudioContext.play()
 			//this.deactivate();
 			this.$emit('enter');
 		},
 		cancel(){
-			this.$util.hitRemind()
+			this.$innerAudioContext.play()
 			this.$emit('cancel')
 		},
 		//激活键盘

+ 14 - 0
hdPad/src/main.js

@@ -14,6 +14,20 @@ Vue.mixin(globalMixins);
 import store from "./store";
 Vue.prototype.$store = store;
 
+
+var innerAudioContext = uni.createInnerAudioContext();  
+innerAudioContext.autoplay = false;  
+innerAudioContext.src = constants.imgUrl+'/hit.mp3';  
+innerAudioContext.onPlay(() => {  
+	console.log('开始播放');  
+});  
+innerAudioContext.onError((res) => {  
+	console.log(res.errMsg);  
+	console.log(res.errCode);  
+})
+Vue.prototype.$innerAudioContext = innerAudioContext;
+
+
 // 阻止启动生产消息,常用作指令
 Vue.config.productionTip = false;
 

+ 1 - 1
hdPad/src/mixins/product.js

@@ -271,7 +271,7 @@ export default {
 				}
 				unitName = current.bigUnit
 				unitPrice = current.bigPrice
-				this.$util.hitRemind()
+				this.$innerAudioContext.play()
 				let num = this.calc == 'add' ? 1 : -1
 				let params = {...current,unitName:unitName,unitPrice:unitPrice,currentNum:num}
 				this.replaceItemFn(params,1)

+ 15 - 15
hdPad/src/pages/home/components/console.vue

@@ -121,11 +121,11 @@ export default {
 			})
 		},
 		gatheringFn(){
-			this.$util.hitRemind()
+			this.$innerAudioContext.play()
 			this.$refs.gatheringRef.open('center')
 		},
 		payFinish(){
-			this.$util.hitRemind()
+			this.$innerAudioContext.play()
 			this.$refs.toPayRef.close()
 			this.getNewItemAndListenScan()
 		},
@@ -137,7 +137,7 @@ export default {
 			this.$emit('changeProperty',this.property)
 		},
 		resetCustomer(){
-			this.$util.hitRemind()
+			this.$innerAudioContext.play()
 			this.$emit('resetCustomer')
 		},
 		settleCommit(params){
@@ -161,24 +161,24 @@ export default {
 			})
 		},
 		cancelPay(){
-			this.$util.hitRemind()
+			this.$innerAudioContext.play()
 			this.$refs.toPayRef.close()
 			this.getNewItemAndListenScan()
 		},
 		cancelSettle(){
-			this.$util.hitRemind()
+			this.$innerAudioContext.play()
 			this.settleOpenStatus = 0
 			this.$refs.settlePopRef.close()
 		},
 		async settleReturn(){
-			this.$util.hitRemind()
+			this.$innerAudioContext.play()
 			this.setCreateOrder()
 		},
 		selectPayWayBack(price){
-			this.$util.hitRemind()
+			this.$innerAudioContext.play()
 		},
 		toWastage(){
-			this.$util.hitRemind()
+			this.$innerAudioContext.play()
 			if(this.$util.isEmpty(this.selectList)) {
 				this.$msg('请选择报损花材')
 				return false
@@ -186,7 +186,7 @@ export default {
 			this.$refs.wastageRef.open('center')
 		},
 		confirmWastage(){
-			this.$util.hitRemind()
+			this.$innerAudioContext.play()
 			if(this.$util.isEmpty(this.selectList)) {
 				this.$msg('请选择报损花材')
 				return false
@@ -224,7 +224,7 @@ export default {
 			}
 		},
 		goSettleCommit(){
-			this.$util.hitRemind()
+			this.$innerAudioContext.play()
 			if(this.$util.isEmpty(this.selectList)) {
 				this.$msg('请选择结算花材')
 				return false
@@ -238,16 +238,16 @@ export default {
 		},
 		//清空花材弹框
 		clearItemFn(){
-			this.$util.hitRemind()
+			this.$innerAudioContext.play()
 			this.$refs.clearItemRef.open()
 		},
 		//确认清空花材
 		confirmClearItem(){
-			this.$util.hitRemind()
+			this.$innerAudioContext.play()
 			this.removeFromSaveDirect()
 		},
 		confirmLogout(){
-			this.$util.hitRemind()
+			this.$innerAudioContext.play()
 			uni.clearStorage()
 			this.$store.commit("setLoginInfo", {})
 			// #ifdef APP-PLUS
@@ -255,11 +255,11 @@ export default {
 			// #endif
 		},
 		logoutFn(){
-			this.$util.hitRemind()
+			this.$innerAudioContext.play()
 			this.$refs.logoutRef.open()
 		},
 		delSelectItem(){
-			this.$util.hitRemind()
+			this.$innerAudioContext.play()
 		}
     }
 }

+ 1 - 1
hdPad/src/pages/home/components/createWork.vue

@@ -144,7 +144,7 @@ export default {
             // #endif
             // #ifdef APP-PLUS
             let that = this
-            this.$util.hitRemind()
+            this.$innerAudioContext.play()
             if(this.form.cover == ''){
                 this.$msg('请上传图片')
                 return false

+ 1 - 1
hdPad/src/pages/home/components/customerList.vue

@@ -38,7 +38,7 @@ export default {
   },
   methods: {
     selectCustomer(info){
-      this.$util.hitRemind()
+      this.$innerAudioContext.play()
       this.$emit('selectCustomer',info)
     },
     changSearch(val){

+ 1 - 1
hdPad/src/pages/home/components/leftArea.vue

@@ -69,7 +69,7 @@ export default {
     },
     methods:{
         delItem(item){
-            this.$util.hitRemind()
+            this.$innerAudioContext.play()
             item.currentNum = 0
             this.replaceItemFn(item)
         }

+ 4 - 4
hdPad/src/pages/home/components/leftGroup.vue

@@ -67,10 +67,10 @@ export default {
     },
     methods:{
 		selectPayWayBack(price){
-			this.$util.hitRemind()
+			this.$innerAudioContext.play()
 		},
         getDetail(item){
-            this.$util.hitRemind()
+            this.$innerAudioContext.play()
             uni.showLoading({mask:true})
             detail({id:item.id}).then(res=>{
                 uni.hideLoading()
@@ -96,7 +96,7 @@ export default {
 			})
 		},
 		cancelPay(){
-			this.$util.hitRemind()
+			this.$innerAudioContext.play()
 			this.$refs.toPayRef.close()
 			this.getNewItemAndListenScan()
 		},
@@ -117,7 +117,7 @@ export default {
             })
         },
 		cancelSettle(){
-			this.$util.hitRemind()
+			this.$innerAudioContext.play()
 			this.settleOpenStatus = 0
 			this.$refs.settlePopRef.close()
 		},

+ 1 - 1
hdPad/src/pages/home/components/nav.vue

@@ -51,7 +51,7 @@ export default {
       }
 		},
     goTo(item) {
-      this.$util.hitRemind();
+      this.$innerAudioContext.play();
       this.$util.pageTo({ url: item.page, type: 2 });
     },
   },

+ 3 - 3
hdPad/src/pages/home/components/rightGoods.vue

@@ -115,7 +115,7 @@ export default {
     },
     methods:{
         setNum(info){
-            this.$util.hitRemind()
+            this.$innerAudioContext.play()
             this.flowerNum = info.num
             this.list.data=[]
             this.list.page = 1
@@ -123,7 +123,7 @@ export default {
             this.getGoodsData()
         },
 		popAddModelFn(info) {
-            this.$util.hitRemind()
+            this.$innerAudioContext.play()
 			this.showAddModelFn({ ...info, currentNum: 1, unitPrice: info.price,unitType:0})
 		},
         init(){
@@ -148,7 +148,7 @@ export default {
             }
         },
         changeCategory(item){
-            this.$util.hitRemind()
+            this.$innerAudioContext.play()
             this.list.data=[]
             this.list.page = 1
             this.list.finished = false

+ 2 - 2
hdPad/src/pages/home/components/rightItem.vue

@@ -85,7 +85,7 @@ export default {
     },
     methods:{
 		popAddModelFn(info) {
-            this.$util.hitRemind()
+            this.$innerAudioContext.play()
 			this.showAddModelFn({ ...info, currentNum: 1, unitPrice: info.price,unitType:0})
 		},
         async init(){
@@ -100,7 +100,7 @@ export default {
             this.itemInfoList = this.allItemInfo[this.categoryId]
         },
         changeCategory(item){
-            this.$util.hitRemind()
+            this.$innerAudioContext.play()
             if(item.id === this.categoryId){
                 return false
             }

+ 1 - 1
hdPad/src/pages/home/components/selectPrice.vue

@@ -39,7 +39,7 @@ export default {
             this.checkType = 1
         },
         cancel(){
-            this.$util.hitRemind()
+            this.$innerAudioContext.play()
             this.$emit('cancelSelectPrice')
         },
         activeKeyboard() {

+ 2 - 2
hdPad/src/pages/home/components/workInfo.vue

@@ -285,11 +285,11 @@ export default {
       })
     },
     cancelFinish(){
-			this.$util.hitRemind()
+			this.$innerAudioContext.play()
 			this.$refs.finishWorkRef.close()
     },
     modifyItem(info){
-      this.$util.hitRemind()
+      this.$innerAudioContext.play()
       this.$util.pageTo({url:'/pages/home/modify',query: { id:info.id }})
     },
     getStatus(status) {

+ 1 - 1
hdPad/src/pages/home/components/workList.vue

@@ -83,7 +83,7 @@ export default {
         },
         getOrder(item,click=0){
             if(click == 1){
-                this.$util.hitRemind()
+                this.$innerAudioContext.play()
             }
             this.selectOrderId = item.id
             this.$emit('getOrder',item)

+ 3 - 3
hdPad/src/pages/home/make.vue

@@ -97,16 +97,16 @@ export default {
 			this.$refs.createWorkRef.close()
 		},
 		commit(){
-				this.$util.hitRemind()
+				this.$innerAudioContext.play()
 				this.$refs.createWorkRef.open()
 		},
 		clearItemFn(){
-			this.$util.hitRemind()
+			this.$innerAudioContext.play()
 			this.$refs.clearItemRef.open()
 		},
 		//确认清空花材
 		confirmClearItem(){
-			this.$util.hitRemind()
+			this.$innerAudioContext.play()
 			this.removeFromSaveDirect()
 		},
 		changeProperty(property){

+ 4 - 4
hdPad/src/pages/home/modify.vue

@@ -56,20 +56,20 @@ export default {
 	methods: {
 		//清空花材弹框
 		clearItemFn(){
-			this.$util.hitRemind()
+			this.$innerAudioContext.play()
 			this.$refs.clearItemRef.open()
 		},
 		//确认清空花材
 		confirmClearItem(){
-			this.$util.hitRemind()
+			this.$innerAudioContext.play()
 			this.removeFromSaveDirect()
 		},
 		cancel(){
-			this.$util.hitRemind()
+			this.$innerAudioContext.play()
 			uni.navigateBack({delta: 1})
 		},
 		confirmModify(){
-			this.$util.hitRemind()
+			this.$innerAudioContext.play()
 			if(this.$util.isEmpty(this.selectList)){
 				this.$msg('请选择花材')
 				return false

+ 2 - 2
hdPad/src/pages/home/selectMake.vue

@@ -110,7 +110,7 @@ export default {
 			})
 		},
 		clearItemFn(){
-			this.$util.hitRemind()
+			this.$innerAudioContext.play()
 			this.$refs.clearItemRef.open()
 		},
 		changeProperty(property){
@@ -127,7 +127,7 @@ export default {
 		},
 		//确认清空花材
 		confirmClearItem(){
-			this.$util.hitRemind()
+			this.$innerAudioContext.play()
 			this.removeFromSaveDirect()
 		},
 	}

+ 0 - 21
hdPad/src/utils/util.js

@@ -314,26 +314,6 @@ export const noStockRemind = () =>{
 	})
 }
 
-//点击声效 shish
-export const hitRemind = () =>{
-	//没有库存声音提醒
-	const innerAudioContext = uni.createInnerAudioContext();
-	innerAudioContext.autoplay = true;
-	innerAudioContext.src = `${CONSTANT.imgUrl}/hit.mp3`;
-	innerAudioContext.volume = 0.5
-	innerAudioContext.onPlay(() => {
-		//console.log('开始播放');
-	});
-	innerAudioContext.onError((res) => {
-		//console.log(res.errMsg);
-		//console.log(res.errCode);
-	});
-	innerAudioContext.onPause(function() {
-		//console.log('end');
-		innerAudioContext.destroy();
-	})
-}
-
 //去重 姜枫 2021.05.05
 export const unique = (arr) => {
 	for(var i=0; i<arr.length; i++){
@@ -380,6 +360,5 @@ export default {
 	isNumber,
 	noStockRemind,
 	callUp,
-	hitRemind,
 	isScanEnv
 };