Няма описание

bindmail.js 1.8KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. //首页
  2. mui.ready(function() {
  3. /*定义全局变量*/
  4. var inputEmail = document.getElementById("inputemail");
  5. var sendCode = document.getElementById("sendcode");
  6. mui.plusReady(function() {
  7. /*发送按钮*/
  8. sendCode.addEventListener("tap", function() {
  9. userEmail();
  10. });
  11. /*校验用户账号*/
  12. function userEmail() {
  13. var gunf = /^\w+@\w+\.((cn)|(com)|(com\.cn))$/;
  14. if(gunf.test(inputEmail.value)) {
  15. isReg();
  16. } else {
  17. plus.nativeUI.toast("请输入正确的邮箱", toastStyle);
  18. return;
  19. }
  20. }
  21. /*判断账号是否注册*/
  22. function isReg() {
  23. mui.ajax(baseUrl + '/ajax/isReg?key=' + inputEmail.value, {
  24. dataType: 'json', //数据格式类型
  25. type: 'GET', //http请求类型
  26. timeout: 10000, //超时设置
  27. async: false,
  28. success: function(data) {
  29. console.log(data.data);
  30. if(data.data == false) {
  31. plus.nativeUI.toast("您的邮箱已被绑定", toastStyle);
  32. return;
  33. } else {
  34. sendEmail();
  35. }
  36. },
  37. error: function() {
  38. plus.nativeUI.toast("服务器链接超时", toastStyle);
  39. }
  40. });
  41. }
  42. /*判断账号是否注册*/
  43. function sendEmail() {
  44. var userId = plus.storage.getItem('userid');
  45. mui.ajax(baseUrl + '/ajax/reqBindMail', {
  46. data: {
  47. "userid": userId,
  48. "mail": inputEmail.value
  49. },
  50. dataType: 'json', //数据格式类型
  51. type: 'GET', //http请求类型
  52. timeout: 10000, //超时设置
  53. success: function(data) {
  54. if(data.success && data.data) {
  55. plus.nativeUI.toast("发送成功,请登录邮箱验证", toastStyle);
  56. mui.currentWebview.close();
  57. return;
  58. }
  59. },
  60. error: function() {
  61. plus.nativeUI.toast("服务器链接超时", toastStyle);
  62. return;
  63. }
  64. });
  65. }
  66. });
  67. });