forget-20250813.js 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125
  1. var content = {
  2. 'cn':{
  3. item1:'忘记密码',
  4. btn:'确定',
  5. item2:'密码格式错误',
  6. item3:'请输入新密码',
  7. item4:'请确认新密码',
  8. item5:"两次输入密码不一致!",
  9. success:'成功',
  10. },
  11. 'en':{
  12. item1:'Forget the password',
  13. btn:'confirm',
  14. item2:'Wrong password format',
  15. item3:'Please enter a new password',
  16. item4:'Please confirm the new password',
  17. item5:"The two input passwords are inconsistent!",
  18. success:'success',
  19. }
  20. };
  21. let config = {
  22. Pattern: {
  23. Password: /^(?=.*[A-Z])(?=.*[a-z])(?=.*[0-9])(?=.*[~!@&%$^*./\\(\\)\\+\\=#_-])[A-Za-z0-9~!@&%$^*./\\(\\)\\+\\=#_-]{8,16}$/,
  24. }
  25. };
  26. let vm = new Vue({
  27. el: "#forget",
  28. data(){
  29. return{
  30. ho:'',
  31. //多语言
  32. langList: {
  33. en: "ENGLISH",
  34. cn: "中文简体"
  35. },
  36. language: "cn",
  37. lang:{},
  38. params: {
  39. password: "",
  40. token:'',
  41. },
  42. rules: {
  43. password: [
  44. {
  45. validator: (rule, value, callback) => {
  46. if (config.Pattern.Password.test(value)) {
  47. callback();
  48. } else {
  49. callback(new Error(this.lang.item2));
  50. }
  51. },
  52. trigger: "blur"
  53. }
  54. ],
  55. password1: [
  56. {
  57. validator: (rule, value, callback) => {
  58. if (value === '') {
  59. callback(new Error(this.lang.item4));
  60. } else if (value !== this.params.password) {
  61. callback(new Error(this.lang.item5));
  62. } else {
  63. callback();
  64. }
  65. },
  66. trigger: "blur"
  67. }
  68. ]
  69. }
  70. }
  71. },
  72. computed: {
  73. AccessToken(){
  74. return{
  75. 'Access-Token': window.location.search.split('?token=')[1]
  76. }
  77. }
  78. },
  79. methods: {
  80. // 语言切换函数
  81. chooseLang (key) {
  82. this.lang = content[key];
  83. this.language = key;
  84. },
  85. // 发送
  86. send: async function () {
  87. this.$refs["params"].validate(async valid => {
  88. if (valid) {
  89. axios.defaults.headers.common['Access-Token'] = window.location.search.split('?token=')[1];
  90. axios.post('https://ad.' + this.ho + '.com/user/update/email/password', {
  91. ...this.params
  92. //参数
  93. }).then(res => {//请求成功后的处理函数
  94. if (res.data.code == 200) {
  95. this.$message({
  96. message: this.lang.success,
  97. type: 'success'
  98. });
  99. setTimeout(() => {
  100. window.location.href = 'https://ad.' + this.ho + '.com'
  101. }, 2000);
  102. } else {
  103. this.$message.error(res.data.msg);
  104. }
  105. }).catch(err => { //请求失败后的处理函数
  106. })
  107. } else {
  108. return false;
  109. }
  110. });
  111. },
  112. },
  113. mounted() {
  114. this.ho = window.location.host.split('.')[1];
  115. this.params.token = window.location.search.split('?token=')[1];
  116. this.lang = content['cn'];
  117. }
  118. });