// packageD/member/myOrder/refund/components/returnTypePop/returnTypePop.js
var app = getApp();
Component({
  /**
   * 组件的属性列表
   */
  properties: {
    goodsList:{
      type:Array,
      value:[]
    }
  },

  /**
   * 组件的初始数据
   */
  data: {
    popShow:false,
    returnGoodsModels:[]
  },

  /**
   * 组件的方法列表
   */
  methods: {
    setPopShow(){
      this.setData({
        popShow:!this.data.popShow
      });
    },
    onChange(event) {
      this.setData({
        returnGoodsModels: event.detail,
      });
    },
    sendBtn(){
      if(this.data.returnGoodsModels.length<1) return app.tips("请选择商品");
      let modelsArr=[];
      let total_price=0;
      this.data.goodsList.forEach(item => {
        if(this.data.returnGoodsModels.indexOf(item.id+"")!=-1){
          let o={};
          o.goods_thumb = item.thumb;
          o.goods_title = item.title;
          o.refund_total = item.stepperValue;
          o.id = item.id;
          o.goods_option_title = item.goods_option_title;
          o.refund_price= ((Number(item.payment_amount)/item.total).toFixed(2))*item.stepperValue;
          total_price += o.refund_price;
          modelsArr.push(o);
        }
      });
      this.triggerEvent('confirm',{modelsArr,total_price});
      this.setPopShow();
    }
  
  }
});
