Commit de113e02 by 李伟康

commit 修复BUG

1 parent b0b66b51
......@@ -2,6 +2,7 @@
"dependencies": {
"@vant/area-data": "^1.5.1",
"@vant/weapp": "^1.10.24",
"dayjs": "^1.11.11",
"glsk-applet-component": "^1.0.0",
"glsx-applet-component": "^1.1.29",
"glsx-common-sdk": "^0.2.8",
......
// packageEquity/pages/aiInspection/components/dateBox/dateBox.js
import dayjs from 'dayjs'
const defaultDay = new Date().setDate(new Date().getDate() - 1)
Component({
......@@ -26,6 +27,7 @@ Component({
*/
methods: {
init() {
wx.$util.showLoading()
const now = new Date().format('yyyy/MM/dd'),
calendar = this.selectComponent('#calendar')
this.setData({
......@@ -35,33 +37,33 @@ Component({
currentDayTime: new Date(defaultDay).getTime()
})
calendar.resetData(new Date(defaultDay).format('yyyy-MM-dd'))
wx.$util.hideLoading()
},
selectDay(e) {
let {
date
} = e.detail,
currentDay = new Date(date.replace(/-/g, '/'))
} = e.detail
let currentDay = dayjs(date)
this.setData({
currentDay: currentDay.format('yyyy年MM月dd日'),
currentDayTime: currentDay.getTime(),
currentDay: currentDay.format('YYYY年MM月DD日'),
currentDayTime: currentDay.valueOf(),
}, () => {
this.triggerEvent('change', date)
this.selectComponent('#calendar').resetData(date)
wx.$util.hideLoading()
})
this.triggerEvent('change', date)
this.selectComponent('#calendar').resetData(date)
},
choose(e) {
const {
wx.$util.showLoading()
let {
index
} = e.target.dataset, {
currentDayTime
} = this.data
let currentDay = new Date(currentDayTime)
currentDay.setDate(currentDay.getDate() + Number(index))
let y = currentDay.getFullYear(),
m = currentDay.getMonth() + 1 < 10 ? `0${currentDay.getMonth() + 1}` : currentDay.getMonth() + 1,
d = currentDay.getDate() < 10 ? `0${currentDay.getDate()}` : currentDay.getDate()
currentDayTime
} = this.data,
date = dayjs(currentDayTime).add(Number(index), 'day').format('YYYY-MM-DD')
this.selectDay({
detail: {
date: `${y}-${m}-${d}`
date
}
})
},
......
<view class="date-box">
<block wx:if="{{minTime != currentDayTime}}">
<view class="date-btn" bindtap="choose" data-index="-1">
<gl-image class="icon" src="/equity/arrow-left.png" />
<gl-image data-index="-1" class="icon" src="/equity/arrow-left.png" />
上一天
</view>
</block>
......@@ -12,7 +12,7 @@
<block wx:if="{{maxDateTime != currentDayTime}}">
<view class="date-btn next" bindtap="choose" data-index="1">
下一天
<gl-image class="icon" src="/equity/arrow-right.png" />
<gl-image class="icon" data-index="1" src="/equity/arrow-right.png" />
</view>
</block>
</view>
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!