PageSourceSearch

https://www.youkuaiyun.com/statics/epower/js/module/login/index.js

js youkuaiyun.com collected 2026-10-05 11:41:58 UTC 8,925 bytes, 242 lines download raw bytes

1"use strict";
2
3new Vue({
4    el: "#app",
5    data: function data() {
6        return {
7            sharedState: store.state,
8            content: '发送验证码',
9            form: {
10                username: '',
11                password: '',
12                sms_key: '',
13                verify_code: ''
14            },
15            login_type: 0,
16            canClick: true,
17            qr_code: '',
18            ticket: '',
19            dialogVisible: false,
20            timer: 0,
21            totalTime: 60,
22            sms_step: 1,
23            accountList: [],
24            sms_multi_key: ''
25        };
26    },
27    watch: {
28        login_type: function (value) {
29            this.form.username = ''
30            this.form.password = ''
31            this.form.sms_key = ''
32            this.form.verify_code = ''
33            this.sms_step = 1
34            this.accountList = []
35            this.sms_multi_key = ''
36        }
37    },
38
39    methods: {
40        handleClose: function handleClose() {
41            this.dialogVisible = false;
42            this.qr_code = '';
43            this.ticket = '';
44            if(this.timer) clearTimeout(this.timer)
45        },
46        wxLogin: function wxLogin() {
47            this.$api.post("/authorizations/wechat_scan_login").then(function(res) {
48                this.dialogVisible = true;
49                this.qr_code = res.data.data.qr_code;
50                this.ticket = res.data.data.ticket;
51                this.timer = setTimeout(function() {
52                    this.wxCheck();
53                }.bind(this), 100);
54            }.bind(this));
55        },
56        wxCheck: function wxCheck() {
57            this.$api.get("/wechat/qr_code_check", {
58                ticket: this.ticket,
59                flag: "login"
60            }).then(function(res) {
61                var code = res.data.data.code
62                if (code == 0) {
63                    if(this.dialogVisible === false) return;
64                    this.timer = setTimeout(function() {
65                        this.wxCheck();
66                    }.bind(this), 2000);
67                    return;
68                }
69                if (code == 2) {
70                    this.$message.info(res.data.data.message);
71                    setTimeout(function() {
72                        location.href = "/login/bind";
73                    }, 2000);
74                    return;
75                }
76                if (code == 1) {
77                    this.$message.success(res.data.data.message);
78                    setTimeout(function() {
79                        this.redirect()
80                    }.bind(this), 1500);
81                    return;
82                }
83                this.$message.info(res.message);
84            }.bind(this));
85        },
86        keyupSubmit: function keyupSubmit(e) {
87            if (e.keyCode === 13 && e.key === "Enter") {
88                this.submitLogin();
89            }
90        },
91        submitLogin: function submitLogin() {
92            var that = this;
93
94            if (!this.form.username) {
95                this.$alert((this.login_type === 0 ? "请输入账户!" : '请输入手机号码!'), "系统提示", { type: "error", confirmButtonText: "确定"});
96                return false;
97            }
98            if(this.login_type === 0) {
99                if (!this.form.password) {
100                    this.$alert("请输入密码!", "系统提示", { type: "error", confirmButtonText: "确定"});
101                    return false;
102                }
103            }else{
104                if (!this.form.verify_code) {
105                    this.$alert("请输入短信验证码!", "系统提示", { type: "error", confirmButtonText: "确定"});
106                    return false;
107                }
108            }
109            var form = deepClone(this.form)
110            form.login_type = this.login_type;
111            this.$api.post("/authorizations", form, {processMessage: '正在登录...', watchStatus: [412]}).then(function(res) {
112                var data = res.data && res.data.data
113                if (data && data.need_choose_account && data.accounts && data.sms_multi_key) {
114                    that.sms_step = 2
115                    that.accountList = data.accounts
116                    that.sms_multi_key = data.sms_multi_key
117                    return
118                }
119                that.$message.success("登录成功!");
120                setTimeout(function() {
121                    that.redirect()
122                }, 1500);
123            }).catch(function (res){
124                if(res.response && res.response.status === 412){
125                    this.showRegisterConfirm()
126                }
127            }.bind(this));
128        },
129        chooseAccount: function chooseAccount(acc) {
130            var that = this;
131            this.$api.post("/authorizations/confirm_sms_login", {
132                sms_multi_key: this.sms_multi_key,
133                user_id: acc.id
134            }, {processMessage: '正在登录...'}).then(function() {
135                that.$message.success("登录成功!");
136                setTimeout(function() {
137                    that.redirect()
138                }, 1500);
139            });
140        },
141        redirect(){
142            var referrer_url = this.$query.callback;
143            var redirect_url = this.$query.redirect;
144
145            if (referrer_url) {
146                location.href = referrer_url;
147                return;
148            }
149
150            if (redirect_url) {
151                location.href = redirect_url;
152                return;
153            }
154
155            if (document.referrer.indexOf('/register') !== -1) {
156                location.href = '/';
157                return;
158            }
159            location.href = document.referrer || '/';
160        },
161        showRegisterConfirm: function (){
162            this.$confirm('账号尚未注册,立即前往注册?', '账号未注册', {confirmButtonText: '注册会员'}).then(function (){
163                window.location = '/register'
164            });
165        },
166        // 发送短信验证码
167        sendSmsCode: function sendSmsCode() {
168            var that = this;
169            that.$api.post("/sms", {
170                phone: that.form.username,
171                action: "sms_login"
172            }, {watchStatus: [412]}).then(function(res) {
173                that.verifyDialog = false;
174                that.$message({
175                    type: "success",
176                    message: "发送成功!"
177                });
178                that.form.sms_key = res.data.data.sms_key;
179                that.countDown();
180            }).catch(function (res){
181                if(res.response && res.response.status === 412){
182                    this.showRegisterConfirm()
183                }
184            }.bind(this));
185        },
186        countDown: function countDown() {
187            var that = this;
188            if (!that.canClick) return; // 改动的是这两行代码
189
190            that.canClick = false;
191            that.content = that.totalTime + "s后重新发送";
192            var clock = window.setInterval(function() {
193                that.totalTime--;
194                that.content = that.totalTime + "s后重新发送";
195
196                if (that.totalTime < 0) {
197                    window.clearInterval(clock);
198                    that.content = "重新发送";
199                    that.totalTime = 60;
200                    that.canClick = true; // 这里重新开启
201                }
202            }, 1000);
203        },
204        backTop: function() {
205            // window.history.go(-1);
206            location.href = document.referrer
207        }
208    },
209    computed: {
210        writeLimit: function() {
211            var member = this.member
212            var temp = []
213            if (!member.login_methods) {
214                return '请输入账号'
215            }
216            if (member.login_methods.indexOf('phone_number') !== -1) temp.push('手机号')
217            if (member.login_methods.indexOf('email') !== -1) temp.push('邮箱')
218            if (member.login_methods.indexOf("username") !== -1) temp.push('用户名')
219            if (member.login_methods.indexOf('id') !== -1) temp.push('ID')
220
221            return '请输入' + temp.join('/')
222        },
223        basic: function() {
224            return this.sharedState.basic;
225        },
226        member: function() {
227            return this.sharedState.member;
228        },
229        userInfo: function() {
230            return this.sharedState.userInfo;
231        },
232        banners: function() {
233            return getBanners("login");
234        }
235    },
236    created: function() {
237        if (this.userInfo) {
238            location.href = "/";
239        }
240        if (this.member.sms_login_enable) this.login_type = 1
241    }
242});

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.