import { _decorator, Component, Node, SpriteFrame } from 'cc';
import { base_ui } from '../../fw/base_ui';
const { ccclass, property } = _decorator;

@ccclass('feedback_selected')
export class feedback_selected extends base_ui {
    @property(Node) btn_xcxst:Node = null
    @property(Node) btn_ymcw:Node = null
    @property(Node) btn_kd:Node = null
    @property(Node) btn_qtyc:Node = null
    @property(Node) btn_xcy:Node = null
    @property(Node) btn_xtyh:Node = null

    @property(SpriteFrame) sf_xcxst:SpriteFrame = null
    @property(SpriteFrame) sf_ymcw:SpriteFrame = null
    @property(SpriteFrame) sf_kd:SpriteFrame = null
    @property(SpriteFrame) sf_qtyc:SpriteFrame = null
    @property(SpriteFrame) sf_xcy:SpriteFrame = null
    @property(SpriteFrame) sf_xtyh:SpriteFrame = null

    private data_list = []
    private m_click_item_cb = null

    start() {
        this.onButtonListen(this.btn_xcxst, ()=>{
            this.onClick(0)
        })
        this.onButtonListen(this.btn_ymcw, ()=>{
            this.onClick(1)
        })
        this.onButtonListen(this.btn_kd, ()=>{
            this.onClick(2)
        })
        this.onButtonListen(this.btn_qtyc, ()=>{
            this.onClick(3)
        })
        this.onButtonListen(this.btn_xcy, ()=>{
            this.onClick(4)
        })
        this.onButtonListen(this.btn_xtyh, ()=>{
            this.onClick(5)
        })

        this.data_list = 
        [{'title':'小程序闪退', 'sf':this.sf_xcxst},
         {'title':'页面错位', 'sf':this.sf_ymcw},
         {'title':'卡顿', 'sf':this.sf_kd},
         {'title':'其他异常', 'sf':this.sf_qtyc},
         {'title':'新创意', 'sf':this.sf_xcy},
         {'title':'系统优化', 'sf':this.sf_xtyh}]
        
    }

    initView(click_item_cb) {
        this.m_click_item_cb = click_item_cb
    }

    onClick(index:number) {
        if(this.m_click_item_cb!=null) {
            let data = this.data_list[index]
            this.m_click_item_cb(data)
        }
    }
}

