CrowdfundPoster.js 1.42 KB
// packageOutput/pages/summary/components/CrowdfundPoster/CrowdfundPoster.js
import Draw from '~/utils/Draw'

Component({
  /**
   * 组件的属性列表
   */
  properties: {
    item: {
      type: Object,
      observer(n) {
        console.log(n, '=================')
        this.init(n)
      }
    }
  },

  /**
   * 组件的初始数据
   */
  data: {

  },

  /**
   * 组件的方法列表
   */
  methods: {
    async init(n) {
      wx.$api.showLoading()
      const drawfun = new Draw({
          width: 279,
          height: 554
        }, this),
        {
          userInfo
        } = wx.$storage.get(),
      res = await drawfun.begin({
        imageList: [{
            x: 0,
            y: 0,
            width: 279,
            height: 66,
            url: 'https://img02.glsx.com.cn/weapp/resource/saas/business-assistant/output/poster-bg.png'
          },
          {
            x: 16,
            y: 70,
            width: 247,
            height: 472,
            url: n.posterUrl
          }
        ],
        textList: [{
          x: 12,
          y: 14,
          fontSize: 14,
          color: '#2D2D33',
          text: userInfo.merchantName,
          textBaseline:'top'
        }]
      })
      console.log(res)
      wx.hideLoading()
      this.setData({
        poster: res.path,
        show: true
      })
    },
    hide() {
      this.setData({
        show: false,
        poster: ''
      })
    }
  }
})