Setting.ts 2.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. import JsbSystem from "../../../mk/system/JsbSystem";
  2. import Rule from "./Rule";
  3. const { ccclass, property } = cc._decorator;
  4. /**
  5. * 账号设置
  6. * @author 邹勇
  7. */
  8. @ccclass
  9. export default class Setting extends cc.Component {
  10. @property({ type: cc.Sprite, displayName: "头像" })
  11. img_head: cc.Sprite = null;
  12. @property({ type: cc.Label, displayName: "昵称" })
  13. lbl_nickname: cc.Label = null;
  14. @property({ type: cc.Label, displayName: "ID" })
  15. lbl_id: cc.Label = null;
  16. @property({ type: cc.Sprite, displayName: "音乐开关" })
  17. img_music: cc.Sprite = null;
  18. @property({ type: cc.Sprite, displayName: "音效开关" })
  19. img_effect: cc.Sprite = null;
  20. @property({ type: cc.Label, displayName: "版本号" })
  21. lbl_version: cc.Label = null;
  22. // @property({ type: cc.Node, displayName: "协议内容" })
  23. node_rule: cc.Node = null;
  24. onLoad() {
  25. this.initData();
  26. }
  27. private async initData() {
  28. this.lbl_id.string = "ID:" + gData.wechatData.unionid;
  29. this.lbl_nickname.string = gData.wechatData.nickName;
  30. let music = "module/setting/texture/" + (mk.audio.getSwitchMusic() ? "on" : "off");
  31. let effect = "module/setting/texture/" + (mk.audio.getSwitchEffect() ? "on" : "off");
  32. this.img_music.spriteFrame = await mk.loader.load(music, cc.SpriteFrame);
  33. this.img_effect.spriteFrame = await mk.loader.load(effect, cc.SpriteFrame);
  34. let result = await mk.loader.loadRemote(gData.wechatData.avatar, null);
  35. console.log("loadHead:", result);
  36. // this.img_head.spriteFrame = result;
  37. }
  38. clickCopy() {
  39. JsbSystem.setClipboard(gData.wechatData.unionid);
  40. mk.tip.pop("复制成功");
  41. }
  42. async clickMusic() {
  43. mk.audio.switchMusicFunc();
  44. let music = "module/setting/texture/" + (mk.audio.getSwitchMusic() ? "on" : "off");
  45. this.img_music.spriteFrame = await mk.loader.load(music, cc.SpriteFrame);
  46. }
  47. async clickEffect() {
  48. mk.audio.switchEffectFunc();
  49. let effect = "module/setting/texture/" + (mk.audio.getSwitchEffect() ? "on" : "off");
  50. this.img_effect.spriteFrame = await mk.loader.load(effect, cc.SpriteFrame);
  51. }
  52. clickUpdate() {
  53. }
  54. async clickRule(e, data) {
  55. if (!this.node_rule) this.node_rule = await mk.ui.openPanel('module/setting/rule');
  56. let sc = this.node_rule.getComponent(Rule) as Rule;
  57. sc.setContent(data);
  58. this.node_rule.active = true;
  59. }
  60. update() {
  61. }
  62. onDestroy() {
  63. }
  64. }