Menu.js 2.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  1. "use strict";
  2. var common_vendor = require("../common/vendor.js");
  3. const _sfc_main = {
  4. components: {},
  5. data() {
  6. return {
  7. cateId: 0,
  8. menuCurrent: 0
  9. };
  10. },
  11. props: {
  12. list: {
  13. type: Array,
  14. default: []
  15. },
  16. menu: {
  17. default: 4
  18. },
  19. imgW: {
  20. type: Number,
  21. default: 88
  22. }
  23. },
  24. computed: {
  25. carousel() {
  26. if (this.list) {
  27. let data = this.sortData(this.list, this.menu * 2);
  28. return data;
  29. }
  30. }
  31. },
  32. created() {
  33. },
  34. methods: {
  35. sortData(oArr, length) {
  36. let arr = [];
  37. let minArr = [];
  38. oArr.forEach((c) => {
  39. if (minArr.length === length) {
  40. minArr = [];
  41. }
  42. if (minArr.length === 0) {
  43. arr.push(minArr);
  44. }
  45. minArr.push(c);
  46. });
  47. return arr;
  48. },
  49. onSwiper(e) {
  50. this.menuCurrent = e.detail.current;
  51. },
  52. routerTo(item) {
  53. this.cateId = item.cateId;
  54. this.$emit("menuClick", item);
  55. }
  56. }
  57. };
  58. function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
  59. return common_vendor.e({
  60. a: $options.carousel
  61. }, $options.carousel ? common_vendor.e({
  62. b: common_vendor.f($options.carousel, (itemList, index, i0) => {
  63. return {
  64. a: common_vendor.f(itemList, (item, k1, i1) => {
  65. return {
  66. a: item.imgUrl,
  67. b: common_vendor.t(item.cateName),
  68. c: common_vendor.n($data.cateId == item.cateId ? "tab-title active" : "tab-title"),
  69. d: item.cateId,
  70. e: common_vendor.o(($event) => $options.routerTo(item), item.cateId)
  71. };
  72. }),
  73. b: index
  74. };
  75. }),
  76. c: $props.imgW + "rpx",
  77. d: $props.imgW + "rpx",
  78. e: common_vendor.s($props.list.length <= $props.menu ? `height:200rpx` : `height:340rpx`),
  79. f: common_vendor.s($props.list.length <= $props.menu ? `height:160rpx` : `height:320rpx`),
  80. g: common_vendor.o((...args) => $options.onSwiper && $options.onSwiper(...args)),
  81. h: $options.carousel.length > 1
  82. }, $options.carousel.length > 1 ? {
  83. i: common_vendor.f($options.carousel.length, (dot, index, i0) => {
  84. return {
  85. a: common_vendor.n($data.menuCurrent === index ? "dot-active" : "dot"),
  86. b: index
  87. };
  88. })
  89. } : {}, {
  90. j: common_vendor.s($props.list.length <= $props.menu ? `height:160rpx` : `height:320rpx`)
  91. }) : {});
  92. }
  93. var Component = /* @__PURE__ */ common_vendor._export_sfc(_sfc_main, [["render", _sfc_render], ["__file", "E:/Project/2023/\u95EE\u8BCA\u5E73\u53F0/his_user_miniapp/components/Menu.vue"]]);
  94. wx.createComponent(Component);