productTypes.vue 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  1. <template>
  2. <div class="content">
  3. <div class="conBox big-title">
  4. <span>
  5. {{lang===langType.cn?"产品类别":getAbbrText("产品类别")}}
  6. </span>
  7. <div class="hr"></div>
  8. </div>
  9. <div class="conBox product-type">
  10. <p
  11. v-for="(item,i) in types"
  12. :key="item.key"
  13. :class="`type-item ${item.key===type?'type-selected':''}`"
  14. @click="selectType(item.key)"
  15. >
  16. <span class="icon-box">
  17. <svg-icon :icon-class="item.icon"/>
  18. </span>
  19. <span class="type-name">{{lang===langType.cn?item.text:getAbbrText(item.text)}}</span>
  20. </p>
  21. </div>
  22. </div>
  23. </template>
  24. <script>
  25. import langMap from "@/map/langMap";
  26. import {pTypes} from "~/map/productMap";
  27. export default {
  28. name: "productTypes",
  29. props: {
  30. lang:{
  31. default: langMap.lang.cn
  32. },
  33. type:{
  34. default: 'all'
  35. }
  36. },
  37. data(){
  38. return {
  39. langType: langMap.lang,
  40. types: pTypes
  41. }
  42. },
  43. methods:{
  44. getLangText(str) {
  45. return langMap.getText(this.lang, str);
  46. },
  47. getAbbrText(str) {
  48. return langMap.getAbbrText(this.lang, str);
  49. },
  50. selectType(nextType){
  51. console.log(nextType)
  52. if (this.type === nextType){
  53. return 0;
  54. }
  55. this.$root.$emit('changeProductType',nextType);
  56. }
  57. }
  58. }
  59. </script>
  60. <style scoped>
  61. .content{
  62. cursor: default;
  63. }
  64. .content .big-title{
  65. margin-top: 10px;
  66. margin-bottom: 30px;
  67. }
  68. .product-type{
  69. height: 120px;
  70. display: grid;
  71. grid-template-columns: repeat(6,1fr);
  72. }
  73. .product-type .type-item{
  74. width: auto;
  75. height: 100%;
  76. cursor: pointer;
  77. }
  78. .product-type .type-item:hover{
  79. color: orangered;
  80. }
  81. .content .product-type .type-selected{
  82. color: #f88330;
  83. }
  84. .product-type .type-item .icon-box{
  85. width: 100%;
  86. height: 50px;
  87. display: flex;
  88. justify-content: center;
  89. align-items: center;
  90. font-size: 4rem;
  91. padding-bottom: 20px;
  92. }
  93. .content .product-type .type-selected .icon-box{
  94. border-bottom: 1px solid deepskyblue;
  95. }
  96. .product-type .type-item .type-name{
  97. width: 100%;
  98. height: 60px;
  99. font-size: 1.3rem;
  100. display: flex;
  101. justify-content: center;
  102. align-items: center;
  103. }
  104. </style>