You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
123 lines
2.4 KiB
123 lines
2.4 KiB
// subpages/OCRCard/pages/index/index.js
|
|
const app = getApp()
|
|
Page({
|
|
|
|
/**
|
|
* 页面的初始数据
|
|
*/
|
|
data: {
|
|
scanAnimation: null,
|
|
type:null
|
|
},
|
|
|
|
/**
|
|
* 生命周期函数--监听页面加载
|
|
*/
|
|
onLoad(options) {
|
|
if(options.type){
|
|
this.setData({
|
|
type:options.type
|
|
})
|
|
}
|
|
this.setData({
|
|
statusHeight: app.globalData.deviceInfo.statusHeight,
|
|
navigationHeight: app.globalData.deviceInfo.navigationHeight,
|
|
})
|
|
},
|
|
|
|
/**
|
|
* 生命周期函数--监听页面初次渲染完成
|
|
*/
|
|
onReady() {
|
|
this.startScanAnimation();
|
|
|
|
},
|
|
|
|
/**
|
|
* 生命周期函数--监听页面显示
|
|
*/
|
|
onShow() {
|
|
|
|
},
|
|
|
|
/**
|
|
* 生命周期函数--监听页面隐藏
|
|
*/
|
|
onHide() {
|
|
|
|
},
|
|
|
|
/**
|
|
* 生命周期函数--监听页面卸载
|
|
*/
|
|
onUnload() {
|
|
|
|
},
|
|
|
|
/**
|
|
* 页面相关事件处理函数--监听用户下拉动作
|
|
*/
|
|
onPullDownRefresh() {
|
|
|
|
},
|
|
|
|
/**
|
|
* 页面上拉触底事件的处理函数
|
|
*/
|
|
onReachBottom() {
|
|
|
|
},
|
|
|
|
/**
|
|
* 用户点击右上角分享
|
|
*/
|
|
onShareAppMessage() {
|
|
|
|
},
|
|
|
|
cardSuccess: async function(e){
|
|
console.log(e.detail);
|
|
|
|
},
|
|
back(){
|
|
wx.navigateBack({
|
|
delta: 1
|
|
})
|
|
},
|
|
startScanAnimation() {
|
|
const that = this;
|
|
const maxY = 220; // 卡片高度 - 扫描线高度,具体看视觉需求
|
|
|
|
function loopScan() {
|
|
// 从顶部到底部动画
|
|
const downAnim = wx.createAnimation({
|
|
duration: 2000,
|
|
timingFunction: 'linear',
|
|
});
|
|
downAnim.translateY(maxY).step();
|
|
|
|
that.setData({
|
|
scanAnimation: downAnim.export()
|
|
});
|
|
|
|
// 动画结束后,停一下然后回顶
|
|
setTimeout(() => {
|
|
const resetAnim = wx.createAnimation({
|
|
duration: 0,
|
|
timingFunction: 'step-start',
|
|
});
|
|
resetAnim.translateY(0).step();
|
|
|
|
that.setData({
|
|
scanAnimation: resetAnim.export()
|
|
});
|
|
|
|
// 再次循环
|
|
setTimeout(loopScan, 100);
|
|
}, 2000); // 等扫完后回顶
|
|
}
|
|
|
|
loopScan(); // 启动动画
|
|
}
|
|
|
|
})
|