• 倒计时验证码


    //获取手机验证码
    $scope.regInfo = {
    phone: "15139000000",
    code: "",
    text: "发送验证码",
    };
    $scope.second = 0;
    $scope.currentCode = "";
    $scope.creatCode = function () {
    var Num = "";
    for (var i = 1; i < 7; i++) {
    Num += Math.floor(Math.random() * 10);
    }
    return Num;
    };

    $scope.getcode = function () {
    //alert("123456");
    //测试阶段,不用每次发短信,先默认通过验证
    //return;
    $rootScope.showAlert("此功能暂未开通!");
    return;
    if ($scope.second != 0) {
    return;
    }
    var reg = /^0?1[3|4|5|8][0-9]d{8}$/;
    if (!reg.test($scope.loginfo.userinfo)) {
    $rootScope.showAlert("请输入有效的手机号!");
    return;
    }
    //生成验证码
    $scope.currentCode = $scope.creatCode();

    //发送验证码
    var args = {
    mobile: $scope.loginfo.userinfo,
    content: "【EzTrader】您的验证码是" + $scope.currentCode + ",有效时间5分钟,请不要告诉他人",
    tag: 2,
    headers: {
    "apikey": "300233c8f5c8a11b0117a64ed08e9d80",
    }
    };

    var timePromise = undefined;

    var dx = $resource('http://apis.baidu.com/kingtto_media/106sms/106sms', args, {
    get: {
    method: 'GET',
    isArray: false,
    headers: { 'apikey': "300233c8f5c8a11b0117a64ed08e9d80" }
    }
    });
    dx.get(args, function (data) {
    if (timePromise) {
    return;
    }
    $scope.second = 60;
    timePromise = $interval(function () {
    if ($scope.second <= 0) {
    $interval.cancel(timePromise);
    timePromise = undefined;
    $scope.regInfo.text = "重发验证码";
    } else {
    $scope.regInfo.text = $scope.second + "秒后可重发";
    $scope.second--;

    }
    }, 1000, 100);
    console.log(data);
    });
    };
  • 相关阅读:
    蓝桥杯如何训练?(附VIP题库)
    scratch2.0的教材视频,王木头系列
    out文件 dev c++
    MongoDB 学习笔记
    golang 学习笔记 -- struct interface的使用
    goang学习笔记---struct
    golang 学习笔记 ---JSON
    golang学习笔记 ---rand
    golang学习笔记 --go test
    golang学习笔记---string && strconv
  • 原文地址:https://www.cnblogs.com/xfcao/p/8668335.html
Copyright © 2020-2023  润新知