// Learn TypeScript:
//  - https://docs.cocos.com/creator/2.4/manual/en/scripting/typescript.html
// Learn Attribute:
//  - https://docs.cocos.com/creator/2.4/manual/en/scripting/reference/attributes.html
// Learn life-cycle callbacks:
//  - https://docs.cocos.com/creator/2.4/manual/en/scripting/life-cycle-callbacks.html

import Common5 from "../../Platform/th/Common5";
import InterfaceManager from "../Manager/InterfaceManager";
import Wancheng from "./Wancheng";

const {ccclass, property} = cc._decorator;

@ccclass
export default class Fangbeibao extends cc.Component {

    @property(cc.Sprite)
    guwanNode: cc.Sprite = null;

    @property(cc.Label)
    priceLab: cc.Label = null;

    @property(cc.Label)
    nameLab: cc.Label = null;

    // LIFE-CYCLE CALLBACKS:

    // onLoad () {}
    parentnode:cc.Node
    targetNode:cc.Node
    start () {

    }

    setData(parentnode, targetNode){
        this.parentnode = parentnode
        this.targetNode = targetNode

        let goodsConfig = targetNode['GoodsConfig'] 
        let price = goodsConfig.buyPrice 
        let aaa = Common5.getNumberChangeHanzi( price ,'1')
        aaa = aaa as string
        this.priceLab.string = aaa
        
        let spr = goodsConfig.spriteArray + '/鉴定前'
       

        Common5.addUrlSprite_custom(spr, this.guwanNode)
        //this.nameLab.string = "古董"
    }

    fangruClick(){
        //Common5.playEffect("ui")
        if(this.parentnode){
            let wancheng:Wancheng = this.parentnode.getComponent('Wancheng')
            wancheng.fangruBeubao( this.targetNode )
        }
        this.node.removeFromParent()
    }
    
    jiandingClick(){
        //Common5.playEffect("ui")
        // InterfaceManager.upDataDayTaskProgress('Buygudong')
        if(this.parentnode){
            let wancheng:Wancheng = this.parentnode.getComponent('Wancheng')
            wancheng.jiandingLayerShow( this.targetNode )
        }
        this.node.removeFromParent()
    }
    closeClick(){
        //Common5.playEffect("ui")
        this.node.removeFromParent()
    }

    zichangClick(){
        //Common5.playEffect("ui")
        // if(this.parentnode){
        //     let wancheng:Wancheng = this.parentnode.getComponent('Wancheng')
        //     wancheng.showBagLayer()
        // }
        this.node.removeFromParent()
    }
    // update (dt) {}
}