123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104 |
- define(['jquery', 'toastr', 'form', 'template'], function ($, toastr, Form, Template) {
- var utils = {
- //修改手机前,发送短信(需验证码确认,以防止被攻击)
- triggerBtnModifyMobile:function(btnjqstr,mobile,event,sendedfunc){
- var that = this;
- //v1.2.0 修复部分服务器下手机号码登录验证码无法显示的问题
- //var captchaimg = Fast.api.cdnurl("/captcha.html");
- var captchaimg = Fast.api.fixurl("/index.php?s=/captcha");
- var myreg=/^[1][3,4,5,7,8][0-9]{9}$/;
- if (!myreg.test(mobile)) {
- Toastr.error("请输入正确的手机号码");
- return;
- }
- Layer.open({
- title: '验证码',
- content: '\
- <div class="form-group">\
- <img id="modifymobilecaptchaimg" src="'+captchaimg+'"/>\
- </div>\
- <div class="form-group">\
- <label class="control-label" for="account">请填写图片中内容</label>\
- <input class="form-control" id="modifymobilecaptcha" name="modifymobilecaptcha" type="text"/>\
- </div>\
- ',
- yes: function (index, layero) {
- Fast.api.ajax({
- url: Fast.api.fixurl("csmadmin/csmadminapp/sendMobileCodeAjax"),
- type: "post",
- data: {
- mobile: mobile,
- event: event,
- captcha:$("#modifymobilecaptcha").val()
- },
- }, function (data, ret) {
- Toastr.success("短信发送成功!");
- Layer.close(index);
- if(sendedfunc){
- sendedfunc(mobile);
- }
- return false;
- }, function (data, ret) {
- Toastr.error(ret.msg);
- $("#modifymobilecaptchaimg").removeAttr("src").attr('src',captchaimg);
- return false;
- });
- }
- });
- $("#modifymobilecaptchaimg").click(function(){
- $("#modifymobilecaptchaimg").removeAttr("src").attr('src',captchaimg);
- });
- },
- //修改邮箱前,发送邮件(需验证码确认,以防止被攻击)
- triggerBtnModifyEmail:function(btnjqstr,email,event,sendedfunc){
- var that = this;
- //v1.2.0 修复部分服务器下手机号码登录验证码无法显示的问题
- //var captchaimg = Fast.api.cdnurl("/captcha.html");
- var captchaimg = Fast.api.fixurl("/index.php?s=/captcha");
- if(email.indexOf("@") == -1 ){
- Toastr.error("请输入正确的邮箱格式");
- return;
- }
- Layer.open({
- title: '验证码',
- content: '\
- <div class="form-group">\
- <img id="modifyemailcaptchaimg" src="'+captchaimg+'"/>\
- </div>\
- <div class="form-group">\
- <label class="control-label" for="account">请填写图片中内容</label>\
- <input class="form-control" id="modifyemailcaptcha" name="modifyemailcaptcha" type="text"/>\
- </div>\
- ',
- yes: function (index, layero) {
- Fast.api.ajax({
- url: Fast.api.fixurl("csmadmin/csmadminapp/sendEmailCodeAjax"), type: "post",
- data: {
- email: email,
- event: event,
- captcha:$("#modifyemailcaptcha").val()
- },
- }, function (data, ret) {
- Toastr.success("邮件发送成功!");
- Layer.close(index);
- if(sendedfunc){
- sendedfunc(email);
- }
- return false;
- }, function (data, ret) {
- Toastr.error(ret.msg);
- $("#modifyemailcaptchaimg").removeAttr("src").attr('src',captchaimg);
- return false;
- });
- }
- });
- $("#modifyemailcaptchaimg").click(function(){
- $("#modifyemailcaptchaimg").removeAttr("src").attr('src',captchaimg);
- });
-
- },
- };
- return utils;
- });
|