Commit cb85460e by liang ce

修改二次点击

parent f9209f50
...@@ -87,5 +87,5 @@ ...@@ -87,5 +87,5 @@
</block> </block>
</block> </block>
</scroll-view> </scroll-view>
<view class="createSchedule iconfont iconjiahao " onTap="{{!isClicked?'nextPage':''}}"> <view class="createSchedule iconfont iconjiahao " onTap="nextPage">
</view> </view>
import { getHomeUserSchedule } from '../../api/request.js' import { getHomeUserSchedule } from '../../api/request.js'
import { isClicked } from './../../utils/utils.js' import { throttle } from './../../utils/utils.js'
Page({ Page({
data: { data: {
AllScheduleList: [], AllScheduleList: [],
...@@ -40,7 +40,6 @@ Page({ ...@@ -40,7 +40,6 @@ Page({
const today = new Date() const today = new Date()
const finalDate = new Date(today) const finalDate = new Date(today)
finalDate.setDate(today.getDate() - today.getDay()) finalDate.setDate(today.getDate() - today.getDay())
console.log(finalDate.toLocaleDateString())
that.setData({ that.setData({
scheduleList: scheduleList, scheduleList: scheduleList,
todayStr: finalDate.toLocaleDateString(), todayStr: finalDate.toLocaleDateString(),
...@@ -241,15 +240,17 @@ Page({ ...@@ -241,15 +240,17 @@ Page({
path: 'pages/index/index', path: 'pages/index/index',
}; };
}, },
nextPage() { // nextPage() {
isClicked(this) // isClicked(this)
dd.navigateTo({ url: './../createOrEditSchedule/createOrEditSchedule' }) // dd.navigateTo({ url: './../createOrEditSchedule/createOrEditSchedule' })
}, // },
nextDetail(e) { nextDetail: throttle(function (e) {
isClicked(this)
let item = e.target.dataset.item let item = e.target.dataset.item
dd.navigateTo({ url: `./../scheduleDetail/scheduleDetail?scheduleItem=${JSON.stringify(item)}` }) dd.navigateTo({ url: `./../scheduleDetail/scheduleDetail?scheduleItem=${JSON.stringify(item)}` })
}, }, 1000),
nextPage: throttle(function (e) {
dd.navigateTo({ url: './../createOrEditSchedule/createOrEditSchedule' })
}, 1000),
lower() { lower() {
let year = this.data.maxYear + 1 let year = this.data.maxYear + 1
let DateList = this.returnScheduleList(year) let DateList = this.returnScheduleList(year)
......
// 防止二次点击 //防止多次重复点击 (函数节流)
export function isClicked(self) { export function throttle(fn, gapTime) {
self.setData({ if (gapTime == null || gapTime == undefined) {
isClicked: true gapTime = 1500
}) }
setTimeout(function () {
self.setData({ let _lastTime = null
isClicked: false return function () {
}) let _nowTime = + new Date()
}, 500) if (_nowTime - _lastTime > gapTime || !_lastTime) {
} fn()
\ No newline at end of file _lastTime = _nowTime
}
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment