微信小程序实现充值,自定义金额充值

首页一如既往的先上效果图:

     

上代码:

WXML----------------------------------------------------------

<view class="bgView flexStandard">
  <view class="titleBox">
    <view class="titleView"><text class="title">钱包余额</text></view>
    <view><text class="num">0.00</text></view>
  </view>
</view>

<view class="czhiView flexVertical">
  <text>充值金额</text>
</view>


<view class="flexCenten">
  <view class="btnView">
    <view class="flexCenten {{activeIndex == index ? 'active':'noactive'}}" wx:for="{{numArray}}" wx:key="index"
      bindtap="activethis" data-thisindex="{{index}}">
      <text wx:if="{{item!='m'}}" class="otherText">¥{{item}}</text>
      <text wx:if="{{item=='m' && activeIndex != index}}" class="zidyText">自定义金额</text>
      <input wx:if="{{item=='m' && activeIndex == index}}" class="weui-input inputView" type="number"
        placeholder="请输入金额"></input>
    </view>
  </view>
</view>

<view class="czhiBox flexStandard">
  <view class="btnczhi flexCenten">
    <text>立即充值</text>
  </view>
</view>

JS----------------------------------------------------------

  /**
   * 页面的初始数据
   */
  data: {
    activeIndex: 0, //默认选中第一个
    numArray: [20, 30, 50, 80, 100,'m']
  },
  activethis: function (event) { //点击选中事件
    var thisindex = event.currentTarget.dataset.thisindex; //当前index
    this.setData({
      activeIndex: thisindex
    })
  }

wxss---------------------------------------------------

.active {
  background-color: #6d97f8;
  border: 2px solid #6d97f8;
  color: white;
}

.noactive {
  background-color: white;
  border: 2px solid white;
  color: black;
}

.btnView {
  width: 100%;
  height: 300rpx;
  display: flex;
  flex-wrap: wrap;
  align-content: flex-start;
  justify-content: center;
}

.btnView view {
  width: 210rpx;
  height: 100rpx;
  margin: 10rpx;
  border-radius: 10rpx;
}

.otherText {
  /* color: black; */
  font-size: 38rpx;
  font-weight: 600;
}

.inputView {
  height: 100%;
  width: 100%;
  text-align: center;
  font-size: 38rpx;
  color: white;
}

.zidyText {
  font-size: 30rpx;
  font-weight: 600;
}

.bgView {
  background-image: linear-gradient(0deg, #6d97f8, #5cb3f3);
  height: 150rpx;
  width: 100%;
  margin-bottom: 30rpx;
}
.titleBox{
  text-align: center;
}
.title {
  color: white;
  font-size: 28rpx;
}
.titleView{
  margin-bottom: 20rpx;
}

.num{
  color: white;
  font-size: 40rpx;
  font-weight: 600;
}

.czhiView{
  width: 100%;
  height: 100rpx;
  background-color: white;
  padding: 0rpx 30rpx;
  margin-bottom: 10rpx;
}

.czhiView text{
  font-size: 28rpx;
}
.czhiBox{
  width: 100%;
}
.btnczhi{
  width: 94%;
  background-image: linear-gradient(45deg, #6d97f8, #5cb3f3);
  height: 80rpx;
  border-radius: 10rpx;
}
.btnczhi text{
  color: white;
  font-size: 32rpx;
}

 

  • 14
    点赞
  • 97
    收藏
    觉得还不错? 一键收藏
  • 12
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值