| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127 |
- var content = {
- 'cn':{
- item1:'忘记密码',
- btn:'确定',
- item2:'密码格式错误',
- item3:'请输入新密码',
- item4:'请确认新密码',
- item5:"两次输入密码不一致!",
- success:'成功',
- },
- 'en':{
- item1:'Forget the 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',
- }
- };
- 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: {
- password: "",
- token:'',
- },
- rules: {
- password: [
- {
- 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.password) {
- callback(new Error(this.lang.item5));
- } else {
- callback();
- }
- },
- trigger: "blur"
- }
- ]
- }
- }
- },
- computed: {
- AccessToken(){
- return{
- 'Access-Token': window.location.search.split('?token=')[1]
- }
- }
- },
- 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';
- axios.defaults.headers.common['Access-Token'] = window.location.search.split('?token=')[1];
- axios.post('https://ad.' + this.ho + '.' + tld + '/user/update/email/password', {
- ...this.params
- //参数
- }).then(res => {//请求成功后的处理函数
- if (res.data.code == 200) {
- this.$message({
- message: this.lang.success,
- type: 'success'
- });
- setTimeout(() => {
- window.location.href = 'https://ad.' + 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];
- this.lang = content['cn'];
- }
- });
|