info.js 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337
  1. // ES5 方式:通过全局变量使用 createUploadRequest(需要先加载 upload.js)
  2. var content = {
  3. cn: {
  4. item1: "文档管理",
  5. item2: "身份证明",
  6. item3: "未验证",
  7. item4: "已通过",
  8. item5: "护照/身份证/驾照。",
  9. item6:
  10. "请上传PNG、JPEG、JPG或PDF格式的彩色身份证明文件,显示您的全名。图像必须是高质量的,畅通无阻,并显示整个文档页面。如属国家身份证件,须上传身份证正反两面。文件有效期必须超过3个月。",
  11. item7: "地址证明",
  12. item8: "请以PNG、JPEG、JPG或PDF格式上传地址证明。",
  13. item9:
  14. "住址证明必须不超过180天(水电帐单/银行对账单/其他财务文件)。文件必须以申请人的姓名发出,并显示申请人在登记时所提供的目前居住地址。图像必须是高质量的,畅通无阻,并显示整个文档页面。",
  15. item10: "其它补充材料",
  16. item11: "护照/身份证/驾照。",
  17. item12: "请上传我们支持团队要求的其他文件。",
  18. IMG: "上传头像图片大小不能超过 3MB!",
  19. JPG: "上传图片只能是 JPG、JPEG、PNG、PDF 格式!",
  20. btn: "确认上传",
  21. success: "上传成功,请在PC端查看...",
  22. Upload: "上传文件",
  23. },
  24. en: {
  25. item1: "Document management",
  26. item2: "ID",
  27. item3: "Not verified",
  28. item4: "Passed",
  29. item5: "Passport / ID card / driver's license.",
  30. item6:
  31. "Please upload your full name in PNG, JPEG, JPG or PDF format. Images must be high quality, unobstructed, and display the entire document page. If it is a national ID card, both sides of the ID card must be uploaded. Documents must be valid for more than 3 months.",
  32. item7: "Proof of address",
  33. item8:
  34. "Please upload the address Certificate in PNG, JPEG, JPG or PDF format.",
  35. item9:
  36. "Proof of address must not exceed 180 days (water and electricity bill / bank statement / other financial documents). The document must be issued in the name of the applicant and show the current residential address provided by the applicant at the time of registration. Images must be high quality, unobstructed, and display the entire document page.",
  37. item10: "Other supplementary materials",
  38. item11: "Passport / ID card / driver's license.",
  39. item12: "Please upload other documents as required by our support team.",
  40. IMG: "The size of the uploaded picture cannot exceed 3MB!",
  41. JPG: "Upload image can only be JPG, JPEG, PNG, PDF format!",
  42. btn: "Confirm upload",
  43. success: "Upload succeeded, please check on PC",
  44. Upload: "Upload Files",
  45. },
  46. };
  47. let vm = new Vue({
  48. el: "#index",
  49. data: {
  50. //多语言
  51. langList: {
  52. en: "ENGLISH",
  53. cn: "中文简体",
  54. },
  55. language: "cn",
  56. lang: {},
  57. imageUrl1: "",
  58. imageUrl2: "",
  59. imageUrl3: "",
  60. imageUrl4: "",
  61. imageUrl5: "",
  62. //文件
  63. fileListID1: {
  64. againPath: "",
  65. id: null,
  66. path: "",
  67. status: null,
  68. type: null,
  69. },
  70. fileListID2: {
  71. againPath: "",
  72. id: null,
  73. path: "",
  74. status: null,
  75. type: null,
  76. },
  77. fileListAdd1: {
  78. againPath: "",
  79. id: null,
  80. path: "",
  81. status: null,
  82. type: null,
  83. },
  84. fileListAdd2: {
  85. againPath: "",
  86. id: null,
  87. path: "",
  88. status: null,
  89. type: null,
  90. },
  91. fileListOthers: [],
  92. fileListOther: {
  93. againPath: "",
  94. id: null,
  95. path: "",
  96. status: null,
  97. type: null,
  98. },
  99. actionID1: "",
  100. actionID2: "",
  101. actionAdd1: "",
  102. actionAdd2: "",
  103. actionOtherAdd: "",
  104. actionOther: "",
  105. imgUrl: "",
  106. ho: "",
  107. },
  108. computed: {
  109. AccessToken() {
  110. return {
  111. "Access-Token": window.location.href.split("=")[1],
  112. };
  113. },
  114. },
  115. methods: {
  116. // 语言切换函数
  117. chooseLang(key) {
  118. this.lang = content[key];
  119. this.language = key;
  120. },
  121. //确认上传按钮
  122. update() {
  123. if (
  124. !this.fileListID1.path &&
  125. !this.fileListID2.path &&
  126. !this.fileListAdd1.path &&
  127. !this.fileListAdd2.path &&
  128. !this.fileListOthers.length
  129. ) {
  130. return;
  131. }
  132. this.$message({
  133. message: content[this.language].success,
  134. type: "success",
  135. });
  136. },
  137. //获取上传文件信息
  138. async getCustomFileList() {
  139. let _this = this;
  140. axios.defaults.headers.common["Access-Token"] =
  141. window.location.href.split("=")[1];
  142. axios
  143. .post(this.imgUrl + "/custom/file/list", {
  144. //参数
  145. })
  146. .then((res) => {
  147. //请求成功后的处理函数
  148. if (res.data.code == 200) {
  149. let myData = res.data.data;
  150. this.fileListOthers = [];
  151. myData.forEach((item) => {
  152. if (item.type == 1) {
  153. _this.fileListID1 = item;
  154. } else if (item.type == 2) {
  155. _this.fileListID2 = item;
  156. } else if (item.type == 3) {
  157. _this.fileListAdd1 = item;
  158. } else if (item.type == 4) {
  159. _this.fileListAdd2 = item;
  160. } else if (item.type == 10) {
  161. _this.fileListOthers.push(item);
  162. }
  163. });
  164. this.actionType();
  165. }
  166. })
  167. .catch((err) => {
  168. console.log(err)
  169. //请求失败后的处理函数
  170. });
  171. },
  172. //请求头
  173. actionType() {
  174. if (this.fileListID1.id) {
  175. this.actionID1 =
  176. this.imgUrl + "/custom/file/upload/1/" + this.fileListID1.id;
  177. } else {
  178. this.actionID1 = this.imgUrl + "/custom/file/upload/1";
  179. }
  180. if (this.fileListID2.id) {
  181. this.actionID2 =
  182. this.imgUrl + "/custom/file/upload/2/" + this.fileListID2.id;
  183. } else {
  184. this.actionID2 = this.imgUrl + "/custom/file/upload/2";
  185. }
  186. if (this.fileListAdd1.id) {
  187. this.actionAdd1 =
  188. this.imgUrl + "/custom/file/upload/3/" + this.fileListAdd1.id;
  189. } else {
  190. this.actionAdd1 = this.imgUrl + "/custom/file/upload/3";
  191. }
  192. if (this.fileListAdd2.id) {
  193. this.actionAdd2 =
  194. this.imgUrl + "/custom/file/upload/4/" + this.fileListAdd2.id;
  195. } else {
  196. this.actionAdd2 = this.imgUrl + "/custom/file/upload/4";
  197. }
  198. this.actionOtherAdd = this.imgUrl + "/custom/file/upload/10";
  199. },
  200. // 自定义上传方法
  201. handleUploadID1(options) {
  202. const originalUrl =
  203. this.actionID1 || this.imgUrl + "/custom/file/upload/1";
  204. return createUploadRequest(originalUrl, this.AccessToken)(options);
  205. },
  206. handleUploadID2(options) {
  207. const originalUrl =
  208. this.actionID2 || this.imgUrl + "/custom/file/upload/2";
  209. return createUploadRequest(originalUrl, this.AccessToken)(options);
  210. },
  211. handleUploadAdd1(options) {
  212. const originalUrl =
  213. this.actionAdd1 || this.imgUrl + "/custom/file/upload/3";
  214. return createUploadRequest(originalUrl, this.AccessToken)(options);
  215. },
  216. handleUploadAdd2(options) {
  217. const originalUrl =
  218. this.actionAdd2 || this.imgUrl + "/custom/file/upload/4";
  219. return createUploadRequest(originalUrl, this.AccessToken)(options);
  220. },
  221. handleUploadOtherAdd(options) {
  222. const originalUrl =
  223. this.actionOtherAdd || this.imgUrl + "/custom/file/upload/10";
  224. return createUploadRequest(originalUrl, this.AccessToken)(options);
  225. },
  226. handleUploadOtherWithId(options, id) {
  227. const originalUrl = this.imgUrl + "/custom/file/upload/10/" + id;
  228. return createUploadRequest(originalUrl, this.AccessToken)(options);
  229. },
  230. //图片上传
  231. beforeAvatarUpload(file) {
  232. const imageType = ["image/jpeg", "image/png", "image/jpg", "image/pdf"];
  233. const isJPG =
  234. imageType.indexOf(file.type.toLocaleLowerCase()) == -1 ? false : true;
  235. const isLt2M = file.size / 1024 / 1024 < 3;
  236. if (!isJPG) {
  237. this.$message.error(content[this.language].JPG);
  238. }
  239. if (!isLt2M) {
  240. this.$message.error(content[this.language].IMG);
  241. }
  242. return isJPG && isLt2M;
  243. },
  244. handleAvatarSuccess1(res) {
  245. if (res.code == 200) {
  246. this.$message({
  247. message: res.msg,
  248. type: "success",
  249. });
  250. this.fileListID1.path = res.data.path;
  251. } else {
  252. this.$message.error(res.msg);
  253. }
  254. },
  255. handleAvatarSuccess2(res) {
  256. if (res.code == 200) {
  257. this.$message({
  258. message: res.msg,
  259. type: "success",
  260. });
  261. this.fileListID2.path = res.data.path;
  262. } else {
  263. this.$message.error(res.msg);
  264. }
  265. },
  266. handleAvatarSuccess3(res) {
  267. if (res.code == 200) {
  268. this.$message({
  269. message: res.msg,
  270. type: "success",
  271. });
  272. this.fileListAdd1.path = res.data.path;
  273. } else {
  274. this.$message.error(res.msg);
  275. }
  276. },
  277. handleAvatarSuccess4(res) {
  278. if (res.code == 200) {
  279. this.$message({
  280. message: res.msg,
  281. type: "success",
  282. });
  283. this.fileListAdd2.path = res.data.path;
  284. } else {
  285. this.$message.error(res.msg);
  286. }
  287. },
  288. handleAvatarSuccess5(res) {
  289. if (res.code == 200) {
  290. this.$message({
  291. message: res.msg,
  292. type: "success",
  293. });
  294. this.fileListOther.path = res.data.path;
  295. } else {
  296. this.$message.error(res.msg);
  297. }
  298. },
  299. handleAvatarSuccessOther(res) {
  300. if (res.code == 200) {
  301. this.$message({
  302. message: res.msg,
  303. type: "success",
  304. });
  305. this.getCustomFileList();
  306. } else {
  307. this.$message.error(res.msg);
  308. }
  309. },
  310. },
  311. mounted() {
  312. this.ho = window.location.host.split(".")[1];
  313. this.imgUrl = "https://secure." + this.ho + ".com";
  314. this.host05 = "https://file." + this.ho + ".com";
  315. this.getCustomFileList();
  316. var jsSrc = (navigator.language || navigator.browserLanguage).toLowerCase();
  317. if (jsSrc.indexOf("zh") >= 0) {
  318. this.language = "cn";
  319. this.lang = content["cn"];
  320. } else {
  321. this.language = "en";
  322. this.lang = content["en"];
  323. }
  324. },
  325. });