触屏时间控制

// pages/youxi/dian1.js
Page({

/**
* 页面的初始数据
*/
data: {
bian: 0,
zhuan: 0,
textTure: 'touchstart'
},
shiFN: function (e) {
let that = this;
let n = 0;
// 判断是开始还是结束的参数
let textTure = e.type;
that.setData({
textTure: textTure
})
if (textTure == 'touchstart') {
let lovetime = setInterval(function () {
n += 0.5;

if (that.data.textTure == 'touchend') {
clearInterval(lovetime);
}
console.log(n);
that.setData({
bian: n
})
}, 500)

}
},

})
 
 
 
 
 
 
 
 
<view class='yx-box'>
<view class='yx-content'>
<view>{{bian}}</view>
</view>
<view class='bt flexca'>
<view class='bt-item' bindtouchend='shiFN' bindtouchstart='shiFN'></view>
</view>
</view>
 
 
 
 
page {
width: 100%;
height: 100%;
}

.yx-box {
width: 100%;
height: 100%;
">red;
position: relative;
padding-bottom: 60px;
}

.bt {
width: 100%;
height: 60px;
position: fixed;
left: 0;
bottom: 0;
}

.bt-item {
width: 45px;
height: 45px;
">blue;
border-radius: 50%;
}

.yx-content {
width: 100%;
height: 100%;
">gray;
}
 
posted @ 2018-01-31 21:54  ThisCall  阅读(134)  评论(0编辑  收藏  举报