//paybox js
export default{
  data(){
    return {
    };
  },
  mounted(){
    new QRCode(this.$refs.billImage,location.href+'&pay=1');
    //onez.data(this,['items']);
    /*
    onez.api(this,'bs.pay:qrcode',{
      subject:'购买'+this.data.name,
      price:this.data.price,
      proId:this.data.id,
      sitetoken:'bs.app.shipments',
      goto:'/index/view.php?id='+this.data.id,
      token:'product',
      type:'product'
    }).then((r)=>{
      if(r[0]){
        new QRCode(this.$refs.billImage,r[1]);
      }else{
        onez.tip(r[1]);
      }
    });
    */
  },
  methods:{
    pay(){
      onez.api(this,'bs.pay:pay',{
        subject:'购买'+this.data.name,
        price:this.data.price,
        proId:this.data.id,
        nickname:this.data.myname,
        sitetoken:'bs.app.shipments',
        goto:'/index/view.php?id='+this.data.id,
        token:'product',
        type:'product'
      }).then((r)=>{
        if(r[0]){
        }else{
          onez.alert(r[1]);
          //this.$root.reload();
        }
      });
    },
    read(){
      var that=this;
      layer.prompt({
        formType: 1,
        value: '',
        title: '请输入阅读码'
      }, function(value, index, elem){
        that.$parent.post({ac:'read',code:value},(res)=>{
          if(res.error){
            onez.alert(res.error);
          }else{
            layer.close(index);
            that.$root.reload();
          }
        });
      });
    }
  }
}