const util = require("../../utils/util.js");
const app = getApp();
Component({
  properties: {
    type: {
      type: Number,
      observer: function (newVal, oldVal) {
        this.setData({ type: newVal });
      }
    },
    orderid: {
      type: String,
      observer: function (newVal, oldVal) {
        this.setData({ orderid: newVal });
      }
    },
    groupid: {
      type: String,
      observer: function (newVal, oldVal) {
        this.setData({ groupid: newVal });
      }
    },
    aid: {
      type: String,
      observer: function (newVal, oldVal) {
        this.setData({ aid: newVal });
      }
    },
    sid:{
      type: Number,
      observer: function (newVal, oldVal) {
        this.setData({ sid: newVal });
      }
    },
    pid:{
      type: String,
      observer: function (newVal, oldVal) {
        this.setData({ pid: newVal });
      }
    },
    groupbook:{
      type: Number,
      observer: function (newVal, oldVal) {
        this.setData({ groupbook: newVal });
      }
    },
    channel: {
      type: Number,
      observer: function (newVal, oldVal) {
        this.setData({ channel: newVal });
      }
    },
    status: {
      type: Number,
      observer: function (newVal, oldVal) {
        this.setData({ status: newVal });
      }
    },
    channelTimes: {
      type: Number,
      observer: function (newVal, oldVal) {
        this.setData({ channelTimes: newVal });
      }
    },
    invitefbtn:{
      type: Boolean,
      observer: function (newVal, oldVal) {
        console.log(newVal, oldVal)
        this.setData({ invitefbtn: newVal });
      }
    },
    make:{
      type: Boolean,
      observer: function (newVal, oldVal) {
        this.setData({ make: newVal });
      }
    },
    to:{
      type: String,
      observer: function (newVal, oldVal) {
        this.setData({ toLink: newVal });
      }
    },
    bill:{
        type: Number,
        observer: function (newVal, oldVal) {
          this.setData({ bill: newVal });
        }
    }
  },
  data: {
    aid:'',
    sid:'',
    pid:'',
    groupid:'',
    orderid:'',
    status:0,
    type: 0,
    channel:0,
    channelTimes:0,
    groupbook:-1,
    invitefbtn:true,
    toLink:'',
    to:"",
    bill:0
  },
  pageLifetimes:{
    hide(){
      this.setData({ make: false });
    }
  },
  methods: {
    navigatorTo(e) {
        console.log(this.data.to);
        if(this.data.bill==1){
            wx.navigateTo({
              url: '/pages/growup/activePhoto/bill',
            })
            return
        }
      if (util.isEmpty(this.data.to)) {
        let channelinfo=this.data.channelTimes==1?('&channel='+this.data.channel+'&channelTimes='+this.data.channelTimes):'';
        util.navigator('/pages/product/activity/bill?id='+this.data.aid+
        '&orderid='+this.data.orderid+
        '&groupid='+this.data.groupid+
        '&status='+this.data.status+
        '&groupbook='+this.data.groupbook+
        channelinfo +
        '&sid='+this.data.sid+
        '&pid='+this.data.pid
        );
      }else{
        util.navigator(this.data.toLink);
      }
    
    },
    close() {
      console.log(this.data.invitefbtn)
      this.setData({ make: false });
    }
  }
})