showTypes.vue 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122
  1. <template>
  2. <div class="w-screen pad:w-full">
  3. <div class="conBox container product-type">
  4. <p
  5. v-for="(item,i) in showTypes"
  6. :key="item.key"
  7. :class="`type-item ${item.key===type?'type-selected':''}`"
  8. @click="selectType(item.key)"
  9. >
  10. <span class="icon-box">
  11. <svg-icon :svgHref="item.icon"/>
  12. </span>
  13. <span class="type-name">{{lang===langType.cn?item.text:item.en_text}}</span>
  14. </p>
  15. </div>
  16. </div>
  17. </template>
  18. <script>
  19. import langMap from "@/map/langMap";
  20. import {pTypes} from "~/map/productMap";
  21. import BigTitle from "~/components/public/bigTitle.vue";
  22. export default {
  23. name: "showTypes",
  24. components: {BigTitle},
  25. props: {
  26. lang:{
  27. default: langMap.lang.cn
  28. },
  29. type:{
  30. default: 'all'
  31. },
  32. types: {
  33. type: Array,
  34. required: true
  35. },
  36. title: {
  37. default: '类别'
  38. },
  39. maxShow: {
  40. type: Number,
  41. default: 6,
  42. }
  43. },
  44. data(){
  45. return {
  46. langType: langMap.lang,
  47. }
  48. },
  49. computed: {
  50. showTypes(){
  51. // 移除最后几个元素
  52. let types = this.types.slice(0, this.maxShow);
  53. return types;
  54. }
  55. },
  56. methods:{
  57. getLangText(str) {
  58. return langMap.getText(this.lang, str);
  59. },
  60. getAbbrText(str) {
  61. return langMap.getAbbrText(this.lang, str);
  62. },
  63. selectType(nextType){
  64. console.log(nextType)
  65. if (this.type === nextType){
  66. return 0;
  67. }
  68. this.$root.$emit('changeType', nextType);
  69. }
  70. }
  71. }
  72. </script>
  73. <style scoped>
  74. .content{
  75. cursor: default;
  76. }
  77. .content .big-title{
  78. margin-top: 10px;
  79. margin-bottom: 30px;
  80. }
  81. .product-type{
  82. height: 120px;
  83. display: flex;
  84. justify-content: space-around;
  85. }
  86. .product-type .type-item{
  87. width: auto;
  88. height: 100%;
  89. cursor: pointer;
  90. }
  91. .product-type .type-item:hover{
  92. color: orangered;
  93. }
  94. .product-type .type-selected{
  95. color: #f88330;
  96. }
  97. .product-type .type-item .icon-box{
  98. width: 100%;
  99. height: 50px;
  100. display: flex;
  101. justify-content: center;
  102. align-items: center;
  103. font-size: 4rem;
  104. padding-bottom: 20px;
  105. }
  106. .product-type .type-selected .icon-box{
  107. border-bottom: 2px solid deepskyblue;
  108. }
  109. .product-type .type-item .type-name{
  110. width: 100%;
  111. height: 60px;
  112. font-size: 1.3rem;
  113. display: flex;
  114. justify-content: center;
  115. align-items: center;
  116. }
  117. </style>