agreement.js 835 B

123456789101112131415161718192021222324252627282930313233
  1. import Service from "./common/service.js";
  2. new Vue({
  3. el: "#app",
  4. data: {
  5. info: {},
  6. },
  7. mounted() {
  8. const type = location.href.split("?type=")[1];
  9. this.getDetail(type);
  10. },
  11. methods: {
  12. lan_key(val) {
  13. return `${val}${localStorage.getItem("language") == "en" ? "_en" : ""}`;
  14. },
  15. getDetail(type) {
  16. Service.get_site()
  17. .then((res) => {
  18. this.info = res[`agreement_` + type];
  19. })
  20. .catch((err) => {
  21. console.log(err);
  22. });
  23. },
  24. downloadFile() {
  25. const a = document.createElement("a");
  26. a.href = Service.baseURL + this.info.url;
  27. a.download = decodeURI(this.info[this.lan_key("url_name")] + ".docx");
  28. document.body.appendChild(a);
  29. a.click();
  30. document.body.removeChild(a); // 下载完移除元素
  31. },
  32. },
  33. });