Commit de113e02 by 李伟康

commit 修复BUG

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