var content = { 'cn':{ item1:'重置交易密码', btn:'确定', item2:'密码格式错误', item3:'请输入新密码', item4:'请确认新密码', item5:"两次输入密码不一致!", success:'成功', st1: "使用8到15个字符", nd2: "同时使用大写和小写字母", rd3: "使用数字、英文字母和特殊符号的组合" }, 'en':{ item1:'Reset trading password', btn:'confirm', item2:'Wrong password format', item3:'Please enter a new password', item4:'Please confirm the new password', item5:"The two input passwords are inconsistent!", success:'Success', st1: "Must be between 8 to 15 characters", nd2: "Contain both uppercase and lowercase letter", rd3: "Use a combination of numbers , letters and special symbols" } }; let config = { Pattern: { Password: /^(?=.*[A-Z])(?=.*[a-z])(?=.*[0-9])(?=.*[~!@&%$^*./\\(\\)\\+\\=#_-])[A-Za-z0-9~!@&%$^*./\\(\\)\\+\\=#_-]{8,16}$/, } }; let vm = new Vue({ el: "#forget", data(){ return{ 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(this.lang.item2)); } }, trigger: "blur" } ], password1: [ { validator: (rule, value, callback) => { if (value === '') { callback(new Error(this.lang.item4)); } else if (value !== this.params.newPassword) { callback(new Error(this.lang.item5)); } else { callback(); } }, trigger: "blur" } ] } } }, computed: { AccessToken(){ return{ 'Access-Token': window.location.search.split('?token=')[1].split('&login=')[0] } }, rule1: function () { if (!this.params.newPassword) { return false; } return /^.{8,16}$/.test(this.params.newPassword); }, rule2: function () { return /^(?=.*?[a-z])(?=.*?[A-Z]).*$/.test(this.params.newPassword); }, rule3: function () { return /^(?=.*[A-Z])(?=.*[a-z])(?=.*[0-9])(?=.*[~!@&%$^*./\\(\\)\\+\\=#_-])[A-Za-z0-9~!@&%$^*./\\(\\)\\+\\=#_-]{8,16}$/.test( this.params.newPassword ); }, }, methods: { // 语言切换函数 chooseLang (key) { this.lang = content[key]; this.language = key; }, // 发送 send: async function () { this.$refs["params"].validate(async valid => { if (valid) { let hostParts = window.location.host.split('.'); let tld = hostParts.slice(2).join('.') || 'com'; let _this = this; axios.defaults.headers.common['Language'] = this.language == 'cn' ? 'cn' : 'en'; axios.defaults.headers.common['Access-Token'] = window.location.search.split('?token=')[1].split('&login=')[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' }); setTimeout(() => { window.location.href = 'https://secure.' + this.ho + '.' + tld }, 2000); } 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('?token=')[1].split('&login=')[0]; this.params.login = window.location.search.split('&login=')[1]; this.lang = content['cn']; } });