小程序 - tab两栏切换效果

    <view class="shop-box">
        <view class="item">
            <view class="titel">
            <!-- style 可通过三元运算控制class类得到 -->
                <view class="p-text {{currentTab == "0" ? "text-bg" : ""}}" dada-current="0" 
                   bindtap="clickTab" style="color: {{currentTab=="0"?"#00a9fe":"#333"}}">
                    待缴费
                </view>
                <view class="p-text {{currentTab == "1" ? "text-bg" : ""}}" dada-current="0" 
                   bindtap="clickTab" style="color: {{currentTab=="1"?"#00a9fe":"#333"}}">
                    已缴费
                </view>
                <view class="img-box">
                    <picker mode="date" name="action_date" value="{{date}}" start="2010-09-01"
                     end="2099-09-01" bindchange="bindDateChange">
                         <image class="img" src="" mode="widthFix"></image>
                    </packer>
                </view>
            </view>
        </view>
    </view>
    <view class="form-box">
        <view class="weui-cell" wx:for="{{bill_list}}" wx:key="index">
            <view class="weui-cell-bd">{{iterm.unitName}}</view>
            <view class="weui-cell-ft">{{currentTab == 0 ? '未缴费':'已缴费'}}</view>
        </view>
        <view class="weui-cell" wx:for="{{bill_list}}" wx:key="index">
            <view class="weui-cell-bd">缴费类型</view>
            <view class="weui-cell-ft">{{type}}</view>
        </view>
        <view class="border-top">
            <button class="weui-btn" wx:if="{{currentTab==0}}" open-type="share" 
            data-id="{{item.id}}">催缴</button>
            <button class="weui-btn" wx:if="{{currentTab==0}}" open-type="share" 
            data-id="{{item.id}}" bindtap="navigatorUrl">缴费</button>
            <button class="weui-btn" wx:if="{{currentTab==1}}" open-type="share" 
            data-id="{{item.id}}" bindtap="navigatorUrl">查看</button>
        </view>
    </view>
var app = getApp();
Page({
    data: {
        currentTab: 0,
    },
    onLoad: function(option) {
        var that = this
        var currentType = option.currentType
        form_util.saveFormIds(app)  // 调用一个js
        that.setData({
            "type": currentType === "tube" ? "物业费" : (currentType === "water" ? "水费""电费"),
            "option": option
        })
        that.loadPager(1)
    },
    // 选项卡切换
    clickTab: function(e) {
        var that = this
        this.setData({
            currentTab: e.target.dataset.current
        })
        that.loadPager(1)
    },
    // 判断页面属性跳转
    navigatorUrl: function(e) {
        var id = e.currentTarget.dataset.id;
        var currentType = this.data.option.currentType;
        id && wx.navigateTo({
            url: "/pages/payment/info/index?id=" + id + "&currentType=" +  currentType,
        })  
    },  
  //转发
  onShareAppMessage: function(e) {
    var that = this;
    var id = e.target.dataset.id,
      currentType = that.data.option.currentType,
      typeName = that.data.type;
    var shareData = {
      title: '你这个月的' + typeName + '账单出来了, 赶快查看一下吧!',
      desc: '查看账单',
      path: '/pages/payment/info/index?id=' + id + '&currentType='+currentType,
    }
    //   分享给好友
    return shareData
  },
  // 日历
    bindDateChange: function(e) {
    var that = this
    that.setData({
      "date": e.detail.value
    })
    that.loadPager(1)
  },
})

效果图:
这里写图片描述

  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值