use.vue 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  1. <template>
  2. <div class="use-layout">
  3. <!-- <iselect @current="handleCurrent"/> -->
  4. <!-- @click="$router.push({name:'useimg',params:{id:i}})" -->
  5. <list :data="useList">
  6. <div slot="item" slot-scope="{data,i}" @click="clickItem(data,i)" >
  7. <div class="title">{{`${language==='en'?data.titleEn:data.title}`}}
  8. <img
  9. v-if="data.sub"
  10. :src="`${$cdn}images/right-arrow.png`"
  11. class="jiantou"
  12. :class="{'active':activeIdx===i}"
  13. />
  14. <div class="sub" :class="{'open':activeIdx===i}" >
  15. <div v-for="(item,i) in data.sub" :key="i" @touchstart.stop="$router.push({name:'useimg',params:{id:item.img,type,name: 'use'}})">
  16. <p v-html="language==='en'?item.nameEn:item.name"></p>
  17. </div>
  18. </div>
  19. </div>
  20. </div>
  21. </list>
  22. </div>
  23. </template>
  24. <script>
  25. import select from '../plugin/select'
  26. import list from '../plugin/list'
  27. import {mapState} from 'vuex'
  28. export default {
  29. props: ['data'],
  30. components: {
  31. iselect: select,
  32. list
  33. },
  34. computed: {
  35. ...mapState({
  36. language: state => state.language.current
  37. })
  38. },
  39. data () {
  40. return {
  41. activeIdx: '',
  42. useList: this.data.data.pro,
  43. type: 0
  44. }
  45. },
  46. methods: {
  47. clickItem (data, i) {
  48. this.activeIdx = (this.activeIdx === i ? '' : i)
  49. if (!data.sub) {
  50. this.$router.push({name: 'useimg', params: {id: data.img, type: this.type, name: 'use'}})
  51. }
  52. },
  53. handleCurrent (data) {
  54. this.type = data
  55. this.useList = data ? this.data.data.lite : this.data.data.pro
  56. }
  57. }
  58. }
  59. </script>
  60. <style lang="scss" scoped>
  61. $animatype: cubic-bezier(0.645, 0.045, 0.355, 1);
  62. $bannerHeight: 48px;
  63. .use-layout{
  64. width: 100%;
  65. .item {
  66. padding: 12px 8px;
  67. border-bottom: 1px solid #f2f2f2;
  68. .title {
  69. position: relative;
  70. font-size: 16px;
  71. color: #4a90e2;
  72. padding-right: 24px;
  73. .jiantou {
  74. transition: transform 0.3s $animatype;
  75. position: absolute;
  76. top: 0;
  77. right: 0;
  78. height: 24px;
  79. transform: rotate(0deg);
  80. }
  81. .active {
  82. transform: rotate(90deg);
  83. }
  84. }
  85. .sub {
  86. transition: max-height 0.3s $animatype;
  87. max-height: 0;
  88. overflow: hidden;
  89. padding-top: 8px;
  90. p{
  91. font-size: 16px;
  92. color: #4a90e2;
  93. }
  94. }
  95. .open {
  96. max-height: 420px;
  97. }
  98. }
  99. }
  100. </style>