product.js 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. import Service from "./common/service.js";
  2. import language from "./common/language.js";
  3. new Vue({
  4. el: "#app",
  5. data: {
  6. current_index: 0,
  7. tab_list: [],
  8. list: [],
  9. total: 0,
  10. },
  11. computed: {
  12. current_tab() {
  13. return `calc((100% - ${this.tab_list.length * 15}rem) / 2 + ${
  14. (this.current_index + 0.5) * 15
  15. }rem - 1.75rem)`;
  16. },
  17. },
  18. mounted() {
  19. this.getTabList();
  20. },
  21. methods: {
  22. text(val) {
  23. return language[val][localStorage.getItem("language")];
  24. },
  25. lan_key(val) {
  26. return `${val}${localStorage.getItem("language") == "en" ? "_en" : ""}`;
  27. },
  28. getTabList() {
  29. Service.get_product_cate()
  30. .then((res) => {
  31. this.tab_list = res;
  32. this.getList(0);
  33. })
  34. .catch((err) => {
  35. console.log(err);
  36. });
  37. },
  38. getList(index) {
  39. this.current_index = index;
  40. Service.get_product({
  41. page: 1,
  42. cate_id: this.tab_list[this.current_index].id,
  43. })
  44. .then((res) => {
  45. this.list = res.data;
  46. this.total = res.total;
  47. })
  48. .catch((err) => {
  49. console.log(err);
  50. });
  51. },
  52. },
  53. });