ShareModal.js 2.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  1. // Learn cc.Class:
  2. // - [Chinese] http://docs.cocos.com/creator/manual/zh/scripting/class.html
  3. // - [English] http://www.cocos2d-x.org/docs/creator/en/scripting/class.html
  4. // Learn Attribute:
  5. // - [Chinese] http://docs.cocos.com/creator/manual/zh/scripting/reference/attributes.html
  6. // - [English] http://www.cocos2d-x.org/docs/creator/en/scripting/reference/attributes.html
  7. // Learn life-cycle callbacks:
  8. // - [Chinese] http://docs.cocos.com/creator/manual/zh/scripting/life-cycle-callbacks.html
  9. // - [English] http://www.cocos2d-x.org/docs/creator/en/scripting/life-cycle-callbacks.html
  10. cc.Class({
  11. extends: cc.Component,
  12. properties: {
  13. // foo: {
  14. // // ATTRIBUTES:
  15. // default: null, // The default value will be used only when the component attaching
  16. // // to a node for the first time
  17. // type: cc.SpriteFrame, // optional, default is typeof default
  18. // serializable: true, // optional, default is true
  19. // },
  20. // bar: {
  21. // get () {
  22. // return this._bar;
  23. // },
  24. // set (value) {
  25. // this._bar = value;
  26. // }
  27. // },
  28. bg:cc.Node,
  29. content:cc.Node,
  30. button:cc.Node,
  31. cardLabel:cc.Label,
  32. close:cc.Node,
  33. },
  34. // LIFE-CYCLE CALLBACKS:
  35. // onLoad () {},
  36. start () {
  37. },
  38. onEnable(){
  39. wx.showLoading();
  40. wx.request({
  41. url:'https://api-touhu.duowan.com/user/getUserRecord.do',
  42. data:{
  43. token:Global.user.token,
  44. uid:Global.user.uid,
  45. channel:Global.channel,
  46. os:Global.os,
  47. ver:Global.ver,
  48. },
  49. success:(response)=>{
  50. if(response.data.code==-5){
  51. wx.showToast({
  52. title:'登录过期'
  53. })
  54. Global.showLoginPage = true;
  55. cc.director.loadScene('MainMenu');
  56. }else{
  57. if(response.data.data.revivedCount!=undefined){
  58. Global.user.revivedCount = response.data.data.revivedCount;
  59. }
  60. this.bindData();
  61. }
  62. },
  63. fail:()=>{
  64. wx.showToast({title:'网络错误'})
  65. },
  66. complete:()=>{
  67. wx.hideLoading();
  68. }
  69. })
  70. },
  71. bindData(){
  72. this.bg.on('touchend', ()=> {
  73. this.node.active = false;
  74. });
  75. this.content.on('touchend', ()=> {});
  76. this.close.on('touchend', ()=> {this.node.active = false;})
  77. this.cardLabel.string = Global.user.revivedCount;
  78. }
  79. // update (dt) {},
  80. });