| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394 |
- layui.use(["layer", "form"], function(){
- $ = layui.$;
- form = layui.form;
- layer = layui.layer;
- //点击发送验证码
- $(document).on("click", ".getCode", (e) => {
- let tel = $("input[name=tel]").val();
- if(tel == null || tel == ""){
- layer.msg("请输入手机号", {icon: 2});
- return false;
- }
- if(!(/^1[3456789]\d{9}$/.test(tel))){
- layer.msg("手机号格式不正确", {icon: 2});
- return false;
- }
- //发送验证码
- $.ajax({
- url: "https://www.tuyatrip.com/api/supplier/checkTele",
- type: "get",
- data: {
- "phone": tel
- },
- dataType: "json",
- success: (data) => {
- if(data.msg == "500"){
- layer.alert(data.errMsg, {icon: 2});
- } else {
- layer.alert("发送成功", {icon: 1});
- let time = 60;
- let timer = "";
- clearInterval(timer);
- timer = setInterval(function () {
- if (time > 0) {
- $('.code-btn').html(time + "S");
- $(".code-btn").removeClass("getCode");
- time--;
- } else {
- $('.code-btn').html("获取验证码");
- time = 60;
- $(".code-btn").addClass("getCode");
- clearInterval(timer);
- }
- }, 1000);
- }
- },
- error: () => {
- layer.closeAll("loading");
- layer.alert("网络错误 请联系管理员");
- }
- });
- });
- //注册登录
- $(".login-btn").on("click", (e) =>{
- let captcha = $("input[name=captcha]").val();
- let tel = $("input[name=tel]").val();
- if(captcha == null || captcha == ""){
- layer.msg("验证码不能为空", {icon: 2});
- return false;
- }
- if(tel == null || tel == ""){
- layer.msg("请输入手机号", {icon: 2});
- return false;
- }
- if(!(/^1[3456789]\d{9}$/.test(tel))){
- layer.msg("手机号格式不正确", {icon: 2});
- return false;
- }
- //登录
- $.ajax({
- url: "https://www.tuyatrip.com/api/supplier/updateUser",
- type: "get",
- data: {
- "phone": tel,
- "captcha": captcha
- },
- dataType: "json",
- success: (data) => {
- if(data.msg == "500"){
- layer.msg(data.errMsg, {icon: 2});
- return false;
- } else {
- window.location.href="/page/registered/" + tel;
- }
- localStorage.setItem("token", data.data.token);
- window.location.href="/page/index"
- },
- error: () => {
- layer.closeAll("loading");
- layer.alert("网络错误 请联系管理员");
- }
- });
- });
- })
|