about.js 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. import language from "./common/language.js";
  2. import Service from "./common/service.js";
  3. new Vue({
  4. el: "#app",
  5. data: {
  6. current_index: 0,
  7. tab_list: ["企业定位", "企业使命", "企业愿景", "联系我们"],
  8. info: {},
  9. params: {
  10. realname: "", // 姓名
  11. tel: "", // 电话
  12. email: "", // 邮箱
  13. content: "", // 描述
  14. },
  15. config: {},
  16. baseURL: Service.baseURL,
  17. company_list: [],
  18. company_img: "",
  19. },
  20. computed: {
  21. current_tab() {
  22. return `calc((100% - ${this.tab_list.length * 15}rem) / 2 + ${
  23. (this.current_index + 0.5) * 15
  24. }rem - 1.75rem)`;
  25. },
  26. },
  27. mounted() {
  28. this.getList();
  29. },
  30. methods: {
  31. text(val) {
  32. return language[val][localStorage.getItem("language")];
  33. },
  34. lan_key(val) {
  35. return `${val}${localStorage.getItem("language") == "en" ? "_en" : ""}`;
  36. },
  37. // 切换tab
  38. changeCurrent(item) {
  39. window.scrollTo(0, document.getElementById(item).offsetTop - 70);
  40. },
  41. // 获取数据
  42. getList() {
  43. Service.getCompany()
  44. .then((res) => {
  45. this.company_list = res;
  46. })
  47. .catch((err) => {
  48. console.log(err);
  49. });
  50. Service.get_site()
  51. .then((res) => {
  52. this.config = res;
  53. this.company_img = res.web_company_address_image;
  54. })
  55. .catch((err) => {
  56. console.log(err);
  57. });
  58. Service.get_about()
  59. .then((res) => {
  60. this.info = res;
  61. })
  62. .catch((err) => {
  63. console.log(err);
  64. });
  65. },
  66. submit() {
  67. if (!this.params.realname) return alert(this.text("请输入您的称呼"));
  68. if (!this.params.tel) return alert(this.text("请输入您的联系电话"));
  69. if (!this.params.email) return alert(this.text("请输入您的邮箱地址"));
  70. Service.create_message(this.params)
  71. .then((res) => {
  72. Object.keys(this.params).forEach((key) => (this.params[key] = ""));
  73. alert(this.text("提交成功"));
  74. })
  75. .catch((err) => {
  76. console.log(err);
  77. });
  78. },
  79. },
  80. });