Setting.ts 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  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. start()
  28. {
  29. }
  30. private async initData() {
  31. console.log("=== gData.wechatData.unionid",gData.wechatData.unionid);
  32. console.log("=== gData.wechatData.nickName",gData.wechatData.nickName);
  33. this.lbl_id.string = "ID:" + gData.wechatData.unionid;
  34. this.lbl_nickname.string = gData.wechatData.nickName;
  35. let music = "module/setting/texture/" + (mk.audio.getSwitchMusic() ? "on" : "off");
  36. let effect = "module/setting/texture/" + (mk.audio.getSwitchEffect() ? "on" : "off");
  37. this.img_music.spriteFrame = await mk.loader.load(music, cc.SpriteFrame);
  38. this.img_effect.spriteFrame = await mk.loader.load(effect, cc.SpriteFrame);
  39. let result = await mk.loader.loadRemote(gData.wechatData.avatar, null);
  40. console.log("loadHead:", result);
  41. // this.img_head.spriteFrame = result;
  42. }
  43. clickCopy() {
  44. mk.audio.playEffect("button");
  45. JsbSystem.setClipboard(gData.wechatData.unionid);
  46. mk.tip.pop("复制成功");
  47. }
  48. async clickMusic() {
  49. mk.audio.switchMusicFunc();
  50. mk.audio.playEffect("button");
  51. let music = "module/setting/texture/" + (mk.audio.getSwitchMusic() ? "on" : "off");
  52. this.img_music.spriteFrame = await mk.loader.load(music, cc.SpriteFrame);
  53. }
  54. async clickEffect() {
  55. mk.audio.switchEffectFunc();
  56. mk.audio.playEffect("button");
  57. let effect = "module/setting/texture/" + (mk.audio.getSwitchEffect() ? "on" : "off");
  58. this.img_effect.spriteFrame = await mk.loader.load(effect, cc.SpriteFrame);
  59. }
  60. clickUpdate() {
  61. }
  62. /** 点击微信授权 */
  63. onClickWxAuth() {
  64. mk.ui.closePanel(this.node.name);
  65. JsbSystem.WxAuth();
  66. }
  67. async clickRule(data) {
  68. gData.setting.rule_type = parseInt(data);
  69. }
  70. update() {
  71. }
  72. onDestroy() {
  73. }
  74. }