phone.js 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126
  1. jqMultipleShow("click", ".navList", ".tab", ".con");
  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. contractMobile2:'', //新联系人手机号
  16. contractMobile:'', //旧联系人手机号
  17. mobileCode:'', //原手机号验证码
  18. newMobileCode:'', //新手机号手机验证码
  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. _self.isMobileDisabled = true;
  51. PublicApi.getClubMobileCode({ mobile : _self.form.contractMobile2 },function(response){
  52. if(response.code == 0){
  53. CAIMEI.dialog('验证短信已发送',false,function () {});
  54. var TIME_COUNT = 60;
  55. if (!_self.mobilTime) {
  56. _self.count = TIME_COUNT;
  57. _self.isMobileDisabled = true;
  58. _self.codeTime = setInterval(function(){
  59. if (_self.count > 1 && _self.count <= TIME_COUNT) {
  60. _self.count--;
  61. _self.mobileCodeText = _self.count +'s重新发送';
  62. } else {
  63. _self.isMobileDisabled = false;
  64. clearInterval(_self.codeTime);
  65. _self.codeTime = null;
  66. _self.mobileCodeText = '获取验证码';
  67. }
  68. },1000)
  69. }
  70. }else{
  71. CAIMEI.Alert(response.msg,'确定',false);
  72. _self.isMobileDisabled = false;
  73. }
  74. })
  75. },
  76. getNewMobileCodeFn:function(){//获取新手机号短信验证码
  77. var _self = this;
  78. var pass = verifyCheack('.massageBtn');
  79. if (!pass) {
  80. return false;
  81. }
  82. _self.isNewMobileDisabled = true;
  83. PublicApi.getClubMobileCode({ mobile : _self.form.contractMobile },function(response){
  84. if(response.code == 0){
  85. CAIMEI.dialog('验证短信已发送',false,function () {});
  86. var TIME_COUNT = 60;
  87. if (!_self.codeTimeNew) {
  88. _self.newCount = TIME_COUNT;
  89. _self.isNewMobileDisabled = true;
  90. _self.codeTimeNew = setInterval(function(){
  91. if (_self.newCount > 1 && _self.newCount <= TIME_COUNT) {
  92. _self.newCount--;
  93. _self.newMobileCodeText = _self.newCount +'s重新发送';
  94. } else {
  95. _self.isNewMobileDisabled = false;
  96. clearInterval(_self.codeTimeNew);
  97. _self.codeTimeNew = null;
  98. _self.newMobileCodeText = '获取验证码';
  99. }
  100. },1000)
  101. }
  102. }else{
  103. CAIMEI.Alert(response.msg,'确定',false);
  104. _self.isNewMobileDisabled = false;
  105. }
  106. })
  107. },
  108. blurHandle: function(event) { // 失去焦点校验
  109. var el = event.currentTarget;
  110. verifyHandle(el);
  111. }
  112. },
  113. created: function () {
  114. },
  115. mounted: function () {
  116. var _self = this;
  117. if(globalUserData){
  118. _self.form.contractMobile2 = globalUserData.phone;
  119. _self.form.userID = globalUserData.userId;
  120. }
  121. $('.navLayout').find('.navList').removeClass("on").find('.con').hide().find('a').removeClass("on");
  122. $('.navLayout').find('.navList').eq(2).addClass("on").find('.con').show().find('a').eq(1).addClass("on");
  123. }
  124. });