helpPopup.js 2.91 KB
// packageWorkspace/pages/performanceRating/components/helpPopup/helpPopup.js
const IMG_URL = 'https://img02.glsx.com.cn/weapp/resource/miniprogram/regional-assistant/'
Component({

  /**
   * 组件的属性列表
   */
  properties: {
    show: {
      type: Boolean, //目前接受的类型包括:String, Number, Boolean, Object, Array, null(表示任意类型)
      value: false, // 默认值
      observer(newVal, oldVal) {
        if (newVal) {
          this.createMaskAnimate(true)
        } else {
          this.createMaskAnimate(false)
        }
      }
    },
  },

  /**
   * 组件的初始数据
   */
  data: {
    IMG_URL,
    helpContents: [{
      title: '底薪',
      value: '底薪=工资标准 / 应出勤天数×实际出勤天数×70%'
    }, {
      title: '绩效工资',
      value: '绩效工资=工资标准 / 应出勤天数 × 实际出勤天数 × 30% × 绩效系数(如有手动维护绩效工资,则取最终手工维护的绩效金额)'
    }, {
      title: '基本工资',
      value: '基本工资=底薪+绩效工资'
    }, {
      title: '手动维护最终绩效金额',
      value: '手动维护最终绩效金额字段大于等级字段'
    }],
    maskAnimate: [],
    frameAnimate: [],
  },

  /**
   * 组件的方法列表
   */
  methods: {
    close() {
      this.setData({
        show: !this.data.show
      })
    },
    //动画-遮罩层淡入淡出
    createMaskAnimate(currentStatu) {
      if (currentStatu) {
        this.setData({
          _show: currentStatu
        })
        this.createframeAnimate(true)
      } else {
        setTimeout(() => {
          this.setData({
            _show: false
          })
        }, 300)
        this.createframeAnimate(false)
      }
      let maskAnimate = wx.createAnimation({
        duration: 300,
        timingFunction: 'ease-in-out',
        delay: 0
      })
      this.maskAnimate = maskAnimate
      maskAnimate.opacity(currentStatu ? 0.7 : 0).step()
      setTimeout(() => {
        this.setData({
          maskAnimate: maskAnimate.export()
        })
      }, 50)
    },
    //动画-弹层内容Q弹
    createframeAnimate(currentStatu) {
      // return
      let frameAnimate = wx.createAnimation({
        duration: 300,
        timingFunction: 'ease',
        delay: 0
      })
      this.frameAnimate = frameAnimate
      frameAnimate
        .translate('-50%', '-50%')
        .opacity(currentStatu ? 0.5 : 1)
        .step()
      // .scale(currentStatu ? 1.05 : 1)
      this.setData({
        frameAnimate: frameAnimate.export()
      })
      setTimeout(() => {
        // 执行第二组动画
        frameAnimate
          .opacity(currentStatu ? 1 : 0)
          .scale(currentStatu ? 1 : 0.9)
          .step()
        // 给数据对象储存的第一组动画,更替为执行完第二组动画的动画对象
        this.setData({
          frameAnimate: frameAnimate.export()
        })
      }, 150)
    }
  }
})