截流自动化的商城平台
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

demo.html 6.0KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177
  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4. <meta charset="UTF-8">
  5. <meta name="viewport" content="width=device-width, initial-scale=1.0">
  6. <meta http-equiv="X-UA-Compatible" content="ie=edge">
  7. <title>Document</title>
  8. <link rel="stylesheet" href="assets/layui/css/layui.css">
  9. <style>
  10. .hide {
  11. display: none;
  12. }
  13. </style>
  14. <script src="assets/layui/layui.js"></script>
  15. <script src="module/common.js"></script>
  16. </head>
  17. <body style="padding: 18px;">
  18. <div class="layui-form">
  19. <div class="layui-form-item">
  20. <label for="" class="layui-form-label">默认图标</label>
  21. <div class="layui-input-block">
  22. <input type="text" id="iconPicker" lay-filter="iconPicker" class="hide">
  23. </div>
  24. </div>
  25. <div class="layui-form-item">
  26. <label for="" class="layui-form-label">自定义图标</label>
  27. <div class="layui-input-block">
  28. <input type="text" id="iconPicker2" value="layui-icon-face-smile-fine" lay-filter="iconPicker2" class="hide">
  29. </div>
  30. </div>
  31. <div class="layui-form-item">
  32. <label class="layui-form-label">弹窗选择</label>
  33. <div class="layui-input-block">
  34. <button id="layer" class="layui-btn">点击打开弹窗</button>
  35. </div>
  36. </div>
  37. <div class="layui-form-item">
  38. <label for="" class="layui-form-label">从JSON读取值</label>
  39. <div class="layui-input-block">
  40. <input type="text" id="iconPicker4" lay-filter="iconPicker4" class="hide">
  41. </div>
  42. </div>
  43. </div>
  44. <div id="layer-modal" style="display: none;">
  45. <div style="padding: 18px;">
  46. <input type="text" id="iconPicker3" lay-filter="iconPicker3" value="layui-icon-face-smile-fine" class="layui-input">
  47. <br>
  48. <input type="text" id="iconPicker3-2" lay-filter="iconPicker3-2" class="layui-input">
  49. <button id="btnSubmit3-2" class="layui-btn">获取当前值</button>
  50. </div>
  51. </div>
  52. <script>
  53. layui.use(['iconPicker', 'form', 'layer'], function () {
  54. var iconPicker = layui.iconPicker,
  55. form = layui.form,
  56. layer = layui.layer,
  57. $ = layui.$;
  58. iconPicker.render({
  59. // 选择器,推荐使用input
  60. elem: '#iconPicker',
  61. // 数据类型:fontClass/unicode,推荐使用fontClass
  62. type: 'fontClass',
  63. // 是否开启搜索:true/false,默认true
  64. search: true,
  65. // 是否开启分页:true/false,默认true
  66. page: true,
  67. // 每页显示数量,默认12
  68. limit: 12,
  69. // 点击回调
  70. click: function (data) {
  71. console.log(data);
  72. },
  73. // 渲染成功后的回调
  74. success: function(d) {
  75. console.log(d);
  76. }
  77. });
  78. // ********************** 示例2 - 默认值 *****************************************
  79. iconPicker.render({
  80. // 选择器,推荐使用input
  81. elem: '#iconPicker2',
  82. // 数据类型:fontClass/unicode,推荐使用fontClass
  83. type: 'fontClass',
  84. // 是否开启搜索:true/false
  85. search: true,
  86. // 是否开启分页
  87. page: true,
  88. // 每页显示数量,默认12
  89. limit: 12,
  90. // 点击回调
  91. click: function (data) {
  92. console.log(data);
  93. },
  94. // 渲染成功后的回调
  95. success: function(d) {
  96. console.log(d);
  97. }
  98. });
  99. // ********************** 示例2 END *****************************************
  100. // ********************* 示例3 - 弹窗中打开 **********************************
  101. iconPicker.render({
  102. elem: '#iconPicker3',
  103. type: 'fontClass',
  104. search: true,
  105. page: true,
  106. limit: 12,
  107. click: function (data) {
  108. console.log(data);
  109. },
  110. success: function(d) {
  111. console.log(d);
  112. }
  113. });
  114. iconPicker.render({
  115. elem: '#iconPicker3-2',
  116. type: 'fontClass',
  117. search: true,
  118. page: true,
  119. limit: 12,
  120. click: function (data) {
  121. console.log(data);
  122. },
  123. success: function(d) {
  124. console.log(d);
  125. }
  126. });
  127. $('#layer').click(function(){
  128. layer.open({
  129. type: 1,
  130. area: ['500px', '400px'],
  131. content: $('#layer-modal'),
  132. success: function(layero){
  133. iconPicker.checkIcon('iconPicker3-2', 'layui-icon-cellphone');
  134. }
  135. });
  136. });
  137. $('#btnSubmit3-2').click(function(){
  138. alert($('#iconPicker3-2').val());
  139. });
  140. // ********************* 示例3 END **********************************
  141. // ********************* 示例4 - 异步设置值 **********************************
  142. iconPicker.render({
  143. elem: '#iconPicker4',
  144. type: 'fontClass'
  145. });
  146. $.getJSON("json/example.json",function(result){
  147. console.log(result);
  148. var icon = result.data[0].icon;
  149. console.log(icon);
  150. iconPicker.checkIcon('iconPicker4', icon);
  151. });
  152. // ********************* 示例4 END **********************************
  153. });
  154. </script>
  155. </body>
  156. </html>