var content = { 'cn':{ item1:'重置交易密码', btn:'确定', item2:'密码格式错误', item3:'请输入新密码', success:'成功', }, 'en':{ item1:'Reset trading password', btn:'confirm', item2:'Wrong password format', item3:'Please enter a new password', success:'success', } }; let config = { Pattern: { Password: /^(?=.*[A-Z])(?=.*[a-z])(?=.*[0-9])(?=.*[~!@&%$^*./\\(\\)\\+\\=#_-])[A-Za-z0-9~!@&%$^*./\\(\\)\\+\\=#_-]{8,16}$/, } }; let vm = new Vue({ el: "#forget", data: { ho:'', //多语言 langList: { en: "ENGLISH", cn: "中文简体" }, language: "cn", lang:{}, params: { newPassword: "", token:'', login:'' }, rules: { newPassword: [ { validator: (rule, value, callback) => { if (config.Pattern.Password.test(value)) { callback(); } else { callback(new Error(content.en.item2)); } }, trigger: "blur" } ] } }, computed: { AccessToken(){ return{ 'Access-Token': window.location.href.split('=')[1] } } }, methods: { // 语言切换函数 chooseLang (key) { this.lang = content[key]; this.language = key; }, // 发送 send: async function () { this.$refs["params"].validate(async valid => { if (valid) { let _this = this; let hostParts = window.location.host.split('.'); let tld = hostParts.slice(2).join('.') || 'com'; axios.defaults.headers.common['Access-Token'] = window.location.search.split('=')[1].split('&')[0]; axios.post('https://secure.' + this.ho + '.' + tld + '/account/deal/password/reset/apply', { ...this.params //参数 }).then(res => {//请求成功后的处理函数 if (res.data.code == 200) { this.$message({ message: this.lang.success, type: 'success' }); } else { this.$message.error(res.data.msg); } }).catch(err => { //请求失败后的处理函数 }) } else { return false; } }); }, }, mounted() { this.ho = window.location.host.split('.')[1]; this.params.token = window.location.search.split('=')[1].split('&')[0]; this.params.login = window.location.search.split('=')[2]; 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']; } } });