tm-pickersDateView - 副本.vue 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836
  1. <!-- 日期组件 -->
  2. <template>
  3. <view class="tm-pickersDateView flex-start px-24" :class="[black_tmeme?'grey-darken-5':bgColor]">
  4. <block v-for="(item_data,index_pub) in listData" :key="index_pub">
  5. <view v-if="(index_pub==0&&dataCauser.year)
  6. ||(index_pub==1&&dataCauser.month)
  7. ||(index_pub==2&&dataCauser.day)
  8. ||(index_pub==3&&dataCauser.hour)
  9. ||(index_pub==4&&dataCauser.min)
  10. ||(index_pub==5&&dataCauser.sec)
  11. " class="tm-pickersDateView-wk " :style="{
  12. height:itemHeight*5+'px',
  13. width:jswid() + '%',
  14. marginLeft:index_pub==0?0:1 + '%',
  15. }">
  16. <scroll-view
  17. @touchstart="setChildreIndex(index_pub)"
  18. :show-scrollbar='false'
  19. v-if="dataType!==null&&item_data"
  20. :scroll-top="listIndex[index_pub]?listIndex[index_pub]['wz']:''"
  21. scroll-y
  22. @touchend="scrllEnd"
  23. @scroll="scroll($event,index_pub)"
  24. scroll-with-animation class="tm-pickersDateView-showbg"
  25. :style="{
  26. height:itemHeight*5+'px'
  27. }">
  28. <!-- #ifdef H5 -->
  29. <view :id='"_bar_"+(index4)+"_bar_"' v-for="(item4,index4) in 2" :key="index4+'_a'" class="tm-pickersDateView-item "
  30. :style="{height:itemHeight+'px'}">
  31. <text class="opacity-1"></text>
  32. </view>
  33. <!-- #endif -->
  34. <!-- #ifndef H5 -->
  35. <view :id='"_bar_"+(index4)+"_bar_"' v-for="(item4,index4) in 2" :key="index4" class="tm-pickersDateView-item "
  36. :style="{height:itemHeight+'px'}">
  37. <text class="opacity-1"></text>
  38. </view>
  39. <!-- #endif -->
  40. <view :id='"_bar_"+(index+2)+"_bar_"' v-for="(item,index) in item_data" :key="index"
  41. class="tm-pickersDateView-item flex-center" :style="{
  42. height:itemHeight+'px'
  43. }">
  44. <view class="text-size-g tm-pickersDateView-item-text" :class="[
  45. listIndex[index_pub].itemIndex==index? (black_tmeme?'text-white':'text-black'):(black_tmeme?'':'opacity-4'),
  46. listIndex[index_pub].itemIndex+1==index||listIndex[index_pub].itemIndex-1==index?'textLevel_1':'',
  47. listIndex[index_pub].itemIndex+2==index||listIndex[index_pub].itemIndex-2==index?'textLevel_2':'',
  48. ]">
  49. <text >{{fullNumber?buqi(item):item}}{{index_pub==0&&mode?'年':''}}{{index_pub==1&&mode?'月':''}}{{index_pub==2&&mode?'日':''}}{{index_pub==3&&mode?'时':''}}{{index_pub==4&&mode?'分':''}}{{index_pub==5&&mode?'秒':''}}</text>
  50. </view>
  51. </view>
  52. <!-- #ifdef H5 -->
  53. <view v-for="(item4,index4) in 2" :key="index4+'_bb'" class="tm-pickersDateView-item"
  54. :style="{height:itemHeight+'px'}">
  55. <text></text>
  56. </view>
  57. <!-- #endif -->
  58. <!-- #ifndef H5 -->
  59. <view v-for="(item4,index4) in 2" :key="index4" class="tm-pickersDateView-item"
  60. :style="{height:itemHeight+'px'}">
  61. <text></text>
  62. </view>
  63. <!-- #endif -->
  64. </scroll-view>
  65. <view class="tm-pickersDateView-fg overflow round-5 shadow-5 flex-center"
  66. :class="[
  67. black_tmeme?'white opacity-1':'grey-darken-1 opacity-1'
  68. ]" :style="{
  69. height:itemHeight+'px',
  70. top:itemHeight*2+'px'
  71. }">
  72. </view>
  73. </view>
  74. </block>
  75. </view>
  76. </template>
  77. <script>
  78. /**
  79. * 日期下拉选择器(嵌入式)
  80. * @description 多级关联,单级关联选择
  81. * @property {Array} default-value = [] 默认:当前的时间,初始显示的时间
  82. * @property {String|Number} item-height = [34|42|50|58|62] 项目的高度单位px
  83. * @property {String|Boolean} black = [true|false] 是否开启暗黑模式。
  84. * @property {String|Boolean} disabled = [true|false] 是否禁用
  85. * @property {String} bg-color = [white|blue] 默认:white,白色背景;请填写背景的主题色名称。
  86. * @property {Object} show-detail = [{year:true,month:true,day:true,hour:false,min:false,sec:false}] 默认:{year:true,month:true,day:true,hour:false,min:false,sec:false}
  87. * @property {String} start = [1900-1-1 00:00:00] 默认:1900-1-1 00:00:00,开始的时间
  88. * @property {String} end = [] 默认:当前,结束的时间
  89. * @property {String|Boolean} mode = [true|false] 默认:true,是否显示中文年,月后缀
  90. * @property {String|Boolean} full-number = [true|false] 默认:true,是否把个位数补齐双位数
  91. */
  92. export default {
  93. name: "tm-pickersDateView",
  94. props: {
  95. // 行高。
  96. itemHeight: {
  97. type: String | Number,
  98. default: 40
  99. },
  100. black:{
  101. type:String|Boolean,
  102. default:null
  103. },
  104. // 是否禁用
  105. disabled:{
  106. type:String|Boolean,
  107. default:false
  108. },
  109. // 背景颜色,主题色名称。
  110. bgColor:{
  111. type:String,
  112. default:'white'
  113. },
  114. //要展示的时间。
  115. showDetail:{
  116. type:Object,
  117. default:()=>{
  118. return {
  119. year:true,//年
  120. month:true,//月
  121. day:true,//天
  122. hour:false,//小时
  123. min:false,//分
  124. sec:false//秒
  125. }
  126. }
  127. },
  128. start:{
  129. type:String,
  130. default:'1900-1-1 00:00:00'
  131. },
  132. end:{
  133. type:String,
  134. default:''
  135. },
  136. defaultValue:'',
  137. // 是否显示中文年,月后缀
  138. mode:{
  139. type:String|Boolean,
  140. default:true
  141. },
  142. // 是否把个位数补齐双位数
  143. fullNumber:{
  144. type:String|Boolean,
  145. default:true
  146. }
  147. },
  148. data() {
  149. return {
  150. scrollEvent: 0,
  151. childrenIndex: 0,
  152. scrollChildrenIndex:0,
  153. listIndex: [],
  154. listData: [[],[],[],[],[],[]],
  155. dataCauser:{
  156. year:true,//年
  157. month:true,//月
  158. day:true,//天
  159. hour:true,//小时
  160. min:true,//分
  161. sec:true//秒
  162. },
  163. startTime:null,
  164. endTime:null,
  165. };
  166. },
  167. mounted() {
  168. for(let i =0 ; i <this.listData.length;i++){
  169. this.listIndex.push({
  170. itemIndex: 0,
  171. childrenIndex: 0,
  172. wz: 0
  173. })
  174. }
  175. this.chulisdata()
  176. this.$nextTick(function(){
  177. this.setDefaultValue();
  178. })
  179. },
  180. watch:{
  181. defaultValue:async function(){
  182. await this.setDefaultValue();
  183. },
  184. start:async function(){
  185. await this.setDefaultValue();
  186. },
  187. end:async function(){
  188. await this.setDefaultValue();
  189. },
  190. },
  191. computed: {
  192. dataType: function() {
  193. return 'string';
  194. },
  195. gridNum: function() {
  196. let t = this;
  197. let d = 0;
  198. for(let key in this.showDetail){
  199. if(this.showDetail[key]==true){
  200. d++
  201. }
  202. }
  203. return d;
  204. },
  205. black_tmeme: function() {
  206. if (this.black !== null) return this.black;
  207. return this.$tm.vx.state().tmVuetify.black;
  208. }
  209. },
  210. methods: {
  211. buqi(val){
  212. return (val > 9) ? ("" + val) : ("0" + val);
  213. },
  214. // 获取当前选中的数据。
  215. getSelectedValue(){
  216. let t = this;
  217. let ap = [];
  218. this.listIndex.forEach((item,index)=>{
  219. ap.push(t.listData[index][item.itemIndex])
  220. })
  221. let jg = {
  222. year:ap[0],//年
  223. month:ap[1],//月
  224. day:ap[2],//天
  225. hour:ap[3],//小时
  226. min:ap[4],//分
  227. sec:ap[5]//秒
  228. }
  229. let ar = Object.keys(this.dataCauser);
  230. ar.forEach(item=>{
  231. if(t.dataCauser[item]===false){
  232. delete jg[item]
  233. }
  234. })
  235. return jg;
  236. },
  237. chulisdata() {
  238. if(typeof this.showDetail === 'object'){
  239. this.dataCauser = {...this.dataCauser,...this.showDetail};
  240. }
  241. this.startTime = new Date(this.start.replace(/-/g,'/'))
  242. if(isNaN(this.startTime.getFullYear())){
  243. this.startTime = new Date('1900/1/1 00:00:00')
  244. }
  245. this.endTime = new Date(this.end.replace(/-/g,'/'))
  246. if(isNaN(this.endTime.getFullYear()) ){
  247. this.endTime = new Date()
  248. }
  249. // this.dataCauser.year===
  250. if(true){
  251. let pyear = [];
  252. for(let i=this.startTime.getFullYear();i<=this.endTime.getFullYear(); i++){
  253. pyear.push(i)
  254. }
  255. this.listData.splice(0,1,pyear)
  256. }
  257. // this.dataCauser.month===
  258. if(true){
  259. let pmonth = [];
  260. let x_year = this.startTime.getFullYear();
  261. let xz_year= this.listData[0][this.listIndex[0].itemIndex];
  262. if(xz_year === x_year){
  263. for(let i=this.startTime.getMonth()+1;i<=12; i++){
  264. pmonth.push(i)
  265. }
  266. }else{
  267. // 不能大于endtime.
  268. if(xz_year >= this.endTime.getFullYear()){
  269. for(let i=1;i<=this.endTime.getMonth()+1; i++){
  270. pmonth.push(i)
  271. }
  272. }else{
  273. for(let i=1;i<=12; i++){
  274. pmonth.push(i)
  275. }
  276. }
  277. }
  278. this.listData.splice(1,1,pmonth)
  279. }
  280. // this.dataCauser.day===
  281. if(true){
  282. function monthDay(year, month) {
  283. var date = new Date(year, month, 1, 0, 0, 0)
  284. var yesterDay = new Date(date - 1000)
  285. return yesterDay.getDate()
  286. }
  287. let pday = [];
  288. let year = this.startTime.getFullYear();
  289. let xzyear = this.listData[0][this.listIndex[0].itemIndex];
  290. if(xzyear){
  291. year = xzyear;
  292. }
  293. let month = this.startTime.getMonth();
  294. let xzmonth = this.listData[1][this.listIndex[1].itemIndex]-1;
  295. if(xzmonth){
  296. month = xzmonth;
  297. }
  298. let months = [31,monthDay(year,month+1),31,30,31,30,31,31,30,31,30,31];
  299. if(year === this.startTime.getFullYear() && month === this.startTime.getMonth()){
  300. if(year == this.endTime.getFullYear()&&
  301. month == this.endTime.getMonth()+1
  302. ){
  303. for(let i=this.startTime.getDate();i<=this.endTime.getDate(); i++){
  304. pday.push(i)
  305. }
  306. }else{
  307. for(let i=this.startTime.getDate();i<=months[month]; i++){
  308. pday.push(i)
  309. }
  310. }
  311. }else{
  312. if(year >= this.endTime.getFullYear()&& month >= this.endTime.getMonth()){
  313. for(let i=1;i<=this.endTime.getDate(); i++){
  314. pday.push(i)
  315. }
  316. }else{
  317. for(let i=1;i<=months[month]; i++){
  318. pday.push(i)
  319. }
  320. }
  321. }
  322. this.listData.splice(2,1,pday)
  323. }
  324. // this.dataCauser.hour===
  325. if(true){
  326. let phour = [];
  327. let s_year = this.startTime.getFullYear();
  328. let o_year = this.listData[0][this.listIndex[0].itemIndex];
  329. let s_month = this.startTime.getMonth()+1;
  330. let o_month = this.listData[1][this.listIndex[1].itemIndex];
  331. let s_day = this.startTime.getDate();
  332. let o_day = this.listData[2][this.listIndex[2].itemIndex];
  333. // let s_hour = this.startTime.getMinutes();
  334. // let o_hour = this.listData[3][this.listIndex[3].itemIndex];
  335. if(s_year===o_year&&s_month===o_month&&s_day===o_day){
  336. if(s_year == this.endTime.getFullYear()&&
  337. s_month == this.endTime.getMonth()+1 &&
  338. s_day == this.endTime.getDate()
  339. ){
  340. for(let i=this.startTime.getHours();i<=this.endTime.getHours(); i++){
  341. phour.push(i)
  342. }
  343. }else{
  344. for(let i=this.startTime.getHours();i<24; i++){
  345. phour.push(i)
  346. }
  347. }
  348. }else{
  349. if(o_year >= this.endTime.getFullYear() && o_month >= this.endTime.getMonth()&& o_day >= this.endTime.getDate()){
  350. for(let i=0;i<=this.endTime.getHours(); i++){
  351. phour.push(i)
  352. }
  353. }else{
  354. for(let i=0;i<24; i++){
  355. phour.push(i)
  356. }
  357. }
  358. }
  359. this.listData.splice(3,1,phour)
  360. }
  361. // this.dataCauser.min===true
  362. if(true){
  363. let pmin = [];
  364. let s_year = this.startTime.getFullYear();
  365. let o_year = this.listData[0][this.listIndex[0].itemIndex];
  366. let s_month = this.startTime.getMonth()+1;
  367. let o_month = this.listData[1][this.listIndex[1].itemIndex];
  368. let s_day = this.startTime.getDate();
  369. let o_day = this.listData[2][this.listIndex[2].itemIndex];
  370. let s_hour = this.startTime.getHours();
  371. let o_hour = this.listData[3][this.listIndex[3].itemIndex];
  372. if(s_year===o_year&&s_month===o_month&&s_day===o_day&&s_hour===o_hour){
  373. if(s_year == this.endTime.getFullYear()&&
  374. s_month == this.endTime.getMonth()+1 &&
  375. s_day == this.endTime.getDate()&&
  376. s_hour == this.endTime.getHours()
  377. ){
  378. for(let i=this.startTime.getMinutes();i<=this.endTime.getMinutes(); i++){
  379. pmin.push(i)
  380. }
  381. }else{
  382. for(let i=this.startTime.getMinutes();i<60; i++){
  383. pmin.push(i)
  384. }
  385. }
  386. }else{
  387. if(o_year >= this.endTime.getFullYear() && o_month >= this.endTime.getMonth()&& o_day >= this.endTime.getDate() && o_hour >= this.endTime.getHours()){
  388. for(let i=1;i<=this.endTime.getMinutes(); i++){
  389. pmin.push(i)
  390. }
  391. }else{
  392. for(let i=0;i<60; i++){
  393. pmin.push(i)
  394. }
  395. }
  396. }
  397. this.listData.splice(4,1,pmin)
  398. }
  399. // this.dataCauser.sec===
  400. if(true){
  401. let psec = [];
  402. let s_year = this.startTime.getFullYear();
  403. let o_year = this.listData[0][this.listIndex[0].itemIndex];
  404. let s_month = this.startTime.getMonth()+1;
  405. let o_month = this.listData[1][this.listIndex[1].itemIndex];
  406. let s_day = this.startTime.getDate();
  407. let o_day = this.listData[2][this.listIndex[2].itemIndex];
  408. let s_hour = this.startTime.getHours();
  409. let o_hour = this.listData[3][this.listIndex[3].itemIndex];
  410. let s_min = this.startTime.getMinutes();
  411. let o_min = this.listData[4][this.listIndex[4].itemIndex];
  412. if(s_year===o_year&&s_month===o_month&&s_day===o_day&&s_hour===o_hour&&s_min===o_min){
  413. if(s_year == this.endTime.getFullYear()&&
  414. s_month == this.endTime.getMonth()+1 &&
  415. s_day == this.endTime.getDate()&&
  416. s_hour == this.endTime.getHours()&&
  417. s_min == this.endTime.getMinutes()
  418. ){
  419. for(let i=this.startTime.getSeconds();i<=this.endTime.getSeconds(); i++){
  420. psec.push(i)
  421. }
  422. }else{
  423. for(let i=this.startTime.getSeconds();i<60; i++){
  424. psec.push(i)
  425. }
  426. }
  427. }else{
  428. if(o_year >= this.endTime.getFullYear() && o_month >= this.endTime.getMonth()&& o_day >= this.endTime.getDate() && o_hour >= this.endTime.getHours()&& o_min >= this.endTime.getMinutes()){
  429. for(let i=1;i<=this.endTime.getSeconds(); i++){
  430. psec.push(i)
  431. }
  432. }else{
  433. for(let i=0;i<60; i++){
  434. psec.push(i)
  435. }
  436. }
  437. }
  438. this.listData.splice(5,1,psec)
  439. }
  440. return this.listData;
  441. },
  442. async setDefaultValue(date){
  443. let t = this;
  444. let mobj;
  445. if(date){
  446. mobj = new Date(date.replace(/-/g,'/'));
  447. }else{
  448. try{
  449. mobj = new Date(this.defaultValue.replace(/-/g,'/'));
  450. }catch(e){
  451. mobj = new Date();
  452. }
  453. if(!this.defaultValue || isNaN(mobj.getFullYear())){
  454. mobj = new Date();
  455. }
  456. }
  457. await uni.$tm.sleep(20)
  458. // this.dataCauser.year===
  459. if(true){
  460. let pyear = mobj.getFullYear();
  461. if(pyear <= this.startTime.getFullYear()){
  462. pyear = this.startTime.getFullYear()
  463. }else if(pyear >= this.endTime.getFullYear()){
  464. pyear = this.endTime.getFullYear()
  465. }
  466. let itemIndex = this.listData[0].indexOf(pyear)
  467. if(itemIndex>-1){
  468. this.$set(this.listIndex[0], 'itemIndex', itemIndex);
  469. this.$set(t.listIndex[0], 'wz', itemIndex * t.itemHeight);
  470. this.chulisdata();
  471. }
  472. }
  473. await uni.$tm.sleep(20)
  474. // this.dataCauser.month===
  475. if(true){
  476. let pmonth = mobj.getMonth()+1;
  477. if(mobj.getFullYear() <= this.startTime.getFullYear()&&pmonth <= this.startTime.getMonth()+1){
  478. pmonth = this.startTime.getMonth()+1
  479. }else if(mobj.getFullYear() >= this.endTime.getFullYear()&&pmonth >= this.endTime.getMonth()+1){
  480. pmonth = this.endTime.getMonth()+1
  481. }
  482. let itemIndex = this.listData[1].indexOf(pmonth)
  483. if(itemIndex>-1){
  484. this.chulisdata();
  485. this.$set(this.listIndex[1], 'itemIndex', itemIndex);
  486. this.$set(t.listIndex[1], 'wz', itemIndex * t.itemHeight-0.1);
  487. setTimeout(function() {
  488. t.$set(t.listIndex[1], 'wz', itemIndex * t.itemHeight);
  489. }, 10);
  490. }
  491. }
  492. await uni.$tm.sleep(20)
  493. // this.dataCauser.day===
  494. if(true){
  495. let pday = mobj.getDate();
  496. let pmonth = mobj.getMonth()+1;
  497. if(mobj.getFullYear() <= this.startTime.getFullYear()&&
  498. pmonth <= this.startTime.getMonth()+1&&
  499. pday <= this.startTime.getDate()
  500. ){
  501. pday = this.startTime.getDate()
  502. }else if(mobj.getFullYear() >= this.endTime.getFullYear()&&
  503. pmonth >= this.endTime.getMonth()+1&&
  504. pday >= this.endTime.getDate()
  505. ){
  506. pday = this.endTime.getDate()
  507. }
  508. let itemIndex = this.listData[2].indexOf(pday)
  509. if(itemIndex>-1){
  510. this.chulisdata();
  511. this.$set(this.listIndex[2], 'itemIndex', itemIndex);
  512. this.$set(t.listIndex[2], 'wz', itemIndex * t.itemHeight);
  513. }
  514. }
  515. await uni.$tm.sleep(20)
  516. // this.dataCauser.hour===
  517. if(true){
  518. let phour = mobj.getHours();
  519. let pday = mobj.getDate();
  520. let pmonth = mobj.getMonth()+1;
  521. if(mobj.getFullYear() <= this.startTime.getFullYear()&&
  522. pmonth <= this.startTime.getMonth()+1&&
  523. pday <= this.startTime.getDate()&&
  524. phour <= this.startTime.getHours()
  525. ){
  526. phour = this.startTime.getHours()
  527. }else if(mobj.getFullYear() >= this.endTime.getFullYear()&&
  528. pmonth >= this.endTime.getMonth()+1&&
  529. pday >= this.endTime.getDate()&&
  530. phour >= this.endTime.getHours()
  531. ){
  532. phour = this.endTime.getHours()
  533. }
  534. let itemIndex = this.listData[3].indexOf(phour)
  535. if(itemIndex>-1){
  536. this.chulisdata();
  537. this.$set(this.listIndex[3], 'itemIndex', itemIndex);
  538. this.$set(t.listIndex[3], 'wz', itemIndex * t.itemHeight);
  539. }
  540. }
  541. await uni.$tm.sleep(20)
  542. // this.dataCauser.min===
  543. if(true){
  544. let pmin = mobj.getMinutes();
  545. let phour = mobj.getHours();
  546. let pday = mobj.getDate();
  547. let pmonth = mobj.getMonth()+1;
  548. if(mobj.getFullYear() <= this.startTime.getFullYear()&&
  549. pmonth <= this.startTime.getMonth()+1&&
  550. pday <= this.startTime.getDate()&&
  551. phour <= this.startTime.getHours()&&
  552. pmin <= this.startTime.getMinutes()
  553. ){
  554. phour = this.startTime.getMinutes()
  555. }else if(mobj.getFullYear() >= this.endTime.getFullYear()&&
  556. pmonth >= this.endTime.getMonth()+1&&
  557. pday >= this.endTime.getDate()&&
  558. phour >= this.endTime.getHours()&&
  559. pmin >= this.endTime.getMinutes()
  560. ){
  561. phour = this.endTime.getMinutes()
  562. }
  563. let itemIndex = this.listData[4].indexOf(pmin)
  564. if(itemIndex>-1){
  565. this.$set(this.listIndex[4], 'itemIndex', itemIndex);
  566. this.$set(t.listIndex[4], 'wz', itemIndex * t.itemHeight);
  567. }
  568. }
  569. await uni.$tm.sleep(20)
  570. // this.dataCauser.sec===
  571. if(true){
  572. let psec = mobj.getSeconds();
  573. let pmin = mobj.getMinutes();
  574. let phour = mobj.getHours();
  575. let pday = mobj.getDate();
  576. let pmonth = mobj.getMonth()+1;
  577. if(mobj.getFullYear() <= this.startTime.getFullYear()&&
  578. pmonth <= this.startTime.getMonth()+1&&
  579. pday <= this.startTime.getDate()&&
  580. phour <= this.startTime.getHours()&&
  581. pmin <= this.startTime.getMinutes()&&
  582. psec <= this.startTime.getSeconds()
  583. ){
  584. psec = this.startTime.getMinutes()
  585. }else if(mobj.getFullYear() >= this.endTime.getFullYear()&&
  586. pmonth >= this.endTime.getMonth()+1&&
  587. pday >= this.endTime.getDate()&&
  588. phour >= this.endTime.getHours()&&
  589. pmin >= this.endTime.getMinutes()&&
  590. psec >= this.endTime.getSeconds()
  591. ){
  592. psec = this.endTime.getSeconds()
  593. }
  594. let itemIndex = this.listData[5].indexOf(psec)
  595. if(itemIndex>-1){
  596. this.$set(this.listIndex[5], 'itemIndex', itemIndex);
  597. this.$set(t.listIndex[5], 'wz', itemIndex * t.itemHeight);
  598. }
  599. }
  600. },
  601. setChildreIndex(index){
  602. this.childrenIndex = index;
  603. },
  604. scroll(e, index) {
  605. console.log(e);
  606. this.scrollEvent = e;
  607. this.scrollChildrenIndex = index;
  608. },
  609. jswid(){
  610. let wd =(this.gridNum-1)-2
  611. if(wd<=0) wd = 1;
  612. return 100/wd;
  613. },
  614. scrllEnd(e) {
  615. function monthDay(year, month) {
  616. var date = new Date(year, month, 1, 0, 0, 0)
  617. var yesterDay = new Date(date - 1000)
  618. return yesterDay.getDate()
  619. }
  620. if (!this.scrollEvent) return;
  621. let dNum = this.gridNum;
  622. let d;
  623. let t = this;
  624. let idb = 88;
  625. let idc = 884;
  626. let srcllTop = this.scrollEvent.detail.scrollTop ;
  627. if(srcllTop<=0){
  628. srcllTop = 0;
  629. }else if(srcllTop >= this.scrollEvent.detail.srcollHeigh){
  630. srcllTop = this.scrollEvent.detail.srcollHeigh;
  631. }
  632. d = Math.ceil((srcllTop - (this.itemHeight / 2)) / this.itemHeight);
  633. if(d>= t.listData[t.childrenIndex].length-1){
  634. d = t.listData[t.childrenIndex].length-1
  635. }
  636. t.$set(t.listIndex[t.childrenIndex], 'wz', srcllTop)
  637. let old_index = this.listIndex[this.childrenIndex].itemIndex || 0;
  638. if(t.disabled){
  639. clearTimeout(idb)
  640. idb = setTimeout(function() {
  641. t.$nextTick(function(){
  642. t.$set(t.listIndex[t.childrenIndex], 'wz', old_index * t.itemHeight)
  643. })
  644. }, 5);
  645. return;
  646. }
  647. this.$set(this.listIndex[t.childrenIndex], 'itemIndex', d)
  648. t.chulisdata();
  649. clearTimeout(idb);
  650. idb = setTimeout(function() {
  651. t.$nextTick(function(){
  652. t.$set(t.listIndex[t.childrenIndex], 'wz', d * t.itemHeight)
  653. for(let lsindex = t.childrenIndex+1;lsindex<6;lsindex++){
  654. if( t.listData[lsindex][t.listIndex[lsindex].itemIndex] == undefined){
  655. let pda = t.listData[lsindex].length-1;
  656. if(d>=pda){
  657. this.$set(this.listIndex[lsindex], 'itemIndex',pda)
  658. t.$set(t.listIndex[lsindex], 'wz', pda * t.itemHeight)
  659. }else{
  660. this.$set(this.listIndex[lsindex], 'itemIndex',0)
  661. t.$set(t.listIndex[lsindex], 'wz', 0)
  662. }
  663. }else{
  664. let srcllTop_s = t.listIndex[lsindex].wz;
  665. const tsdd = t.listIndex[lsindex].itemIndex;
  666. t.$set(t.listIndex[lsindex], 'wz', (tsdd) * t.itemHeight-1)
  667. this.$nextTick(function(){
  668. t.$set(t.listIndex[lsindex], 'wz', (tsdd) * t.itemHeight)
  669. })
  670. }
  671. }
  672. })
  673. }, 10);
  674. }
  675. },
  676. }
  677. </script>
  678. <style lang="scss" scoped>
  679. .tm-pickersDateView {
  680. .tm-pickersDateView-wk {
  681. position: relative;
  682. .tm-pickersDateView-showbg {
  683. position: absolute;
  684. left: 0;
  685. height: 0;
  686. z-index: 5;
  687. .tm-pickersDateView-item {
  688. .tm-pickersDateView-item-text {
  689. text {
  690. transition: all 0.5s;
  691. }
  692. &.textLevel_1 {
  693. text {
  694. font-size: 28upx !important;
  695. }
  696. }
  697. &.textLevel_2 {
  698. text {
  699. font-size: 26upx !important;
  700. }
  701. }
  702. }
  703. }
  704. }
  705. .tm-pickersDateView-fg {
  706. position: relative;
  707. z-index: 3;
  708. }
  709. }
  710. }
  711. </style>