csmadmin_utils.js 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  1. define(['jquery', 'toastr', 'form', 'template'], function ($, toastr, Form, Template) {
  2. var utils = {
  3. //修改手机前,发送短信(需验证码确认,以防止被攻击)
  4. triggerBtnModifyMobile:function(btnjqstr,mobile,event,sendedfunc){
  5. var that = this;
  6. //v1.2.0 修复部分服务器下手机号码登录验证码无法显示的问题
  7. //var captchaimg = Fast.api.cdnurl("/captcha.html");
  8. var captchaimg = Fast.api.fixurl("/index.php?s=/captcha");
  9. var myreg=/^[1][3,4,5,7,8][0-9]{9}$/;
  10. if (!myreg.test(mobile)) {
  11. Toastr.error("请输入正确的手机号码");
  12. return;
  13. }
  14. Layer.open({
  15. title: '验证码',
  16. content: '\
  17. <div class="form-group">\
  18. <img id="modifymobilecaptchaimg" src="'+captchaimg+'"/>\
  19. </div>\
  20. <div class="form-group">\
  21. <label class="control-label" for="account">请填写图片中内容</label>\
  22. <input class="form-control" id="modifymobilecaptcha" name="modifymobilecaptcha" type="text"/>\
  23. </div>\
  24. ',
  25. yes: function (index, layero) {
  26. Fast.api.ajax({
  27. url: Fast.api.fixurl("csmadmin/csmadminapp/sendMobileCodeAjax"),
  28. type: "post",
  29. data: {
  30. mobile: mobile,
  31. event: event,
  32. captcha:$("#modifymobilecaptcha").val()
  33. },
  34. }, function (data, ret) {
  35. Toastr.success("短信发送成功!");
  36. Layer.close(index);
  37. if(sendedfunc){
  38. sendedfunc(mobile);
  39. }
  40. return false;
  41. }, function (data, ret) {
  42. Toastr.error(ret.msg);
  43. $("#modifymobilecaptchaimg").removeAttr("src").attr('src',captchaimg);
  44. return false;
  45. });
  46. }
  47. });
  48. $("#modifymobilecaptchaimg").click(function(){
  49. $("#modifymobilecaptchaimg").removeAttr("src").attr('src',captchaimg);
  50. });
  51. },
  52. //修改邮箱前,发送邮件(需验证码确认,以防止被攻击)
  53. triggerBtnModifyEmail:function(btnjqstr,email,event,sendedfunc){
  54. var that = this;
  55. //v1.2.0 修复部分服务器下手机号码登录验证码无法显示的问题
  56. //var captchaimg = Fast.api.cdnurl("/captcha.html");
  57. var captchaimg = Fast.api.fixurl("/index.php?s=/captcha");
  58. if(email.indexOf("@") == -1 ){
  59. Toastr.error("请输入正确的邮箱格式");
  60. return;
  61. }
  62. Layer.open({
  63. title: '验证码',
  64. content: '\
  65. <div class="form-group">\
  66. <img id="modifyemailcaptchaimg" src="'+captchaimg+'"/>\
  67. </div>\
  68. <div class="form-group">\
  69. <label class="control-label" for="account">请填写图片中内容</label>\
  70. <input class="form-control" id="modifyemailcaptcha" name="modifyemailcaptcha" type="text"/>\
  71. </div>\
  72. ',
  73. yes: function (index, layero) {
  74. Fast.api.ajax({
  75. url: Fast.api.fixurl("csmadmin/csmadminapp/sendEmailCodeAjax"), type: "post",
  76. data: {
  77. email: email,
  78. event: event,
  79. captcha:$("#modifyemailcaptcha").val()
  80. },
  81. }, function (data, ret) {
  82. Toastr.success("邮件发送成功!");
  83. Layer.close(index);
  84. if(sendedfunc){
  85. sendedfunc(email);
  86. }
  87. return false;
  88. }, function (data, ret) {
  89. Toastr.error(ret.msg);
  90. $("#modifyemailcaptchaimg").removeAttr("src").attr('src',captchaimg);
  91. return false;
  92. });
  93. }
  94. });
  95. $("#modifyemailcaptchaimg").click(function(){
  96. $("#modifyemailcaptchaimg").removeAttr("src").attr('src',captchaimg);
  97. });
  98. },
  99. };
  100. return utils;
  101. });