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

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

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

3.

  <!--出价软键盘-->
        <view class="mark" hidden="{{hidden}}" bindtap="bindMark"></view>
        <view class="Bid_list" hidden='{{hidden}}'>
            <view class="Lead">
                <view><span>领先价</span><span class="Lead_price">{{lead_price}}元</span></view>
                <view class="close">x</view>
            </view>
            <view class="shuru">
                <span class="bid">我要出价</span>
                <view id="view">{{new_price}}</view>
            </view>
            <view class="offer_price" bindtap='bindGoPrice' data-id='{{product_info.product_id}}'>出价</view>
            <view class="Explain">出价即表示同意《随手拍竞拍服务协议》</view>
            <view class="layer-content" style="bottom: 0px;">
                <view class="form_edit clearfix">
                    <view class="num" bindtap="bindNumber" data-id="1">1</view>
                    <view class="num" bindtap="bindNumber" data-id="2">2</view>
                    <view class="num" bindtap="bindNumber" data-id="3">3</view>
                    <view class="num" bindtap="bindNumber" data-id="4">4</view>
                    <view class="num" bindtap="bindNumber" data-id="5">5</view>
                    <view class="num" bindtap="bindNumber" data-id="6">6</view>
                    <view class="num" bindtap="bindNumber" data-id="7">7</view>
                    <view class="num" bindtap="bindNumber" data-id="8">8</view>
                    <view class="num" bindtap="bindNumber" data-id="9">9</view>
                    <view class="num" bindtap="bindNumber" data-id=".">.</view>
                    <view class="num" bindtap="bindNumber" data-id="0">0</view>
                    <view id="remove" bindtap='bindRemove'>删除</view>
                </view>
            </view>

        </view>
/*软键盘*/
.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
    })
  },

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
Winform是一种运行于Microsoft Windows操作系统上的桌面应用程序开发框架。使用Winform框架可以方便快捷地制作出各种个性化的桌面应用程序。其中,数字键盘小程序是Winform框架的一种常见应用。 数字键盘小程序可用于各种场合,如密码输入、金额输入等。其基本功能是提供数字输入的便捷性。一般来说,数字键盘小程序应该包含0~9十个数字删除键。在Winform框架下,数字键盘小程序常用的控件包括:按钮控件、文本框控件、标签控件、面板控件等。 使用Winform框架制作数字键盘小程序的主要过程包括以下几个步骤: Step 1. 新建Winform项目,创建数字键盘UI布局。 Step 2. 在UI布局中添加按钮和文本框控件,使其具备数字输入的功能。 Step 3. 对按钮添加点击事件,可以使用控件内置的Click事件。 Step 4. 在点击事件中实现数字输入逻辑,将数字添加到文本框中。 Step 5. 对删除添加点击事件,在点击事件中将文本框中最后一个字符删除。 通过以上几个步骤,可以轻松制作出一个简单的数字键盘小程序。此外,还可以通过添加键盘按键事件、美化UI界面等方式增强该程序的易用性和美观度。 总的来说,Winform框架为制作数字键盘小程序提供了很大的便利性和开发效率。程序员们只需要掌握基本的开发知识,便可以轻松地为Windows系统用户提供各种实用的桌面应用程序。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值