// packageI/newMedia/components/rewardPopup/rewardPopup.js
var app = getApp();
Component({
  options: {
    addGlobalClass: true
  },
  /**
   * 组件的属性列表
   */
  properties: {
    show:{
      value:false,
      type:Boolean
    },
    details:{
      value:{},
      type:Object
    },
    reward_button:{
      value:{},
      type:Object
    }
  },

  /**
   * 组件的初始数据
   */
  data: {
    reward_type:"1",
    reward_number:'',
  },

  /**
   * 组件的方法列表
   */
  ready(){
    
  },
  methods: {
    closePopup(){
      this.triggerEvent("close");
    },
    bindChangeReward(evt){
      this.setData({reward_type:evt.detail});
    },

    sendReward(){
      let {reward_number,reward_type,details}=this.data;
      if(!reward_number || reward_number<=0) return app.tips("请输入打赏数量");
      let urlStr = app.getNetAddresss("plugin.new-media-advertising.frontend.media-advertisingt.reward");
      app._getNetWork({
        url: urlStr,
        data: {
          advertisingt_id: details.id,reward_number,reward_type
        },
        success: (resdata) => {
          var res = resdata.data;
          app.tips(res.msg);
          if (res.result != 1) return ;
          this.setData({
            reward_type:"1",
            reward_number:""
          });
          this.triggerEvent("close");
        }
      });
    }


  }
});
