微信小程序之时间选择、switch开闭按钮、picker下拉选择框

效果图:
微信小程序之时间选择、switch开闭按钮、picker下拉选择框_第1张图片

代码:
html:

<view class="khinputbox">
      <view class="jibeninfo">
        <view class="jibentit">客户来访view>
      view>
      <view class="yilaifang">
        <view class="yilaitit">
          <view>
            客户是否已来访
            <switch checked="{{is_visit}}" bindchange="visittap" color="#ff2b0a" class="yilfswitch" />
          view>
        view>
          <view class="zhuibomtxt" bindtap="laifangdisable">
            <view>来访时间view>
            <picker class="select" 
                      mode="date" 
                      disabled="{{!is_visit}}"
                      value="{{laifang_time}}" 
                      start="{{lfstartdate}}" 
                      end="{{enddate}}" 
                      bindchange="bindlfdateChange">
              <view class="picker">
                {{laifang_time == 0 ? '请选择' : laifang_time}}
              view>
            picker>
            <view class="select bomnone smselect">
              {{weekdaylf}}
            view>
            <picker class="select smselect" 
                      mode="time" 
                      disabled="{{!is_visit}}"
                      value="{{yilaifang_time}}" 
                      start="06:00" 
                      end="23:00" 
                      bindchange="bindylfTimeChange">
              <view class="picker">
                {{yilaifang_time == 0 ? '请选择' : yilaifang_time}}
              view>
            picker>
          view>
          <view class="zhuifangbox">
            <view class="inptxt">来访说明view>
            <scroll-view class="areabox" bindtap="areatanshow" data-textareatit="来访说明" scroll-y="{{true}}">{{analysis}}scroll-view>
          view>
      view>
    view>

js:

// bindlfdateChange
  bindlfdateChange: function (e) {
    this.setData({
      laifang_time: e.detail.value
    })
    if (this.data.laifang_time != 0) {
      let today = util.getWeek(this.data.laifang_time);
      this.setData({
        weekdaylf: today
      })
    }
    // console.log(this.data.laifang_time);
  },
  bindylfTimeChange: function (e) {
    this.setData({
      yilaifang_time: e.detail.value
    })
    // console.log(this.data.laifang_time);
  },
  visittap: function () {
    this.setData({
      // djiisdown: !this.data.djiisdown,
      is_visit: !this.data.is_visit
    })
    if (this.data.is_visit == 0) {
      this.setData({
        laifang_time: 0,
        weekdaylf: '',
        yilaifang_time: '',
        analysis: '',
      })
    }
    // console.log(this.data.is_visit);
  },

你可能感兴趣的:(微信小程序)