bank.js 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  1. var content = {
  2. 'cn':{
  3. item1:'银行卡照片',
  4. UpdatePrompt: "银行卡照片上传,可减少因银行信息输入有误,而导致无法到账或到账不及时的情况",
  5. IMG: "上传图片大小不能超过 3MB!",
  6. JPG: "上传图片只能是 JPG、JPEG、PNG、PDF 格式!",
  7. btn:'确认上传',
  8. success:'上传成功,请在PC端查看...',
  9. },
  10. 'en':{
  11. item1:'Bank card photo',
  12. UpdatePrompt: "The uploading of bank card photos can reduce the situation that the account cannot be received or the account is not timely due to the wrong input of bank information",
  13. IMG: "Upload image size cannot exceed 3MB!",
  14. JPG: "Upload image can only be JPG, JPEG, PNG, PDF format!",
  15. btn:'Confirm upload',
  16. success:'Upload succeeded, please check on PC',
  17. }
  18. }
  19. let vm = new Vue({
  20. el: "#index",
  21. data: {
  22. ho:'',
  23. //多语言
  24. langList: {
  25. en: "ENGLISH",
  26. cn: "中文简体"
  27. },
  28. language: "cn",
  29. lang:{},
  30. imageUrl:'',
  31. imgUrl:''
  32. },
  33. computed: {
  34. AccessToken(){
  35. return{
  36. 'Access-Token': window.location.href.split('=')[1]
  37. }
  38. }
  39. },
  40. methods: {
  41. // 语言切换函数
  42. chooseLang (key) {
  43. this.lang = content[key];
  44. this.language = key;
  45. },
  46. //确认上传按钮
  47. update(){
  48. if (!this.imageUrl) {
  49. return
  50. }
  51. this.$message({
  52. message: content[this.language].success,
  53. type: 'success'
  54. });
  55. },
  56. //图片上传
  57. handleAvatarSuccess1 (res, file) {
  58. if (res.code == 200) {
  59. this.$message({
  60. message: res.msg,
  61. type: 'success'
  62. });
  63. this.imageUrl = URL.createObjectURL(file.raw);
  64. } else {
  65. this.$message.error(res.msg);
  66. }
  67. },
  68. beforeAvatarUpload (file) {
  69. const imageType = ['image/jpeg', 'image/png', 'image/jpg', 'image/pdf'];
  70. const isJPG = imageType.indexOf(file.type.toLocaleLowerCase()) == -1 ? false : true;
  71. const isLt2M = file.size / 1024 / 1024 < 3;
  72. if (!isJPG) {
  73. this.$message.error(content[this.language].JPG);
  74. }
  75. if (!isLt2M) {
  76. this.$message.error(content[this.language].IMG);
  77. }
  78. return isJPG && isLt2M;
  79. },
  80. },
  81. mounted() {
  82. let hostParts = window.location.host.split('.');
  83. let tld = hostParts.slice(2).join('.') || 'com';
  84. this.ho = window.location.host.split('.')[1];
  85. this.imgUrl = 'https://secure.' + this.ho + '.' + tld
  86. var jsSrc =(navigator.language || navigator.browserLanguage).toLowerCase();
  87. if(jsSrc.indexOf('zh') >= 0){
  88. this.language = 'cn'
  89. this.lang = content['cn'];
  90. }else{
  91. this.language = 'en'
  92. this.lang = content['en'];
  93. }
  94. }
  95. });