// packagecard/sharePage/cardcode.js
const app = getApp()
Page({

    /**
     * 页面的初始数据
     */
    data: {
        imgUrl: app.urls.baseImgUrl,
        animationData: {},
        cardImg: '',
        id: '',
        contentHeight: app.globalData.windowHeight,
        translateUp: {}, //上平移
        translateDown: {}, //下移
        animDuration: 800,
    },

    /**
     * 生命周期函数--监听页面加载
     */
    onLoad: function (options) {
        this.setData({
            cardImg: options.cardImg,
            id: options.id
        })

    },
    onReady() {
        var _self = this
        this.setData({
            animationData: {},
            translateDown: {},
            translateUp: {}
        })
        var rotate = wx.createAnimation({
            duration: _self.data.animDuration,
            timingFunction: 'linear',
            transformOrigin: '50% 50% 0'
        })
        rotate.rotate(180).step()
        //上移
        var trUp = wx.createAnimation({
            duration: _self.data.animDuration,
            timingFunction: 'linear',
            transformOrigin: '50% 50% 0'
        })
        trUp.translateY(160).step()
        //下移
        var trDown = wx.createAnimation({
            duration: _self.data.animDuration,
            timingFunction: 'linear',
            transformOrigin: '50% 50% 0'
        })
        trDown.translateY(-160).step()
        this.setData({
            animationData: rotate.export(),
        })

        setTimeout(() => {
            _self.setData({
                translateUp: trUp.export(),
                translateDown: trDown.export()
            })
        }, _self.data.time);
    }
})