// shoppingGuid/page/pages/couponQrcode/couponQrcode.js
const wxService = require('../../../../utils/wxService')
const app = getApp();

wxService.page({

  /**
   * 页面的初始数据
   */
  data: {
    qrcodeImg : '',
    couponInfo : {}
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    let couponInfo = wx.getStorageSync('_guidCouponInfo');
    this.setData({
      couponInfo: couponInfo,
    },() => {
      this.getMiniQrcode(couponInfo.id);
    })
    
  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {

  },
  //获取小程序码
  getMiniQrcode(id){
    // subPackage / page / pages / scanCoupon / scanCoupon
    let data = {
      "autoColor": true,
      "page": 'pages/index/index',
      "scene": 'id=' + id,
      "width": 260
    }

    wxService.post(`/marketing/quickMark/getAppQrCodePicture`, data).then(res => {
      const { result, data } = res.data
      if (result == 0) {
        this.setData({
          qrcodeImg: app.globalData.imageUrl + data
        });
      }
    })
  },
 
})