Commit cf2a3e20 authored by jiangjiantao's avatar jiangjiantao

键盘内容超出优化

parent 3cf5c999
...@@ -62,7 +62,7 @@ ...@@ -62,7 +62,7 @@
/* icon+结果 */ /* icon+结果 */
.result-container { .result-container {
width: 80%; width: 85%;
height: 60rpx; height: 60rpx;
display: flex; display: flex;
flex-direction: row; flex-direction: row;
...@@ -79,7 +79,7 @@ ...@@ -79,7 +79,7 @@
/* 结果展示 */ /* 结果展示 */
.result-display { .result-display {
width: 80%; width: 85%;
height: 100%; height: 100%;
display: flex; display: flex;
align-items: center; align-items: center;
...@@ -108,7 +108,7 @@ ...@@ -108,7 +108,7 @@
/* 中间空白的部分 */ /* 中间空白的部分 */
.result-blank { .result-blank {
width: 10%; width: 5%;
height: 100%; height: 100%;
} }
......
...@@ -10,7 +10,7 @@ ...@@ -10,7 +10,7 @@
<text class="result-display-text-empty" a:if="{{result == '' && scenes == 2}}">请输入会员号</text> <text class="result-display-text-empty" a:if="{{result == '' && scenes == 2}}">请输入会员号</text>
<text class="result-display-text-empty" a:if="{{result == '' && scenes == 3 }}">请输入收款金额</text> <text class="result-display-text-empty" a:if="{{result == '' && scenes == 3 }}">请输入收款金额</text>
<text class="result-display-text-empty" a:if="{{result == '' && scenes == 4}}">请输入退款金额</text> <text class="result-display-text-empty" a:if="{{result == '' && scenes == 4}}">请输入退款金额</text>
<text class="result-display-text" a:if="{{result != ''}}">{{result}}</text> <text class="result-display-text" a:if="{{result != ''}}">{{showresult}}</text>
</view> </view>
</view> </view>
<view class="result-baseline"> <view class="result-baseline">
......
Component({ Component({
mixins: [], mixins: [],
data: { data: {
showresult:"",
result: "", result: "",
scenes: 2, scenes: 2,
errMsg: "" errMsg: ""
...@@ -23,6 +24,7 @@ Component({ ...@@ -23,6 +24,7 @@ Component({
this.setData({ this.setData({
result: '', result: '',
errMsg: '', errMsg: '',
showresult:''
}); });
} }
...@@ -35,36 +37,41 @@ Component({ ...@@ -35,36 +37,41 @@ Component({
add7(e) { add7(e) {
this.setData({ result: this.data.result + "7" }); this.addInputContont("7")
}, add8(e) { }, add8(e) {
this.setData({ result: this.data.result + "8" }); this.addInputContont("8")
}, add9(e) { }, add9(e) {
this.setData({ result: this.data.result + "9" }); this.addInputContont("9")
}, add4(e) { }, add4(e) {
this.setData({ result: this.data.result + "4" }); this.addInputContont("4")
}, add5(e) { }, add5(e) {
this.setData({ result: this.data.result + "5" }); this.addInputContont("5")
}, add6(e) { }, add6(e) {
this.setData({ result: this.data.result + "6" }); this.addInputContont("6")
}, add1(e) { }, add1(e) {
this.setData({ result: this.data.result + "1" }); this.addInputContont("1")
}, add2(e) { }, add2(e) {
this.setData({ result: this.data.result + "2" }); this.addInputContont("2")
}, add3(e) { }, add3(e) {
this.setData({ result: this.data.result + "3" }); this.addInputContont("3")
}, add0(e) { }, add0(e) {
this.setData({ result: this.data.result + "0" }); this.addInputContont("0")
}, addpoint(e) { }, addpoint(e) {
if (this.data.scenes == 3 || this.data.scenes == 4) { if (this.data.scenes == 3 || this.data.scenes == 4) {
this.setData({ result: this.data.result + "." }); this.addInputContont(".")
} }
}, delete(e) { }, delete(e) {
if (this.data.result.length > 1) { if (this.data.result.length > 1) {
let cur = this.data.result; let cur = this.data.result;
cur = cur.substring(0, cur.length - 1) cur = cur.substring(0, cur.length - 1)
this.setData({ result: cur });
let shownewresult = cur
if (cur.length > 13) {
shownewresult = "..." + cur.substring(cur.length - 11, cur.length)
}
this.setData({ result: cur, showresult: shownewresult });
} else { } else {
this.setData({ result: '' }); this.setData({ result: '',showresult:''});
} }
}, finish(e) { }, finish(e) {
this.setData({ errMsg: "" }) this.setData({ errMsg: "" })
...@@ -85,8 +92,19 @@ Component({ ...@@ -85,8 +92,19 @@ Component({
this.props.onKeyBordFinished(this.data.result); this.props.onKeyBordFinished(this.data.result);
}, closeKeybord(e) { }, closeKeybord(e) {
this.props.onKeyBordClose(); this.props.onKeyBordClose();
} },
//处理输入的内容
addInputContont(content){
let newresult = this.data.result + content;
let shownewresult = newresult
if(newresult.length > 13){
shownewresult = "..."+ newresult.substring(newresult.length - 11,newresult.length)
}
this.setData({ result: newresult,showresult:shownewresult});
}
}, },
}); });
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment