oa-emoji.vue 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125
  1. <template>
  2. <view class="emotion-box">
  3. <swiper
  4. class="swiper"
  5. disable-programmatic-animation="true"
  6. indicator-dots="true"
  7. >
  8. <swiper-item
  9. class="emotion-box-line"
  10. v-for="(xItem, xIndex) in list"
  11. :key="xIndex"
  12. >
  13. <view v-for="(yItem, yIndex) in xItem" :key="yIndex">
  14. <view
  15. v-for="(zItem, zIndex) in yItem"
  16. :key="zIndex"
  17. class="emotion-item"
  18. @click="clickHandler(zItem)"
  19. >
  20. <image :src="`/static/emoji/${zItem}.png`"></image>
  21. </view>
  22. </view>
  23. </swiper-item>
  24. </swiper>
  25. </view>
  26. </template>
  27. <script>
  28. export default {
  29. props: {},
  30. data() {
  31. return {
  32. // 画矩阵
  33. list: [
  34. [
  35. [0, 1, 2, 3],
  36. [4, 5, 6, 7],
  37. [8, 9, 10, 11],
  38. [12, 13, 14, 15],
  39. [16, 17, 18, 19],
  40. [20, 21, 22, 23],
  41. [24, 25, 26, 27],
  42. [28, 29, 30, 31]
  43. ],
  44. [
  45. [32, 33, 34, 35],
  46. [36, 37, 38, 39],
  47. [40, 41, 42, 43],
  48. [44, 45, 46, 47],
  49. [48, 49, 50, 51],
  50. [52, 53, 54, 55],
  51. [56, 57, 58, 59],
  52. [60, 61, 62, 63]
  53. ],
  54. [
  55. [64, 65, 66, 67],
  56. [68, 69, 70, 71],
  57. [72, 73, 74, 75],
  58. [76, 77, 78, 79],
  59. [80, 81, 82, 83],
  60. [84, 85, 86, 87],
  61. [88, 89, 90, 91],
  62. [92, 93, 94, 95]
  63. ],
  64. [[96, 104], [97], [98], [99], [100], [101], [102], [103]]
  65. ],
  66. item: [],
  67. image_width: 0
  68. };
  69. },
  70. mounted() {
  71. // // #ifdef APP-PLUS || H5
  72. // const query = uni.createSelectorQuery().in(this);
  73. // query.select('.emotion-box').boundingClientRect(data => {
  74. // console.log(data.width / 10);
  75. // this.image_width = data.width / 10;
  76. // }).exec();
  77. // // #endif
  78. // // #ifdef MP-WEIXIN
  79. // this.image_width = 22;
  80. // // #endif
  81. this.image_width = 64;
  82. },
  83. methods: {
  84. clickHandler(i) {
  85. this.$emit('emotion', i);
  86. }
  87. }
  88. };
  89. </script>
  90. <style lang="scss">
  91. page {
  92. }
  93. .emotion-box {
  94. margin: 0 auto;
  95. overflow: hidden;
  96. }
  97. .swiper {
  98. height: 460upx;
  99. }
  100. .icon {
  101. width: 48upx;
  102. height: 48upx;
  103. vertical-align: -0.15em;
  104. fill: currentColor;
  105. overflow: hidden;
  106. }
  107. .emotion-box-line {
  108. display: flex;
  109. justify-content: center;
  110. margin: 40upx 0;
  111. }
  112. .emotion-item {
  113. flex: 1;
  114. text-align: center;
  115. cursor: pointer;
  116. margin: 28upx 18upx;
  117. image {
  118. width: 46upx;
  119. height: 46upx;
  120. }
  121. }
  122. </style>