resetMam.js 2.7 KB

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