wuxw
2019-04-25 2c8771fbb8090d433c059b2d783c2c1959137cc9
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
(function(vc){
    vc.extends({
            data:{
                validateParam:{
                    tel:'',
                    messageCode:'',
                },
               buttonInfo:'验证码'
            },
            _initMethod:function(){
                console.log("validate-tel _initMethod 方法调用");
                 //vc.component.generateCode();
 
            },
            _initEvent:function(){
 
            },
            watch: {
                validateParam:{
                    deep: true,
                    handler:function(){
                        console.log('通知号码信息',vc.component.validateParam.tel);
                        vc.component.$emit('validate_tel_change_event',vc.component.validateParam);
                    }
                 }
//                messageCode:function(){
//                    vc.component.$emit('validate_tel_change_event',vc.component.validateParam);
//                }
            },
            methods:{
                sendTelMessageCode(){
                    if(!vc.validate.phone(vc.component.validateParam.tel)){
                          vc.component.$emit('errorInfoEvent',"手机号码为空或不正确,不能发送验证码");
                        return;
                    }
                    // 开启定时
                    vc.component.messageCodeTimer();
 
                    var param = {
                            tel:vc.component.validateParam.tel,
                    };
                    console.log("validate-tel sendTelMessageCode",JSON.stringify(param));
                    vc.http.post('validate-tel','sendTelMessageCode',
                                 JSON.stringify(param),
                                 {
                                     emulateJSON:true
                                  },
                                 function(json,res){
                                    //vm.menus = vm.refreshMenuActive(JSON.parse(json),0);
                                    if(res.status == 200){
                                        vc.component.errorInfo = json;
                                        return ;
                                    }
                                    vc.component.$emit('errorInfoEvent',json);
                                 },function(errInfo,error){
                                    console.log('请求失败处理',errInfo,error);
                                    vc.component.$emit('errorInfoEvent',errInfo);
                                 });
 
                },
                //验证码定时
                messageCodeTimer(){
                      var num = 60;
 
                    var _timer = vc.createTimer(function(){
                        num --;
                        vc.component.buttonInfo = num +" 秒后重试";
                        if(num === 1){
                            vc.clearTimer(_timer);
                            vc.component.buttonInfo = "验证码";
                        }
                    },1000);
                }
            },
             _destroyedMethod:function(){
                 console.log("登录页面销毁调用");
             }
 
    });
 
})(window.vc);