国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 課堂 > 小程序 > 正文

微信小程序時間標簽和時間范圍的聯(lián)動效果

2020-03-21 16:01:57
字體:
來源:轉載
供稿:網(wǎng)友

本文實例為大家分享了微信小程序時間標簽和時間范圍聯(lián)動的具體代碼,供大家參考,具體內(nèi)容如下

微信小程序,時間,聯(lián)動

最近忙于一個有關數(shù)據(jù)管理的微信小程序,遇到了上圖情況,雖然很簡單,還是整理一下。若有錯誤,請廣大朋友們指正。

使用微信小程序組件radio-group、picker,用wxss對radio按照需求進行重構,picker里邊的start和end時間是根據(jù)radio來顯示的。將start、end時間放在data里,radio發(fā)生改變時,改變data中的時間。當picker中的值發(fā)生改變時,如果時間范圍已經(jīng)超出了radio中的范圍,需要對radio的顯示進行實時修改。

話不多說,接下來上代碼。

index.wxml

<view class="con_screen"> <text class="cons_ti">日期范圍</text> <!-- 單選時間 --> <radio-group class="radio-group" bindchange="radioCheckedChange">  <block >  <label class="cons_radio {{radioCheckVal==1?'active':''}}" >   <radio value="1" hidden="true"/>   <text>今日</text>  </label>   <label class="cons_radio {{radioCheckVal==4?'active':''}}" >   <radio value="4" hidden="true" />   <text>近7日</text>  </label>   <label class="cons_radio {{radioCheckVal==6?'active':''}}" >   <radio value="6" hidden="true"/>   <text>近30日</text>  </label>    </block> </radio-group> <!-- 時間段 --> <view class="picker_group">  <picker mode="date" value="{{date}}" start="2015-09-01" end="{{date2}}" bindchange="bindDateChange">  <view class="picker">   {{date}}   <image src="../../image/home_zsr_icon.png"></image>  </view>  </picker>  到  <picker mode="date" value="{{date2}}" start="{{date}}" end="2018-01-24" bindchange="bindDateChange2">  <view class="picker">   {{date2}}   <image src="../../image/home_zsr_icon.png"></image>  </view>  </picker>   </view>   </view>

index.wxss

.radio-group{ display: inline-block;}.cons_radio{ margin-left: 30rpx;}.cons_radio text{ font-size: 26rpx; color: #c8c8c8; height: 40rpx; /* width: 93rpx; */ border: #c8c8c8 solid 2rpx; padding:0 20rpx; text-align: center; line-height: 40rpx; display: inline-block; border-radius: 20rpx;}/* 黃色 */.cons_radio.active text{ color: #F5A623; border-color: #F5A623;}/* 紅色 */.cons_radio.activered text{ color: #FA2B21; border-color: #FA2B21;}/* 藍色 */.cons_radio.activeblue text{ color: #4AAFDD; border-color: #4AAFDD;}/* 黃綠色 */.cons_radio.activeyg text{ color: #BABC1A; border-color: #BABC1A;} /* 日期選擇 */.picker_group{ display: block; font-size: 28rpx; color: #c8c8c8; margin-left: 20rpx; margin-top: 15rpx;}.picker_group picker{ display: inline-block; margin:0 20rpx 0 20rpx; position: relative; color: #232323;}.picker_group picker image{ width: 20rpx; height: 20rpx;}.cons_zsr{ display: block; font-size: 32rpx; color: #232323; margin-left: 40rpx; margin-bottom: 15rpx;}.cons_zsr picker image{ width: 30rpx; height: 30rpx;}

index.js

Page({ data:{ page:'', Loading:false, isLogin:false, radioCheckVal:0,//收益占比單選 date: '2015-09-01',//收益占比時間段起始時間 date2:'2018-01-24',//收益占比時間段終止時間 },  // 收益占比單選時間 ring radioCheckedChange(e){  let that=this;  that.setData({   radioCheckVal:e.detail.value  })  console.log(that.data.radioCheckVal) if(that.data.radioCheckVal=='1'){  that.setData({  date:timedate.formatDate(now),  date2:timedate.formatDate(now),  })  // console.log(that.data.date+'------'+that.data.date2)  that.timeFn(that.data.arrayindex,that.data.date,that.data.date2) } if(that.data.radioCheckVal=='4'){  that.setData({  date:timedate.sevenDays().t2,  date2:timedate.sevenDays().t1,  })  // console.log(that.data.date+'------'+that.data.date2)  that.timeFn(that.data.arrayindex,that.data.date,that.data.date2) } if(that.data.radioCheckVal=='6'){  that.setData({  date:timedate.thirtyDays().t2,  date2:timedate.thirtyDays().t1,  })  // console.log(that.data.date+'------'+that.data.date2)  that.timeFn(that.data.arrayindex,that.data.date,that.data.date2) } }, // 收益占比時間段選擇 bindDateChange(e){ let that=this; console.log(e.detail.value) that.setData({  date: e.detail.value,  radioCheckVal:0, }) that.timeFn(that.data.arrayindex,that.data.date,that.data.date2) }, bindDateChange2(e){ let that=this; that.setData({  date2: e.detail.value,  radioCheckVal:0, }) that.timeFn2(that.data.arrayindex,that.data.date,that.data.date2) },

以上就是本文的全部內(nèi)容,希望對大家的學習有所幫助,也希望大家多多支持VEVB武林網(wǎng)。


發(fā)表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發(fā)表
主站蜘蛛池模板: 通州市| 武邑县| 高碑店市| 库伦旗| 顺义区| 中牟县| 泸州市| 清水县| 铁力市| 科技| 岱山县| 灌南县| 青州市| 马龙县| 宣武区| 永州市| 内乡县| 永丰县| 嵊州市| 会同县| 泰宁县| 乡宁县| 黔东| 郸城县| 吴堡县| 盱眙县| 山阳县| 贵定县| 奈曼旗| 万荣县| 浦北县| 大竹县| 新龙县| 涟源市| 瑞金市| 车致| 长岛县| 宾阳县| 宜兰市| 福鼎市| 西乡县|