Commit cb85460e by liang ce

修改二次点击

parent f9209f50
......@@ -87,5 +87,5 @@
</block>
</block>
</scroll-view>
<view class="createSchedule iconfont iconjiahao " onTap="{{!isClicked?'nextPage':''}}">
<view class="createSchedule iconfont iconjiahao " onTap="nextPage">
</view>
import { getHomeUserSchedule } from '../../api/request.js'
import { isClicked } from './../../utils/utils.js'
import { throttle } from './../../utils/utils.js'
Page({
data: {
AllScheduleList: [],
......@@ -40,7 +40,6 @@ Page({
const today = new Date()
const finalDate = new Date(today)
finalDate.setDate(today.getDate() - today.getDay())
console.log(finalDate.toLocaleDateString())
that.setData({
scheduleList: scheduleList,
todayStr: finalDate.toLocaleDateString(),
......@@ -241,15 +240,17 @@ Page({
path: 'pages/index/index',
};
},
nextPage() {
isClicked(this)
dd.navigateTo({ url: './../createOrEditSchedule/createOrEditSchedule' })
},
nextDetail(e) {
isClicked(this)
// nextPage() {
// isClicked(this)
// dd.navigateTo({ url: './../createOrEditSchedule/createOrEditSchedule' })
// },
nextDetail: throttle(function (e) {
let item = e.target.dataset.item
dd.navigateTo({ url: `./../scheduleDetail/scheduleDetail?scheduleItem=${JSON.stringify(item)}` })
},
}, 1000),
nextPage: throttle(function (e) {
dd.navigateTo({ url: './../createOrEditSchedule/createOrEditSchedule' })
}, 1000),
lower() {
let year = this.data.maxYear + 1
let DateList = this.returnScheduleList(year)
......
// 防止二次点击
export function isClicked(self) {
self.setData({
isClicked: true
})
setTimeout(function () {
self.setData({
isClicked: false
})
}, 500)
//防止多次重复点击 (函数节流)
export function throttle(fn, gapTime) {
if (gapTime == null || gapTime == undefined) {
gapTime = 1500
}
let _lastTime = null
return function () {
let _nowTime = + new Date()
if (_nowTime - _lastTime > gapTime || !_lastTime) {
fn()
_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