(function(v,w,d,q,_self){
q(function(q){
class Login{
constructor(...params) {
try{
this.pageData = pageData
}catch(e){
this.pageData = {}
}
this.translate = this.pageData.translate ? this.pageData.translate : {}
this.lang = this.pageData.lang ? this.pageData.lang : ''
this.name = this.pageData.name ? this.pageData.name : ''
this.link = this.pageData.link ? this.pageData.link : []
this.forgoturl = this.pageData.forgoturl ? this.pageData.forgoturl : []
this.ordersList = this.pageData.ordersList ? this.pageData.ordersList : []
this.countryList = this.pageData.countryList ? this.pageData.countryList : []
this.industryList = this.pageData.industryList ? this.pageData.industryList : []
this.api = this.pageData.api ? this.pageData.api : ''
this.email = this.pageData.email ? this.pageData.email : ''
this.loading = false
this.bigPage = this.pageData.bigPage ? true : false
this.googleRecaptcheClientKey = this.pageData.gc_client_key ? this.pageData.gc_client_key : ''
return this.initApp()
}
initApp(){
_self = this
this.registeredApp()
this.app = new v({el : "#app",})
return false
}
registeredApp(){
this.registered()
v.component("App",{
template:`
{{ errorMessage }}
${_self.translate.clause}
`,
data(){
return {
link : _self.link,
email : _self.email,
// username : '',
password : '',
firstname : '',
lastname : '',
errorMessage : '',
}
},
methods:{
showError(message){
this.errorMessage = message
},
handleSubmit(e){
this.errorMessage = ''
if(e) e.stopPropagation()
if(!this.firstname) return this.$refs.firstname.showError(_self.translate.t113)
if(!this.$refs.firstname.checkFirstnameFormat(this.firstname)) return this.$refs.firstname.showError(_self.translate.t119)
if(!this.lastname) return this.$refs.lastname.showError(_self.translate.t113)
if(!this.$refs.lastname.checkLastnameFormat(this.lastname)) return this.$refs.lastname.showError(_self.translate.t119)
if(!this.email) return this.$refs.email.showError(_self.translate.t113)
if(!this.$refs.email.checkEmailFormat(this.email)) return this.$refs.email.showError(_self.translate.t111)
if(!this.password) return this.$refs.newPassword.error = true
if(!this.$refs.newPassword.cCheckNewPassword(this.password)) return this.$refs.newPassword.error = true
this.$refs.button.loading = true
let _that = this
grecaptcha.ready(function() {
grecaptcha.execute(_self.googleRecaptcheClientKey, {action: 'submit'}).then(function(token) {
_self.sendRequest({
type : _self.name,
email : _that.email,
password : _that.password,
firstname : _that.firstname,
lastname : _that.lastname,
// username : this.username,
token: token,
},_that.handleResponse)
});
});
},
handleResponse(code,message,data){
return _self.handleResponse(this,code,message,data)
}
},
})
}
registeredLogin(){
v.component("Login",{
template:`
{{ errorMessage }}
${_self.translate.clause}
`,
data(){
return {
link : _self.link,
errorMessage : '',
email : _self.email,
password : '',
loading : false,
line: true
}
},
methods:{
showError(message){
this.errorMessage = message
},
handleSubmit(e){
this.errorMessage = ''
if(e) e.stopPropagation()
if(!this.email) return this.$refs.email.showError(_self.translate.t113)
if(!this.$refs.email.checkEmailFormat(this.email)) return this.$refs.email.showError(_self.translate.t111)
if(!this.password) return this.$refs.password.showError(_self.translate.t113)
if(!this.$refs.password.checkPasswordFormat(this.password)) return this.$refs.password.showError(_self.translate.t112)
this.$refs.button.loading = true
_self.sendRequest({
type : _self.name,
email : this.email,
password : this.password,
forward : _self.pageData.forward,
},this.handleResponse)
},
handleResponse(code,message,data){
return _self.handleResponse(this,code,message,data)
}
}
})
}
registeredLoginManage(){
v.component("LoginManage",{
template:`
第一步:
登录手机应用,通过搜索关键词 “ Authenticator ” 下载任意一款两步验证应用
第二步:
打开两步验证应用,然后扫描下方二维码获取应用授权,最后在两步验证页面,输入两步验证码即可提交登录
{{ errorMessage }}
`,
data(){
return {
link : _self.link,
// errorMessage : '',
errorMsg : _self.pageData.status,
errorMessage : _self.translate.t116,
email : _self.email,
password : '',
code : '',
qrsrc: _self.pageData.qrsrc,
status: _self.pageData.status,
loading : false,
line: true
}
},
methods:{
showError(message){
this.errorMessage = message
},
handleSubmit(e){
this.errorMessage = ''
if(e) e.stopPropagation()
if (!this.code) return this.$refs.code.showError(_self.translate.t113)
if (this.code.length !== 6) return this.$refs.code.showError(_self.translate.t115)
this.$refs.button.loading = true
_self.sendRequest({
type : _self.name,
email : this.email,
code : this.code,
},this.handleResponse)
},
handleResponse(code,message,data){
return _self.handleResponse(this,code,message,data)
}
}
})
}
registeredForgotPassword(){
v.component("ForgotPassword",{
template:`
${_self.translate.t5}
${_self.translate.describe}
`,
data(){
return {
link : _self.link,
email : '',
isManage : _self.pageData.isManage,
}
},
methods:{
handleSubmit(e){
if(e) e.stopPropagation()
if(!this.email) return this.$refs.email.showError(_self.translate.t113)
if(!this.$refs.email.checkEmailFormat(this.email)) return this.$refs.email.showError(_self.translate.t111)
this.$refs.button.loading = true
let _that = this
grecaptcha.ready(function() {
grecaptcha.execute(_self.googleRecaptcheClientKey, {action: 'submit'}).then(function(token) {
_self.sendRequest({
type : _self.name,
email : _that.email,
isManage : _that.isManage,
token: token,
},_that.handleResponse)
});
});
},
handleResponse(code,message,data){
return _self.handleResponse(this,code,message,data)
}
}
})
}
registeredChangePassword(){
v.component("ChangePassword",{
template:`
We've sent a 6-character code to
{{email}}
Please enter it below to verify your identity.
Didn't receive it? Check your spam folder, or resend email.
{{ errorMessage }}
`,
data(){
return {
errorMessage : '',
email : _self.email,
verifycode : '',
loading : false,
}
},
created(){
this.sendAuthCode(true)
},
methods:{
showError(message){
this.errorMessage = message
},
subCheckVerifyCode(verifycode){
let pattern = new RegExp("(^[0-9]{6}$)")
if (pattern.test(verifycode)) return true
this.verifycode = ''
return false
},
sendAuthCode(hideTip = false){
_self.sendRequest({
type : 'auth-send-code',
email : this.email,
}, (code, message, data) => {
if (!hideTip) {
return UIkit.notification({message: message , pos: 'top-center',timeout: 3000})
}
})
},
handleSubmit(e){
this.errorMessage = ''
if(e) e.stopPropagation()
if(!this.subCheckVerifyCode(this.verifycode)) return this.$refs.verifycode.showError(_self.translate.t111)
this.$refs.button.loading = true
_self.sendRequest({
type : _self.name,
email : this.email,
auth_type : _self.translate.auth_type_name,
verifycode : this.verifycode,
},this.handleResponse)
},
handleResponse(code,message,data){
return _self.handleResponse(this,code,message,data)
}
}
})
}
sendRequest(data,callback){
if(_self.loading) return false
_self.loading = true
q.ajax({
url : this.api,
type : 'post',
data : data,
success : function(r){
_self.loading = false
try{
let result = JSON.parse(r)
let code = result.code ? parseInt(result.code) : 0
let message = result.message ? result.message : 0
let data = result.data ? result.data : {}
if(callback) callback(code,message,data)
}catch(e){
if(callback) callback(0,'',{})
}
}
})
}
handleResponse(_this,code,message,data){
_this.$refs.button.loading = false
try{
if(code !== 200)
{
if(code === 302){
let url = data.location ? data.location : ''
url = decodeURIComponent(url)
let time = data.time ? data.time : 0
if(url) time > 0 ? setTimeout(() => {
w.location.href = url
},time) : w.location.href = url
}
let name = data.name ? data.name : ''
if(!name || !_this.$refs[name] || !_this.$refs[name].showError){
switch (name) {
case 'Orders': {
console.log(_this.$refs[name])
return _this.error.Orders = message
}
case 'Country': {
return _this.error.Country = message
}
case 'Industry': {
return _this.error.Industry = message
}
default: {
return _this.showError(message)
}
}
}
return _this.$refs[name].showError(message)
}
_this.$parent.showLoading(true)
let url = data.location ? data.location : ''
url = decodeURIComponent(url)
let time = data.time ? data.time : 0
if(url) time > 0 ? setTimeout(() => {
w.location.href = url
},time) : w.location.href = url
}catch(e){
return e
}
}
}
let ln = new Login()
})
}(Vue,window,document,$,{}))