diff --git a/components/timecomponentHome/index.js b/components/timecomponentHome/index.js new file mode 100644 index 0000000..9739444 --- /dev/null +++ b/components/timecomponentHome/index.js @@ -0,0 +1,58 @@ +import moment from "moment" +const app = getApp() +Component({ + data: { + timelist: [], + sStartTime: '', + sEndTime: '', + sTimeType: '34', + intervalSel: 0, + }, + lifetimes: { + attached() { + this.getData().then(() => { + let st = wx.getStorageSync('sTimeType2') || '' + if (st) { + let n = this.data.timelist.findIndex(ele => ele.key == st); + this.setData({ + intervalSel: n + }) + } else { + wx.setStorageSync('sTimeType2', 34); + // wx.setStorageSync('sStartTime', ''); + // wx.setStorageSync('sEndTime', ''); + } + }) + } + }, + methods: { + getData() { + return new Promise((resolve, reject) => { + app.globalData.request({ + action: "getTime" + }).then(res => { + let arr = res || []; + this.setData({ + timelist: arr + }) + resolve(true) + }) + }) + }, + priceSel(e) { + let row = e.currentTarget.dataset.row; + let n = this.data.timelist.findIndex(ele => ele.key == row.key); + this.setData({ + intervalSel: n + }) + wx.setStorageSync('sTimeType2', row.key); + let start = ""; + let end = ""; + this.triggerEvent('change', { + sTimeType: row.key, + sStartTime: start, + sEndTime: end + }) + } + } +}) \ No newline at end of file diff --git a/components/timecomponentHome/index.json b/components/timecomponentHome/index.json new file mode 100644 index 0000000..fba482a --- /dev/null +++ b/components/timecomponentHome/index.json @@ -0,0 +1,3 @@ +{ + "component": true +} \ No newline at end of file diff --git a/components/timecomponentHome/index.wxml b/components/timecomponentHome/index.wxml new file mode 100644 index 0000000..64c016e --- /dev/null +++ b/components/timecomponentHome/index.wxml @@ -0,0 +1,4 @@ + + {{item.value}} + + \ No newline at end of file diff --git a/components/timecomponentHome/index.wxss b/components/timecomponentHome/index.wxss new file mode 100644 index 0000000..e3ce262 --- /dev/null +++ b/components/timecomponentHome/index.wxss @@ -0,0 +1,46 @@ +.timelist { + height: 80rpx; + line-height: 80rpx; + margin:0 auto; + display: flex; + flex-wrap: nowrap; + background: white; + justify-content:space-between; + padding-left: 8rpx; + padding-right: 8rpx; + margin-top: 32rpx; + border-radius: 8rpx; +} + +.timelist view { + text-align: center; + color: #999999; + font-size: 24rpx; + width: 25%; +} + +.timelist .active { + color: #027AFF; + background-color: #f9f9f9; + font-weight: bolder; + width: 166rpx; + height: 64rpx; + line-height: 64rpx; + margin-top: 8rpx; + border-radius: 4rpx; +} +.tc-d-t { + font-size: 14px; + padding: 15px 0px; + color: #909497; + text-align: center; +} +.tp-btn { + color: #fff; + background: #1B89FA; + text-align: center; + font-size: 14px; + height: 36px; + line-height: 36px; + font-weight: 500; +} \ No newline at end of file