feat: 首次提交
This commit is contained in:
66
components/firstui/fui-slide-verify/mpjs.js
Normal file
66
components/firstui/fui-slide-verify/mpjs.js
Normal file
@ -0,0 +1,66 @@
|
||||
// 本文件由FirstUI授权予新疆天衡创新研究院有限公司(手机号: 1 8 6 14 07 2549,身份证尾号:5A07X5)专用,请尊重知识产权,勿私下传播,违者追究法律责任。
|
||||
// #ifndef APP-PLUS || MP-WEIXIN || H5
|
||||
export default {
|
||||
data() {
|
||||
return {
|
||||
transform: '',
|
||||
fwidth: 0,
|
||||
startX: 0,
|
||||
lastLeft: 0,
|
||||
resetAni: false
|
||||
}
|
||||
},
|
||||
watch: {
|
||||
resetNum(val) {
|
||||
this.startX = 0;
|
||||
this.lastLeft = 0;
|
||||
this.styleChange(0)
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
styleChange(left) {
|
||||
if (left == 0) {
|
||||
this.resetAni = true
|
||||
} else {
|
||||
this.resetAni = false
|
||||
}
|
||||
this.fwidth = left
|
||||
this.transform = 'translate3d(' + left + 'px,0,0)'
|
||||
},
|
||||
touchstart(e) {
|
||||
let touch = e.touches[0] || e.changedTouches[0];
|
||||
this.startX = touch.clientX
|
||||
},
|
||||
touchmove(e) {
|
||||
if (this.isPass) return;
|
||||
let touch = e.touches[0] || e.changedTouches[0]
|
||||
let pageX = touch.clientX;
|
||||
let left = pageX - this.startX + this.lastLeft;
|
||||
left = left < 0 ? 0 : left;
|
||||
let width = this.totalWidth - this.sliderW;
|
||||
left = left >= width ? width : left;
|
||||
this.startX = pageX
|
||||
this.lastLeft = left
|
||||
this.styleChange(left)
|
||||
},
|
||||
touchend(e) {
|
||||
if (this.isPass) return;
|
||||
let left = this.targetWidth - this.sliderW
|
||||
if (Math.abs(left - this.lastLeft) <= Number(this.range)) {
|
||||
// this.styleChange(left)
|
||||
this.success()
|
||||
} else {
|
||||
this.startX = 0;
|
||||
this.lastLeft = 0;
|
||||
this.styleChange(0)
|
||||
this.fail()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// #endif
|
||||
|
||||
// #ifdef APP-PLUS|| MP-WEIXIN || H5
|
||||
export default {}
|
||||
// #endif
|
Reference in New Issue
Block a user