(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.two_factor_send_email_code = this.pageData.two_factor_send_email_code ? this.pageData.two_factor_send_email_code : ''
this.two_send_email_url = this.pageData.two_send_email_url ? this.pageData.two_send_email_url : ''
this.check_two_send_email_url = this.pageData.check_two_send_email_url ? this.pageData.check_two_send_email_url : ''
this.two_factor_authentication_submit = this.pageData.two_factor_authentication_submit ? this.pageData.two_factor_authentication_submit : ''
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.nocheck_message}
`,
data(){
return {
link : _self.link,
email : _self.email,
// username : '',
password : '',
firstname : '',
lastname : '',
errorMessage : '',
isSendCode : false,
second : 60,
verifycode: '',
emailError: '',
emailUrl: '',
isFirst: true,
verifycodeError: false,
cftoken: '',
isChecked: true,
}
},
computed: {
disable() {
if(!this.firstname) return true;
if(!this.$refs.firstname.checkFirstnameFormat(this.firstname)) return true;
if(!this.lastname) return true;
if(!this.$refs.lastname.checkLastnameFormat(this.lastname)) return true;
if(!this.email) return true;
if(!this.$refs.email.checkEmailFormat(this.email)) return true;
if(!this.password) return true;
if(!this.$refs.newPassword.cCheckNewPassword(this.password)) return true;
// 验证cf的token
if(!this.cftoken) return true;
if(!this.isChecked){
return true;
}
return false;
},
},
watch: {
email(val, old) {
if (val !== old) this.emailUrl = ''
},
// verifycode(val, old) {
// if (val !== old) this.verifycodeError = false
// },
},
mounted() {
this.$refs.firstname.handleFocus()
// CF Turnstile
turnstile.ready(() => {
turnstile.render('#cf-turnstile-container', {
sitekey: '0x4AAAAAAAgo2PH-EZFDzaTA',
// sitekey: '1x00000000000000000000AA',
callback: (token) => {
this.cftoken = token;
},
});
});
},
methods:{
setCheck:function(){
this.check = !this.check
console.log(this.check)
},
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
_self.sendRequest({
type : _self.name,
email : _that.email,
password : _that.password,
firstname : _that.firstname,
lastname : _that.lastname,
verifycode: _that.verifycode,
token: _that.cftoken,
}, _that.handleResponse)
// 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,
// verifycode: _that.verifycode,
// // username : this.username,
// token: token,
// },_that.handleResponse)
// });
// });
},
handleResponse(code,message,data){
if (data?.name) this.verifycodeError = true
return _self.handleResponse(this,code,message,data)
},
getVerifycode(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.isSendCode = true
_self.sendRequest({
type : 'get-verify-code',
name : _self.name,
email : this.email,
}, this.handleCodeRespone)
this.isFirst = false
this.$refs.verifycode.handleFocus()
},
handleCodeRespone(code, message, data){
if (code !== 200)
{
this.isSendCode = false
if ([4005, 4006, 4007].includes(code)) return this.handleResponse(code,message,data)
return this.$refs.verifycode.showError(message)
}
if (data['email_url']) {
this.emailUrl = data['email_url']
}
const st = setInterval(() => {
this.second --
if (this.second <= 0)
{
clearInterval(st)
this.isSendCode = false
this.second = 60
}
}, 1000)
},
cleanCode(){
this.inputValue = ''
},
},
})
}
registeredLogin(){
//
第一步:
登录手机应用,通过搜索关键词 “ 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)
}
}
})
}
twoFactorAuthentication(){
v.component("TwoFactorAuthentication",{
template:`
{{email}}
${_self.translate.t5}
${_self.translate.describe}
{{showErrorMassge}}
`,
created(){
this.resetVerifyCode()
},
mounted(){
this.isSendCode = true
},
beforeDestroy() {
clearInterval(this.countdownTwoAuthId)
},
data(){
return {
link : _self.link,
email : _self.email,
isManage : _self.pageData.isManage,
verifycode : "",
check_two_send_email_url :_self.pageData.check_two_send_email_url,
two_send_email_url :_self.pageData.two_send_email_url,
isSendCode : false,
second : 60,
showErrorMassge : "",
countdownTwoAuthId: "",
}
},
methods:{
previousPage() {
history.go(-1)
},
//倒计时
countdownTwoAuth(){
this.countdownTwoAuthId = setInterval(() => {
this.second --
if (this.second <= 0)
{
clearInterval(this.countdownTwoAuthId)
this.isSendCode = false
setTimeout(()=>{
$('.rest-verify').text(_self.translate.t41)
},10)
}
$(".rest-sended").text(this.second)
}, 1000)
},
// 重发二次验证邮件验证码
resetVerifyCode(e){
if(e) e.stopPropagation()
let _that = this
this.countdownTwoAuth()
this.isSendCode = true
_self.sendRequestRestCode(this.two_send_email_url,{
type : _self.two_factor_send_email_code,
email : _self.email,
isManage : _that.isManage,
},_that.handleResponse);
},
handleSubmitVerifyCode(e){
if(e) e.stopPropagation()
_self.verifycode = this.verifycode
if(!this.subCheckVerifyCode(this.verifycode)) return this.$refs.verifycode.showError(_self.translate.t111)
this.$refs.button.loading = true
let _that = this
try {
//校验验证码
_self.sendRequestRestCode(this.check_two_send_email_url,{
type : _self.check_two_send_email_url,
email : _self.email,
verify : this.verifycode,
isManage : _that.isManage,
},_that.handleResponseSubmit);
} catch (error) {
this.showErrorMassge = error.message || "";
}
},
handleResponse(code,message,data){
if (code != 200) {
this.showErrorMassge = message
} else {
let url = data.location ? data.location : ''
url = decodeURIComponent(url)
if(url) w.location.href = url
}
},
handleResponseSubmit(code,message,data){
if (code != 200) {
this.showErrorMassge = message
} else {
// 提交并登录
console.log(_self.two_factor_authentication_submit)
console.log(_self.verifycode)
console.log(_self.email)
_self.sendRequest({
type : _self.two_factor_authentication_submit,
verifycode : _self.verifycode,
email : _self.email,
lang : _self.lang,
},this.handleResponse);
}
},
subCheckVerifyCode(verifycode){
let pattern = new RegExp("(^[0-9]{6}$)")
if (pattern.test(verifycode)) return true
this.inputValue = ''
return false
},
}
})
}
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:`
No country found
{{ errorMessage }}
`,
data(){
return {
email : _self.email,
errorMessage : null,
company : '',
website : '',
mobile: '',
optionCountry : _self.countryList,
optionCountryValue: [],
optionOrdersList : _self.ordersList,
OrdersListValue : [],
optionIndustry : _self.industryList,
optionIndustryValue: [],
translations: {
countrySelectorLabel: null,
phoneNumberLabel: _self.translate.t118,
},
results: null,
error: {
Orders: false,
Country: false,
Industry: false
},
}
},
props: {
defaultCountryCode: {
type: String,
},
clearable : {
type : Boolean,
default : true,
},
showCodeOnList: {
type: Boolean,
default: true,
},
},
watch: {
optionCountryValue(val) {
if(val) this.error.Country = false
},
OrdersListValue(val) {
if(val) this.error.Orders = false
},
optionIndustryValue(val) {
if(val) this.error.Industry = false
},
},
created() {
if (_self.translate.t2000) {
this.optionCountryValue = {"name": _self.translate.t2000, "value": _self.translate.t2000}
}
},
methods:{
showError(message){
this.errorMessage = message
},
setError(key, value = null) {
this.error[key] = value
return false
},
handleData(data) {
let dataArr = []
if(data.length > 0) {
data.map((v) => {
if(v) dataArr.push(v.value)
})
}
return dataArr.join(',')
},
handleSubmit(e){
if(e) e.stopPropagation()
if(!this.company) return this.$refs.company.showError(_self.translate.t315)
if(!this.$refs.company.checkCompanyFormat(this.company)) return this.$refs.company.showError(_self.translate.t111)
if(!this.optionCountryValue.length === 0) return this.setError('Country', _self.translate.t315)
this.setError('Country')
if(!this.website) return this.$refs.website.showError(_self.translate.t315)
if(this.website.length > 100) return this.$refs.website.showError(_self.translate.t114)
if(!this.$refs.website.checkWebsiteFormat(this.website)) return this.$refs.website.showError(_self.translate.t112)
if(this.optionIndustryValue.length === 0) return this.setError('Industry', _self.translate.t116)
this.setError('Industry')
if(this.OrdersListValue.length === 0) return this.setError('Orders', _self.translate.t115)
this.setError('Orders')
let phoneCode = this.results ? (this.results.countryCallingCode != undefined ? this.results.countryCallingCode : '') : ''
let nationalNumber = this.results ? (this.results.nationalNumber != undefined ? this.results.nationalNumber : '') : ''
let phone = phoneCode + " " + nationalNumber
if(this.mobile){
if(!phone){
return $('.mobileerrormsg').html(_self.translate.t314).show()
}
if(this.results.isValid == false) return $('.mobileerrormsg').html(_self.translate.t314).show()
phone = "+" + phone
}
this.$refs.button.loading = true
_self.sendRequest({
email: this.email,
type: _self.name,
company: this.company,
country: this.handleData([this.optionCountryValue]),
website: this.website,
industry: this.handleData(this.optionIndustryValue),
order_quantity: this.handleData([this.OrdersListValue]),
phone: phone,
encrypt: _self.pageData.encrypt,
acticode: _self.pageData.acticode,
auth_source: _self.translate.t_source,
},this.handleResponse)
},
handleResponse(code,message,data){
return _self.handleResponse(this,code,message,data)
}
}
})
}
registeredNameInputStyle(){
v.component("NameInputStyle",{
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)
}
}
})
}
sendRequestRestCode(url, data,callback){
if(_self.loading) return false
_self.loading = true
q.ajax({
url : url,
type : 'post',
data : data,
success : function(r){
_self.loading = false
let result = r
if (typeof r == "string") {
result = JSON.parse(r)
}
let code = result.code ? parseInt(result.code) : 0
let message = result.message ? result.message : 0
console.log(result)
try{
let data = result.data ? result.data : {}
if(callback) callback(code,message,data)
}catch(e){
if(callback) callback(code,message,{})
}
}
})
}
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
let result = r
if (typeof r == "string") {
result = JSON.parse(r)
}
let code = result.code ? parseInt(result.code) : 0
let message = result.message ? result.message : 0
try{
let data = result.data ? result.data : {}
if(callback) callback(code,message,data)
}catch(e){
if(callback) callback(code,message,{})
}
}
})
}
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': {
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,$,{}))