//product js
export default{
  data(){
    return {
      ptoken:''
    };
  },
  mounted(){
    this.ptoken=onez.install_get().ptoken||'';
  },
  methods:{
    click(item){
      var that=this;
      if(item.type=='plugin'){
        onez.install_save({ptoken:item.ptoken,pname:item.name});
        this.$emit('next');
      }else if(item.type=='bs'){
        onez.install_save({ptoken:'bs',pname:'总平台'});
        this.$emit('next');
      }else if(item.type=='code'){
        layer.prompt({
          formType: 2,
          value: '',
          title: '请填写您在佳蓝官网获得的产品识别码'
        }, function(value, index, elem){
          onez.loading(true);
          that.post({ac:'code',ptoken:value},(res)=>{
            onez.loading(false);
            if(res.error){
              onez.alert(res.error);
            }else if(res.ptoken){
              layer.close(index);
              onez.install_save({ptoken:res.ptoken,pname:res.pname});
              this.$emit('next');
            }else{
              onez.alert('未知错误');
            }
          });
        });
      }
    },
    prev(){
      this.$emit('prev');
    },
    next(){
      this.$emit('next');
    }
  }
}