var content = { 'cn': { headers1: '登录', headers2: 'CWG Markets', headers3: '匠鑫学院CWG杯
实盘交易大赛', table1: '交易排名', table2: '最近更新:', table3: '排名', table4: '姓名', table5: '交易账号', table6: '盈利百分比', table7: '暂无数据', footer1: '© 2023 CWG MARKETS', footer2: '隐私政策', footer3: '条款和条件', }, 'en': { headers1: 'Login', headers2: 'CWG Markets', headers3: 'Craftsmen Academy CWG
Cup Live Trading Competition', table1: 'Transaction Ranking', table2: 'Last Updated: ', table3: 'Rank', table4: 'Name', table5: 'Trading Account', table6: 'Profitability', table7: 'Not Data', footer1: '© 2023 CWG MARKETS', footer2: 'Privacy Policy', footer3: 'Terms & Conditions', } } let vm = new Vue({ el: "#active1", data: { //多语言 langList: { en: "ENGLISH", cn: "中文简体" }, language: "en", lang: {}, flag: false, loading: false, mock_options: { time:'', list:[] }, // img_logo: logo, timer: 59, interval: null, getCodeString: "", notCountry:[ 'AF','AI','AG','BS','BY', 'BZ','BA','BI','CF','CD','CU', 'ET','FJ','PS','GN','GW','HT', 'IR','IQ','LB','LY','ML','MM', 'NI','KP','PW','RU','SO','SS', 'SD','SY','UA','US','VE','YE','ZW','MY' ], // 表单参数 params: { agentId: null, comPoint: null, sourceCode:null, subId: "", email: "", password: "", country: "", emailCode: "", phone: "", w: "", agree: false, linkValue: null, }, clientWidth:'', pagerInfo: {row: 10, current: 1, pageTotal: 0, rowTotal: 0},//分页 pictLoading:false, // 验证规则 rules: { country: [ { validator: (rule, value, callback) => { if (value != "" && value != null) { callback(); } else { callback(new Error(content[sessionStorage.getItem('lang')].country)); } }, trigger: "blur", }, ], email: [ { validator: (rule, value, callback) => { if (/^[\w-]+(\.[\w-]+)*@[\w-]+(\.[\w-]+)+$/.test(value)) { callback(); } else { callback(new Error(content[sessionStorage.getItem('lang')].email)); } }, trigger: "blur", }, ], emailCode: [ { validator: (rule, value, callback) => { if ( value != "" && value != null ) { callback(); } else { callback(new Error(content[sessionStorage.getItem('lang')].codeInput)); } }, trigger: "blur", }, ], password: [ { validator: (rule, value, callback) => { if (/^(?=.*[A-Z])(?=.*[a-z])(?=.*[0-9])(?!.*([~!@&%$^\\(\\)#_]).*\\1.*\\1.*\\1)[A-Za-z0-9~!@&%$^\\(\\)#_]{8,16}$/.test(value)) { callback(); } else { callback(new Error(content[sessionStorage.getItem('lang')].password)); } }, trigger: "blur", }, ], agree: [ { validator: (rule, value, callback) => { if (value) { callback(); } else { callback(new Error(content[sessionStorage.getItem('lang')].agree)); } }, trigger: "change", }, ], phone: [ { validator: (rule, value, callback) => { if (/^[0-9]\d*$/.test(value)) { callback(); } else { callback(new Error(content[sessionStorage.getItem('lang')].phone)); } }, trigger: "blur", }, ], }, notRegisterMsg:"", notRegisterMsgOpen:false, imgUrl: '', ho: '', isPc:null, centerDialogVisible:false, }, computed: { rule1: function () { if (!this.params.password) { return false; } return /^.{8,16}$/.test(this.params.password); }, rule2: function () { return /^(?=.*?[a-z])(?=.*?[A-Z]).*$/.test(this.params.password); }, rule3: function () { return /^(?=.*[A-Z])(?=.*[a-z])(?=.*[0-9])(?!.*([~!@&%$^\\(\\)#_]).*\\1.*\\1)[A-Za-z0-9~!@&%$^\\(\\)#_]{8,16}$/.test( this.params.password ); }, }, methods: { // 语言切换函数 chooseLang(key) { this.lang = content[key]; this.language = key; sessionStorage.setItem("lang", this.language); location.reload(); this.initTimer(); }, //分页返回数据 handleSizeChange (val) { this.pagerInfo.row = val; this.searchFunc(); }, handleCurrentChange (val) { this.pagerInfo.current = val; this.searchFunc(); }, //获取列表数据 async searchFunc () { this.pictLoading = true; axios.post(this.imgUrl + '/custom/activity/hundred/agent/vip/ranking', { page: { current: this.pagerInfo.current, row: this.pagerInfo.row } //参数 }).then(res => {//请求成功后的处理函数 if (res.data.code == 200) { if (res.data.data && res.data.data.length) { this.mock_options.list = res.data.data; this.mock_options.time = res.data.data[0].addTime.split(' ')[0]; } if (res.data.page != null) { this.pagerInfo.rowTotal = res.data.page.rowTotal; this.pagerInfo.pageTotal = res.data.page.pageTotal; } else { this.pagerInfo.rowTotal = 0; } this.pictLoading = false; } else { this.$message.error(res.data.msg); this.pictLoading = false; } }).catch(err => {//请求失败后的处理函数 this.pictLoading = false; }) }, //获取国家列表 async getCountry() { axios.post(this.imgUrl + '/country/get', { ...this.params //参数 }).then(res => {//请求成功后的处理函数 if (res.data.code == 200) { this.mock_options = res.data.data; } else { this.$message.error(res.data.msg); } }).catch(err => {//请求失败后的处理函数 }) }, //获取当前国家编码 async getCountryMsg() { axios.get(this.imgUrl + '/country/get', { //参数 }).then(res => {//请求成功后的处理函数 if (res.data.code == 200) { this.notRegisterMsg = res.data.msg if ((res.data.msg == "GB"||res.data.msg == "IE")&&res.data.data.indexOf('//195.224.141.218') == -1) { window.location.href = 'https://www.cwgmarkets.co.uk'; } else { document.getElementById("pre").style.display = 'none' } } else { document.getElementById("pre").style.display = 'none' this.$message.error(res.data.msg); } }).catch(err => {//请求失败后的处理函数 }) }, //获取当前国家编码 async getCountryCode() { axios.post(this.imgUrl + '/country/getCodeByIp', { //参数 }).then(res => {//请求成功后的处理函数 if (res.data.code == 200) { if (this.notCountry.indexOf(res.data.msg)==-1) { this.params.country = res.data.msg; } if (!sessionStorage.getItem("timer")) { let lang = sessionStorage.getItem("lang") ? sessionStorage.getItem("lang") : this.params.country == "CN" ? "cn" : "en"; sessionStorage.clear(); sessionStorage.setItem("lang", lang); } else { let timer = sessionStorage.getItem("timer"); let lang = sessionStorage.getItem("lang") ? sessionStorage.getItem("lang") : this.params.country == "CN" ? "cn" : "en"; sessionStorage.clear(); sessionStorage.setItem("lang", lang); sessionStorage.setItem("timer", timer); } this.language = sessionStorage.getItem("lang"); this.lang = content[this.language]; this.initTimer(); } else { this.$message.error(res.data.msg); } }).catch(err => {//请求失败后的处理函数 }) }, // 注册 register: async function () { if (this.notRegisterMsg == 'MY') { this.notRegisterMsgOpen = true; return } this.$refs["params"].validate(async (valid) => { if (valid) { if (this.flag) { return; } else { this.flag = true; } axios.post(this.imgUrl + '/custom/register', { ...this.params //参数 }).then(res => {//请求成功后的处理函数 if (res.data.code == 200) { this.loading = true; this.$message({ message: this.lang.registerSuc, type: 'success' }); this.login(); this.flag = false; } else { this.$message.error(res.data.msg); this.flag = false; } }).catch(err => {//请求失败后的处理函数 }) } else { return false; } }); }, // 登陆 login: async function () { axios.post(this.imgUrl + '/custom/login', { loginName: this.params.email, password: this.params.password, //参数 }).then(res => {//请求成功后的处理函数 if (res.data.code == 200) { sessionStorage.setItem("access_token", res.data.data); axios.defaults.headers.common["Access-Token"] = res.data.data; this.getLoginInfo(); } else { this.$message.error(res.data.msg); } }).catch(err => {//请求失败后的处理函数 }) }, //获取登录信息 async getLoginInfo() { axios.post(this.imgUrl + '/custom/info', { //参数 }).then(res => {//请求成功后的处理函数 if (res.data.code == 200) { this.loading = true; // this.$store.commit("InitInfo", res.data.data); this.$message({ message: this.lang.LoginSuccess, type: 'success' }); setTimeout(() => { this.loading = false; Session.Set("user", JSON.stringify(res.data.data), true) window.location.href = this.imgUrl + '/#/customer/index'; }, 1000); } else { this.$message.error(this.lang.SystemError); } }).catch(err => {//请求失败后的处理函数 }) }, // 获取验证码 getCode: async function (val) { if (val) { if (!this.params.country) { this.$message.error(content[sessionStorage.getItem("lang")].country); return; } if (!this.params.email) { this.$message.error(content[sessionStorage.getItem("lang")].emailempty); return; } if (!/^[\w-]+(\.[\w-]+)*@[\w-]+(\.[\w-]+)+$/.test(this.params.email)) { this.$message.error(content[sessionStorage.getItem("lang")].email); return; } } this.getCodeString = content[sessionStorage.getItem("lang")].waitCode1 + this.timer + content[sessionStorage.getItem("lang")].waitCode2; let that = this; if (!this.interval) { this.getCode1(val); this.interval = setInterval(() => { that.timer--; sessionStorage.setItem("timer", that.timer); that.getCodeString = content[sessionStorage.getItem("lang")].waitCode1 + that.timer + content[sessionStorage.getItem("lang")].waitCode2; if (that.timer == 0) { this.getCodeString = content[sessionStorage.getItem("lang")].code; clearInterval(that.interval); that.interval = null; that.timer = 59; sessionStorage.setItem("timer", that.timer); } }, 1000); } }, //验证码 async getCode1(val) { if (val) { axios.post(this.imgUrl + '/custom/register/send/code', { ...this.params //参数 }).then(res => {//请求成功后的处理函数 if (res.data.code == 200) { this.$message({ message: this.lang.CodeSuccess, type: 'success' }); } else { this.$message.error(res.data.msg); } }).catch(err => {//请求失败后的处理函数 }) } }, // 初始化定时器 initTimer: function () { let t = sessionStorage.getItem("timer") || this.timer; if (t == 59) { this.getCodeString = content[sessionStorage.getItem("lang")].code; } else { this.timer = sessionStorage.getItem("timer"); this.getCode(0); } }, getQueryStringRegExp(name){ var reg = new RegExp("(^|\\?|&)"+ name +"=([^&]*)(\\s|&|$)", "i"); if (reg.test(location.href)) return unescape(RegExp.$2.replace(/\+/g, " ")); return ""; }, getCodeQuery(){ this.params.sourceCode = this.getQueryStringRegExp('ex') this.params.w = this.getQueryStringRegExp('w') this.params.subId = this.getQueryStringRegExp('SUBID') this.params.agentId = Number(this.getQueryStringRegExp('mmdi')) || null; this.params.linkValue = this.getQueryStringRegExp('mmF') switch (this.getQueryStringRegExp('mmF')) { case "F0": this.params.comPoint = 0; break; case "F1": this.params.comPoint = 10; break; case "F2": this.params.comPoint = 20; break; case "F3": this.params.comPoint = 30; break; } switch (this.getQueryStringRegExp('mmB')) { case "B0": this.params.ibInvalid = 0; break; case "B1": this.params.ibInvalid = 1; break; } }, //判断pc、移动 IsPC() { var userAgentInfo = navigator.userAgent; var Agents = ['Android', 'iPhone', 'SymbianOS', 'Windows Phone', 'iPad', 'iPod' ]; var flag = true; for (var i = 0; i < Agents.length; i++) { if (userAgentInfo.indexOf(Agents[i]) != -1) { flag = false; break; } } return flag; }, openMP4(){ this.centerDialogVisible = true; }, }, watch:{ 'centerDialogVisible'(val){ if (!val) { document.getElementById("videoplayer").pause(); } } }, mounted() { // console.log(document.body.clientWidth); // this.clientWidth = document.body.clientWidth; // if (window.location.search.indexOf('&ex=') != '-1') { // this.params.sourceCode = window.location.search.split('&ex=')[1] || null; // } else if (window.location.search.indexOf('?ex=') != '-1') { // this.params.sourceCode = window.location.search.split('?ex=')[1] || null; // } // this.getCodeQuery(); this.ho = window.location.host.split('.')[1]; this.imgUrl = window.location.origin; // this.imgUrl = 'http://45.136.12.50:8000'; this.getCountryMsg() if (sessionStorage.getItem("lang")) { this.language = sessionStorage.getItem("lang"), this.lang = content[sessionStorage.getItem("lang")]; } else { var jsSrc =(navigator.language || navigator.browserLanguage).toLowerCase(); if(jsSrc.indexOf('zh') >= 0){ this.language = 'cn' this.lang = content['cn']; }else{ this.language = 'en' this.lang = content['en']; } sessionStorage.setItem("lang", this.language); } this.searchFunc();//获取列表数据 //获取国家 // this.getCountryCode(); // this.getCountry(); // this.initTimer(); //是否pc // if (this.IsPC()) { // this.isPc = true; // } else { // this.isPc = false; // } }, destroyed() { clearInterval(this.interval); }, });