select_icon_style.html 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. {extend name="base"/}
  2. {block name="resources"}
  3. <style>
  4. html,body {
  5. width: 100%;
  6. height: 100%;
  7. background: #fff;
  8. }
  9. .icon-style-wrap {
  10. padding: 15px;
  11. box-sizing: border-box;
  12. width: 100%;
  13. height: 100%;
  14. display: flex;
  15. flex-direction: column;
  16. }
  17. .icon-style-wrap .title {
  18. margin-bottom: 10px;
  19. }
  20. .icon-style-wrap .icon-list {
  21. flex: 1;
  22. height: 0;
  23. display: flex;
  24. overflow-y: scroll;
  25. flex-wrap: wrap;
  26. }
  27. .icon-style-wrap .icon-list::-webkit-scrollbar {
  28. display: none;
  29. }
  30. .icon-style-wrap .icon-list .icon-block {
  31. width: 56px;
  32. height: 56px;
  33. font-size: 60px;
  34. border: 1px dashed #eee;
  35. margin: 0 5px 5px 0;
  36. cursor: pointer;
  37. }
  38. .icon-style-wrap .icon-list .icon-block:nth-child(5n+5) {
  39. margin-right: 0;
  40. }
  41. .icon-style-wrap .icon-list .icon-block:hover {
  42. border-color: var(--base-color);
  43. }
  44. .icon-style-wrap .icon-list .custom {
  45. font-size: 12px;
  46. display: flex;
  47. align-items: center;
  48. justify-content: center;
  49. }
  50. </style>
  51. {/block}
  52. {block name="body"}
  53. <div class="icon-style-wrap" id="app">
  54. <div class="title">图标风格</div>
  55. <div class="icon-list">
  56. <div class="icon-block" v-for="(item, index) in styleList" :key="index" @click="selectStyle(index)">
  57. <iconfont icon="{$icon}" :value="item"></iconfont>
  58. </div>
  59. <div class="icon-block custom" @click="custom">
  60. <p>自定义</p>
  61. </div>
  62. </div>
  63. </div>
  64. {/block}
  65. {block name="script"}
  66. <script src="STATIC_JS/vue.js"></script>
  67. {include file="diy/iconfont_component"/}
  68. <script>
  69. vue = new Vue({
  70. el: "#app",
  71. data: {
  72. styleList: {:json_encode($icon_style)}
  73. },
  74. methods: {
  75. selectStyle(index){
  76. window.parent.postMessage({
  77. event: 'selectIconStyle',
  78. data: this.styleList[index],
  79. }, location.origin);
  80. },
  81. custom(){
  82. window.parent.postMessage({
  83. event: 'selectIconStyle',
  84. data: null,
  85. }, location.origin);
  86. }
  87. }
  88. })
  89. </script>
  90. {/block}