|
|
@@ -110,11 +110,11 @@
|
|
|
</view>
|
|
|
</view>
|
|
|
</view>
|
|
|
- <uni-popup ref="calcHistoryPopup" type="center" background-color="#ffffff">
|
|
|
+ <uni-popup ref="calcHistoryPopup" type="center" background-color="#ffffff" @change="onCalcHistoryPopupChange">
|
|
|
<view class="calc-history-popup">
|
|
|
<view class="calc-history-popup-hd">
|
|
|
<text class="calc-history-popup-title">历史记录</text>
|
|
|
- <text class="calc-history-popup-close" @tap.stop="closeCalcHistory">关闭</text>
|
|
|
+ <text class="calc-history-popup-close" @tap.stop="onHistoryPopupCloseTap">关闭</text>
|
|
|
</view>
|
|
|
<scroll-view scroll-y class="calc-history-popup-body">
|
|
|
<view
|
|
|
@@ -151,6 +151,8 @@ export default {
|
|
|
calcInput: '',
|
|
|
calcHistory: [],
|
|
|
maxHistory: 20,
|
|
|
+ /** 通过代码调用 uni-popup.close 时为 true,避免与遮罩关闭的 @change 重复播点击音 */
|
|
|
+ _historyPopupCloseByApi: false,
|
|
|
}
|
|
|
},
|
|
|
computed: {
|
|
|
@@ -186,6 +188,10 @@ export default {
|
|
|
},
|
|
|
},
|
|
|
methods: {
|
|
|
+ /** 全页可点区域统一按键音(依赖 $util.hitVoice) */
|
|
|
+ tapVoice() {
|
|
|
+ this.$util.hitVoice()
|
|
|
+ },
|
|
|
/** 构造用于求值的数字列与运算符列(末尾仅挂运算符、无下一操作数时不参与运算) */
|
|
|
buildEvalState() {
|
|
|
const nums = []
|
|
|
@@ -362,24 +368,39 @@ export default {
|
|
|
return parseFloat(s).toString()
|
|
|
},
|
|
|
focusCalc() {
|
|
|
- this.$util.hitVoice()
|
|
|
+ this.tapVoice()
|
|
|
this.keyboardTarget = 'calc'
|
|
|
this.checkType = 3
|
|
|
},
|
|
|
checkCurrent(n) {
|
|
|
- this.$util.hitVoice()
|
|
|
+ this.tapVoice()
|
|
|
this.checkType = n
|
|
|
this.keyboardTarget = n === 1 ? 'order' : 'cash'
|
|
|
},
|
|
|
openCalcHistory() {
|
|
|
- this.$util.hitVoice()
|
|
|
+ this.tapVoice()
|
|
|
this.$refs.calcHistoryPopup && this.$refs.calcHistoryPopup.open()
|
|
|
},
|
|
|
+ onHistoryPopupCloseTap() {
|
|
|
+ this.tapVoice()
|
|
|
+ this.closeCalcHistory()
|
|
|
+ },
|
|
|
closeCalcHistory() {
|
|
|
+ this._historyPopupCloseByApi = true
|
|
|
this.$refs.calcHistoryPopup && this.$refs.calcHistoryPopup.close()
|
|
|
},
|
|
|
+ onCalcHistoryPopupChange(e) {
|
|
|
+ if (!e || e.show !== false) {
|
|
|
+ return
|
|
|
+ }
|
|
|
+ if (this._historyPopupCloseByApi) {
|
|
|
+ this._historyPopupCloseByApi = false
|
|
|
+ return
|
|
|
+ }
|
|
|
+ this.tapVoice()
|
|
|
+ },
|
|
|
onHistoryRowTap(e) {
|
|
|
- this.$util.hitVoice()
|
|
|
+ this.tapVoice()
|
|
|
const idx = Number(e.currentTarget.dataset.idx)
|
|
|
if (isNaN(idx) || idx < 0) {
|
|
|
return
|
|
|
@@ -405,7 +426,6 @@ export default {
|
|
|
}
|
|
|
},
|
|
|
clearStack() {
|
|
|
- this.$util.hitVoice()
|
|
|
this.tokens = []
|
|
|
this.calcInput = ''
|
|
|
},
|
|
|
@@ -426,11 +446,11 @@ export default {
|
|
|
this.checkType = 3
|
|
|
},
|
|
|
cancel() {
|
|
|
- this.$util.hitVoice()
|
|
|
+ this.tapVoice()
|
|
|
this.$emit('cancelSelectPrice')
|
|
|
},
|
|
|
onNumpadTap(e) {
|
|
|
- this.$util.hitVoice()
|
|
|
+ this.tapVoice()
|
|
|
const ds = e.currentTarget.dataset || {}
|
|
|
const action = ds.action
|
|
|
const char = ds.char
|
|
|
@@ -526,7 +546,7 @@ export default {
|
|
|
this.checkType = 0
|
|
|
},
|
|
|
submitGathering() {
|
|
|
- this.$util.hitVoice()
|
|
|
+ this.tapVoice()
|
|
|
if (this.keyboardTarget === 'calc') {
|
|
|
const st = this.stackTotal
|
|
|
if (!Number.isFinite(st) || isNaN(st)) {
|