SendRoomCard.js 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. cc.Class({
  2. extends: cc.BaseClass,
  3. properties: {
  4. m_Lab:[cc.Label],
  5. },
  6. ctor:function(){
  7. this.m_CntArr = new Array();
  8. },
  9. OnShowView:function(){
  10. this.m_Input = null;
  11. this.m_Lab[0].string = '輸入好友ID';
  12. this.m_Lab[1].string = '輸入鑽石數';
  13. },
  14. OnBtInput:function(Tag, Data){
  15. this.m_Input = parseInt(Data);
  16. this.m_InputCtrl = this.m_LabID;
  17. this.ShowPrefabDLG('SelfInput');
  18. },
  19. SetInput:function(Num){
  20. this.m_Lab[this.m_Input].string = Num;
  21. this.m_CntArr[this.m_Input] = Num;
  22. },
  23. BtSend:function(){
  24. //验证
  25. if( this.m_Lab[0].string == '輸入好友ID' || this.m_CntArr[0] < 100000) {
  26. this.ShowTips('請輸入有效ID!');
  27. return
  28. }
  29. if( this.m_Lab[1].string == '輸入鑽石數' || this.m_CntArr[1] == 0) {
  30. this.ShowTips('請輸入有效鑽石數!');
  31. return
  32. }
  33. //发送协议
  34. this.m_Hook.OnGetUsingCard();
  35. this.m_Hook.ShowLoading();
  36. },
  37. SetUsingCard:function(Card){
  38. var pGlobalUserData = g_GlobalUserInfo.GetGlobalUserData();
  39. var webUrl = window.PHP_HOME+'/UserFunc.php?&GetMark=4&dwUserID='+pGlobalUserData.dwUserID;
  40. webUrl += '&strPsw='+ pGlobalUserData.szPassword + '&TagID=' + this.m_CntArr[0];
  41. webUrl += '&TakeCount='+Card+'&CardCount='+this.m_CntArr[1];
  42. var self = this;
  43. WebCenter.GetData(webUrl, null, function (data) {
  44. if(self.m_Hook)self.m_Hook.StopLoading();
  45. if (data === -1){
  46. self.ShowTips('請檢查網絡!');
  47. }else{
  48. var res = JSON.parse(data);
  49. self.m_Hook.ShowTips(res.Describe)
  50. self.m_Hook.OnBtRefeshRoomCard();
  51. self.m_CntArr[0] = 0;
  52. self.m_CntArr[1] = 0;
  53. if(res.Res == 0) self.HideView();
  54. }
  55. });
  56. },
  57. });