小程序软键盘 添加删除数字

1.将软键盘绑定data-id 将获取的data-id的值

2.获取到我要出价的值,将拿到的值和data-id进行拼接

3.

  
        
        
/*软键盘*/
.mark {
    position: fixed;
    left: 0;
    right: 0;
    top: 0;
    bottom: 0;
    background: rgba(0,0,0,0.5);
}
.form_edit {
    width: 100%;
    background: #D1D4DD;
}

.form_edit > view {
    margin-bottom: 2px;
    margin-right: 0.5%;
    float: left;
    width: 33%;
    height: 45px;
    text-align: center;
    color: #333;
    line-height: 45px;
    font-size: 18px;
    font-weight: 600;
    background-color: #fff;
    border-radius: 5px;
}

.form_edit > view:nth-child(3n) {
    margin-right: 0;
}

.form_edit > view:last-child {
    background-color: #DEE1E9;
}


.Bid_list {
    position: fixed;
    width: 100%;
    bottom: 0;
    left: 0;
    display: block;
    background-color: #f3f3f3;
}
.shuru {
    display: flex;
    align-items: center;
    margin-bottom: 10px;
}
.offer_price {
    background-color: #085556;
    position: relative;
    width: 90%;
    margin: auto;
    height: 40px;
    line-height: 40px;
    color: #fff;
    font-size: 16px;
    text-align: center;
    border-radius: 4px;
}
.Explain {
    text-align: right;
    font-size: 12px;
    padding: 10px 20px;
}
.bid {
    width: 20%;
    text-align: center;
    background: #085556;
    color: white;
    height: 40px;
    line-height: 40px;
}
#view {
    flex: 1;
    height: 40px;
    line-height: 40px;
    background: white;
    color: #576b95;
    font-size: 18px;
    /* margin-left: 10px; */
    padding-left: 10px;
}
.Lead {
    display: flex;
    justify-content: space-between;
    padding: 10px;
}
.Lead_price {
    color: #576b95;
    font-size: 18px;
    margin-left: 10px;
}
.mask {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    top: 0;
}
.close {
    width: 30px;
    text-align: center;
}


data:{
lead_price:'',//当前出价
      new_price:'',//领先价
      hidden:true,//软键盘显示状态
},

 //  点击软键盘
  bindNumber:function(event){
    var value = event.currentTarget.dataset.id;//软键盘的值
    var new_price = this.data.new_price.toString();//将数字转换为字符串
    var str = new_price.split('');//在将字符串转换成数组
    str.push(value);//将点击的值添加进数组中
    this.data.new_price = str.join("");//再将数组装换为字符串
    this.setData({
      new_price: this.data.new_price
    })
  },
 // 删除软键盘数字
  bindRemove:function(){
    var new_price = this.data.new_price.toString();//同上
    var str = new_price.split('');
    str.splice(str.length-1,1);
    this.data.new_price = str.join("")
    this.setData({
      new_price: this.data.new_price
    })
  },
  // 遮罩层
  bindMark:function(){
    this.setData({
      hidden: true
    })
  },

 

你可能感兴趣的:(get,技能)