phone.js 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136
  1. ;
  2. var phonePage = new Vue({
  3. el: "#phonePage",
  4. data: {
  5. loginLoading:false,
  6. count: '', //倒计时
  7. newCount: '', //倒计时
  8. codeTime: null,
  9. codeTimeNew: null,
  10. mobileCodeText: '获取验证码',
  11. newMobileCodeText: '获取验证码',
  12. isMobileDisabled: false, //手机验证码按钮控制
  13. isNewMobileDisabled: false, //手机验证码按钮控制
  14. form:{
  15. mobile:'', //旧联系人手机号
  16. newMobile:'', //新联系人手机号
  17. smsCode:'', //原手机号验证码
  18. newSmsCode:'', //新手机号手机验证码
  19. userId:0
  20. },
  21. rule:{
  22. phone: '^\\d{6,12}$',
  23. code: '^\\d{6}$',
  24. }
  25. },
  26. computed: {
  27. },
  28. methods: {
  29. bindMobileCheck:function(){
  30. var _self = this;
  31. var pass = verifyForm();
  32. if (_self.loginLoading) { return false; }
  33. if (!pass) {return false;}
  34. _self.loginLoading = true;
  35. PublicApi.clubChangeMobile(_self.form,function (response) {
  36. if(response.code === 0){
  37. CAIMEI.dialog('修改成功~',true,function () {
  38. _self.loginLoading = false;
  39. CAIMEI.Storage.clear();
  40. window.location.href = '/login.html';
  41. });
  42. } else {
  43. CAIMEI.Alert(response.msg,'确定',false);
  44. _self.loginLoading = false;
  45. }
  46. });
  47. },
  48. getMobileCodeFn:function(){//获取旧手机号验证码
  49. var _self = this;
  50. var params = {
  51. mobile:_self.form.mobile,
  52. isCheckCaptcha:1,
  53. activateCodeType:4,
  54. platformType:0
  55. };
  56. _self.isMobileDisabled = true;
  57. UserApi.getRegisterMobileCode(params,function(response){
  58. if(response.code == 0){
  59. CAIMEI.dialog('验证短信已发送',false,function () {});
  60. var TIME_COUNT = 60;
  61. if (!_self.mobilTime) {
  62. _self.count = TIME_COUNT;
  63. _self.isMobileDisabled = true;
  64. _self.codeTime = setInterval(function(){
  65. if (_self.count > 1 && _self.count <= TIME_COUNT) {
  66. _self.count--;
  67. _self.mobileCodeText = _self.count +'s重新发送';
  68. } else {
  69. _self.isMobileDisabled = false;
  70. clearInterval(_self.codeTime);
  71. _self.codeTime = null;
  72. _self.mobileCodeText = '获取验证码';
  73. }
  74. },1000)
  75. }
  76. }else{
  77. CAIMEI.Alert(response.msg,'确定',false);
  78. _self.isMobileDisabled = false;
  79. }
  80. })
  81. },
  82. getNewMobileCodeFn:function(){//获取新手机号短信验证码
  83. var _self = this;
  84. var pass = verifyCheack('.massageBtn');
  85. if (!pass) { return false; }
  86. var params = {
  87. mobile:_self.form.newMobile,
  88. isCheckCaptcha:1,
  89. activateCodeType:5,
  90. platformType:0
  91. };
  92. _self.isNewMobileDisabled = true;
  93. UserApi.getRegisterMobileCode(params,function(response){
  94. if(response.code == 0){
  95. CAIMEI.dialog('验证短信已发送',false,function () {});
  96. var TIME_COUNT = 60;
  97. if (!_self.codeTimeNew) {
  98. _self.newCount = TIME_COUNT;
  99. _self.isNewMobileDisabled = true;
  100. _self.codeTimeNew = setInterval(function(){
  101. if (_self.newCount > 1 && _self.newCount <= TIME_COUNT) {
  102. _self.newCount--;
  103. _self.newMobileCodeText = _self.newCount +'s重新发送';
  104. } else {
  105. _self.isNewMobileDisabled = false;
  106. clearInterval(_self.codeTimeNew);
  107. _self.codeTimeNew = null;
  108. _self.newMobileCodeText = '获取验证码';
  109. }
  110. },1000)
  111. }
  112. }else{
  113. CAIMEI.Alert(response.msg,'确定',false);
  114. _self.isNewMobileDisabled = false;
  115. }
  116. })
  117. },
  118. blurHandle: function(event) { // 失去焦点校验
  119. var el = event.currentTarget;
  120. verifyHandle(el);
  121. }
  122. },
  123. created: function () {
  124. },
  125. mounted: function () {
  126. var _self = this;
  127. if(globalUserData){
  128. _self.form.mobile = globalUserData.phone;
  129. _self.form.userId = globalUserData.userId;
  130. }
  131. $('.navLayout').find('.navList').removeClass("on").find('.con').hide().find('a').removeClass("on");
  132. $('.navLayout').find('.navList').eq(2).addClass("on").find('.con').show().find('a').eq(1).addClass("on");
  133. }
  134. });