shop_view.ts 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117
  1. import { _decorator, Component, Node, Prefab } from 'cc';
  2. import { ContentType } from '../adapter/define/enum';
  3. import { shop_type } from '../constant';
  4. import GBaseUI from '../gcommon/GBaseUI';
  5. import { UIButton } from '../gcommon/UIButton';
  6. import { shop_type_btn } from './shop_type_btn';
  7. const { ccclass, property } = _decorator;
  8. @ccclass('shop_view')
  9. export class shop_view extends GBaseUI {
  10. @property(Node) btn_close:Node = null
  11. @property(Node) btn_select_daoju:Node = null
  12. @property(Node) btn_select_zhuangban:Node = null
  13. @property(Node) btn_select_yuanbao:Node = null
  14. @property(Node) node_select_daoju:Node = null
  15. @property(Node) node_select_zhuangban:Node = null
  16. @property(Node) node_select_yuanbao:Node = null
  17. private curSelect:number = shop_type.dao_ju;
  18. initSelectView(){
  19. UIButton.BindClick(this.btn_select_daoju,()=>{
  20. if(this.curSelect===shop_type.dao_ju){
  21. }else{
  22. this.curSelect = shop_type.dao_ju;
  23. this.updateSelectStatus()
  24. }
  25. },this)
  26. UIButton.BindClick(this.btn_select_zhuangban,()=>{
  27. if(this.curSelect===shop_type.zhuang_ban){
  28. }else{
  29. this.curSelect = shop_type.zhuang_ban;
  30. this.updateSelectStatus()
  31. }
  32. },this)
  33. UIButton.BindClick(this.btn_select_yuanbao,()=>{
  34. if(this.curSelect===shop_type.huo_bi){
  35. }else{
  36. this.curSelect = shop_type.huo_bi;
  37. this.updateSelectStatus()
  38. }
  39. },this)
  40. this.updateSelectStatus()
  41. }
  42. updateSelectStatus(){
  43. this.btn_select_daoju.getComponent(shop_type_btn).unSelect()
  44. this.btn_select_zhuangban.getComponent(shop_type_btn).unSelect()
  45. this.btn_select_yuanbao.getComponent(shop_type_btn).unSelect()
  46. switch (this.curSelect) {
  47. case shop_type.dao_ju:
  48. {
  49. this.btn_select_daoju.getComponent(shop_type_btn).onSelect()
  50. }
  51. break;
  52. case shop_type.zhuang_ban:
  53. {
  54. this.btn_select_zhuangban.getComponent(shop_type_btn).onSelect()
  55. }
  56. break;
  57. case shop_type.huo_bi:
  58. {
  59. this.btn_select_yuanbao.getComponent(shop_type_btn).onSelect()
  60. }
  61. break;
  62. }
  63. this.updateView()
  64. }
  65. updateView(){
  66. this.node_select_daoju.active = false;
  67. this.node_select_zhuangban.active = false;
  68. this.node_select_yuanbao.active = false;
  69. switch (this.curSelect) {
  70. case shop_type.dao_ju:
  71. {
  72. this.node_select_daoju.active = true;
  73. }
  74. break;
  75. case shop_type.zhuang_ban:
  76. {
  77. this.node_select_zhuangban.active = true;
  78. }
  79. break;
  80. case shop_type.huo_bi:
  81. {
  82. this.node_select_yuanbao.active = true;
  83. }
  84. break;
  85. }
  86. }
  87. start() {
  88. UIButton.BindClick(this.btn_close,()=>{
  89. this.closeUI()
  90. },this)
  91. this.initSelectView()
  92. }
  93. update(deltaTime: number) {
  94. }
  95. }