您好,登錄后才能下訂單哦!
這篇文章主要介紹了微信小程序日歷插件怎么實(shí)現(xiàn)的相關(guān)知識,內(nèi)容詳細(xì)易懂,操作簡單快捷,具有一定借鑒價(jià)值,相信大家閱讀完這篇微信小程序日歷插件怎么實(shí)現(xiàn)文章都會有所收獲,下面我們一起來看看吧。
微信小程序的日歷插件,主要針對酒店選擇時(shí)間段的日歷,帶有公歷的節(jié)日。
主要函數(shù):
通過選擇入住與離店時(shí)間,記錄對應(yīng)的時(shí)間段,判斷選擇的開始時(shí)間和結(jié)束時(shí)間,通過改變背影顏色連成對應(yīng)時(shí)間段。
selectDataMarkLine: function () { let dateList = this.data.dateList; let { checkInDate, checkOutDate } = wx.getStorageSync("ROOM_SOURCE_DATE"); let curreInid = checkInDate.substr(0, 4) + "-" + (checkInDate.substr(5, 2) < 10 ? checkInDate.substr(6, 1) : checkInDate.substr(5, 2));//選擇入住的id let curreOutid = checkOutDate.substr(0, 4) + "-" + (checkOutDate.substr(5, 2) < 10 ? checkOutDate.substr(6, 1) : checkOutDate.substr(5, 2));//選擇離店的id let dayIn = checkInDate.substr(8, 2) >= 10 ? checkInDate.substr(8, 2) : checkInDate.substr(9, 1);//選擇入住的天id let dayOut = checkOutDate.substr(8, 2) >= 10 ? checkOutDate.substr(8, 2) : checkOutDate.substr(9, 1);//選擇離店的天id let monthIn = checkInDate.substr(5, 2) >= 10 ? checkInDate.substr(5, 2) : checkInDate.substr(6, 1);//選擇入店的月id let monthOut = checkOutDate.substr(5, 2) >= 10 ? checkOutDate.substr(5, 2) : checkOutDate.substr(6, 1);//選擇離店的月id if (curreInid == curreOutid) {//入住與離店是當(dāng)月的情況 for (let i = 0; i < dateList.length; i++) { if (dateList[i].id == curreInid) { let days = dateList[i].days; for (let k = 0; k < days.length; k++) { if (days[k].day >= dayIn && days[k].day <= dayOut) { days[k].class = days[k].class + ' bgitem'; } if (days[k].day == dayIn) { days[k].class = days[k].class + ' active'; days[k].inday = true; } if (days[k].day == dayOut) { days[k].class = days[k].class + ' active'; days[k].outday = true; } } } } } else {//跨月 for (let j = 0; j < dateList.length; j++) { if (dateList[j].month == monthIn) {//入住的開始月份 let days = dateList[j].days; for (let k = 0; k < days.length; k++) { if (days[k].day >= dayIn) { days[k].class = days[k].class + ' bgitem'; } if (days[k].day == dayIn) { days[k].class = days[k].class + ' active'; days[k].inday = true; } } } else {//入住跨月月份 if (dateList[j].month < monthOut) {//離店中間的月份 let days = dateList[j].days; for (let k = 0; k < days.length; k++) { days[k].class = days[k].class + ' bgitem'; } } else if (dateList[j].month == monthOut) {//離店最后的月份 let days = dateList[j].days; for (let k = 0; k < days.length; k++) { if (days[k].day <= dayOut) { days[k].class = days[k].class + ' bgitem'; } if (days[k].day == dayOut) { days[k].class = days[k].class + ' active'; days[k].outday = true; } } } } } } this.setData({ dateList: dateList }) },
關(guān)于“微信小程序日歷插件怎么實(shí)現(xiàn)”這篇文章的內(nèi)容就介紹到這里,感謝各位的閱讀!相信大家對“微信小程序日歷插件怎么實(shí)現(xiàn)”知識都有一定的了解,大家如果還想學(xué)習(xí)更多知識,歡迎關(guān)注億速云行業(yè)資訊頻道。
免責(zé)聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀點(diǎn)不代表本網(wǎng)站立場,如果涉及侵權(quán)請聯(lián)系站長郵箱:is@yisu.com進(jìn)行舉報(bào),并提供相關(guān)證據(jù),一經(jīng)查實(shí),將立刻刪除涉嫌侵權(quán)內(nèi)容。