Setting.ts 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  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. }
  41. async clickMusic() {
  42. mk.audio.switchMusicFunc();
  43. let music = "module/setting/texture/" + (mk.audio.getSwitchMusic() ? "on" : "off");
  44. this.img_music.spriteFrame = await mk.loader.load(music, cc.SpriteFrame);
  45. }
  46. async clickEffect() {
  47. mk.audio.switchEffectFunc();
  48. let effect = "module/setting/texture/" + (mk.audio.getSwitchEffect() ? "on" : "off");
  49. this.img_effect.spriteFrame = await mk.loader.load(effect, cc.SpriteFrame);
  50. }
  51. clickUpdate() {
  52. }
  53. clickRule(e,data) {
  54. let sc = this.node_rule.getComponent(Rule) as Rule;
  55. sc.setContent(data);
  56. this.node_rule.active = true;
  57. }
  58. update() {
  59. }
  60. onDestroy() {
  61. }
  62. }