// pages/components/blocks/goods_item/goods_item.js
const proxy = require("../../../../Proxy.js");

Component({
  /**
   * 组件的属性列表
   */
  properties: {
    goods_item: {
      type: Object
    },
    summery: {
      type: Array
    }
  },
  attached() {
    let goods_id = this.properties.goods_item.data;
    let summery = this.properties.summery;
    let getSummeryGoods = proxy.getSummeryGoods(goods_id, summery);
    let discounts_price = ((getSummeryGoods.goods_price) - (getSummeryGoods.bonus_price)).toFixed(2);
    let goods = Object.assign(
      {},
      getSummeryGoods,
      {
        discounts: discounts_price,
        bonus_price: parseFloat(getSummeryGoods.bonus_price),
        goods_price: parseFloat(getSummeryGoods.goods_price),
        goods_lowest_price: parseFloat(getSummeryGoods.goods_lowest_price),
        goods_promotion_price: parseFloat(getSummeryGoods.goods_promotion_price)
      }
    )
    // console.log('goods:', goods);
    this.setData({
      goods
    })
  },

  /**
   * 组件的初始数据
   */
  data: {
    goods: null
  },

  /**
   * 组件的方法列表
   */
  methods: {

  }
})
