sample.js 6.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246
  1. /**
  2. @Name:layuiAdmin 主页示例
  3. @Author:star1029
  4. @Site:http://www.layui.com/admin/
  5. @License:GPL-2
  6. */
  7. layui.define(function(exports){
  8. var admin = layui.admin;
  9. //区块轮播切换
  10. layui.use(['admin', 'carousel'], function(){
  11. var $ = layui.$
  12. ,admin = layui.admin
  13. ,carousel = layui.carousel
  14. ,element = layui.element
  15. ,device = layui.device();
  16. //轮播切换
  17. $('.layadmin-carousel').each(function(){
  18. var othis = $(this);
  19. carousel.render({
  20. elem: this
  21. ,width: '100%'
  22. ,arrow: 'none'
  23. ,interval: othis.data('interval')
  24. ,autoplay: othis.data('autoplay') === true
  25. ,trigger: (device.ios || device.android) ? 'click' : 'hover'
  26. ,anim: othis.data('anim')
  27. });
  28. });
  29. element.render('progress');
  30. });
  31. //八卦新闻
  32. layui.use(['carousel', 'echarts'], function(){
  33. var $ = layui.$
  34. ,carousel = layui.carousel
  35. ,echarts = layui.echarts;
  36. var echartsApp = [], options = [
  37. {
  38. title : {
  39. subtext: '完全实况球员数据',
  40. textStyle: {
  41. fontSize: 14
  42. }
  43. },
  44. tooltip : {
  45. trigger: 'axis'
  46. },
  47. legend: {
  48. x : 'left',
  49. data:['罗纳尔多','舍普琴科']
  50. },
  51. polar : [
  52. {
  53. indicator : [
  54. {text : '进攻', max : 100},
  55. {text : '防守', max : 100},
  56. {text : '体能', max : 100},
  57. {text : '速度', max : 100},
  58. {text : '力量', max : 100},
  59. {text : '技巧', max : 100}
  60. ],
  61. radius : 130
  62. }
  63. ],
  64. series : [
  65. {
  66. type: 'radar',
  67. center : ['50%', '50%'],
  68. itemStyle: {
  69. normal: {
  70. areaStyle: {
  71. type: 'default'
  72. }
  73. }
  74. },
  75. data:[
  76. {value : [97, 42, 88, 94, 90, 86], name : '舍普琴科'},
  77. {value : [97, 32, 74, 95, 88, 92], name : '罗纳尔多'}
  78. ]
  79. }
  80. ]
  81. }
  82. ]
  83. ,elemDataView = $('#LAY-index-pageone').children('div')
  84. ,renderDataView = function(index){
  85. echartsApp[index] = echarts.init(elemDataView[index], layui.echartsTheme);
  86. echartsApp[index].setOption(options[index]);
  87. window.onresize = echartsApp[index].resize;
  88. };
  89. //没找到DOM,终止执行
  90. if(!elemDataView[0]) return;
  91. renderDataView(0);
  92. });
  93. //访问量
  94. layui.use(['carousel', 'echarts'], function(){
  95. var $ = layui.$
  96. ,carousel = layui.carousel
  97. ,echarts = layui.echarts;
  98. var echartsApp = [], options = [
  99. {
  100. tooltip : {
  101. trigger: 'axis'
  102. },
  103. calculable : true,
  104. legend: {
  105. data:['访问量']
  106. },
  107. xAxis : [
  108. {
  109. type : 'category',
  110. data : ['1月','2月','3月','4月','5月','6月','7月','8月','9月','10月','11月','12月']
  111. }
  112. ],
  113. yAxis : [
  114. {
  115. type : 'value',
  116. name : '访问量'
  117. }
  118. ],
  119. series : [
  120. {
  121. name:'访问量',
  122. type:'line',
  123. data:MonthViewCountList
  124. }
  125. ]
  126. }
  127. ]
  128. ,elemDataView = $('#LAY-index-pagetwo').children('div')
  129. ,renderDataView = function(index){
  130. echartsApp[index] = echarts.init(elemDataView[index], layui.echartsTheme);
  131. echartsApp[index].setOption(options[index]);
  132. window.onresize = echartsApp[index].resize;
  133. };
  134. //没找到DOM,终止执行
  135. if(!elemDataView[0]) return;
  136. renderDataView(0);
  137. });
  138. //地图
  139. layui.use(['carousel', 'echarts'], function(){
  140. var $ = layui.$
  141. ,carousel = layui.carousel
  142. ,echarts = layui.echarts;
  143. var echartsApp = [], options = [
  144. {
  145. title : {
  146. text: '全国的用户分布',
  147. subtext: '不完全统计'
  148. },
  149. tooltip : {
  150. trigger: 'item'
  151. },
  152. dataRange: {
  153. orient: 'horizontal',
  154. min: 0,
  155. max: 60000,
  156. text:['高','低'],
  157. splitNumber:0
  158. },
  159. series : [
  160. {
  161. name: '全国的用户分布',
  162. type: 'map',
  163. mapType: 'china',
  164. selectedMode : 'multiple',
  165. itemStyle:{
  166. normal:{label:{show:true}},
  167. emphasis:{label:{show:true}}
  168. },
  169. data:IpCountList
  170. }
  171. ]
  172. }
  173. ]
  174. ,elemDataView = $('#LAY-index-pagethree').children('div')
  175. ,renderDataView = function(index){
  176. echartsApp[index] = echarts.init(elemDataView[index], layui.echartsTheme);
  177. echartsApp[index].setOption(options[index]);
  178. window.onresize = echartsApp[index].resize;
  179. };
  180. //没找到DOM,终止执行
  181. if(!elemDataView[0]) return;
  182. renderDataView(0);
  183. });
  184. //项目进展
  185. layui.use('table', function(){
  186. var $ = layui.$
  187. ,table = layui.table;
  188. table.render({
  189. elem: '#LAY-index-prograss'
  190. ,url: layui.setter.base + 'json/console/prograss.js' //模拟接口
  191. ,cols: [[
  192. {type: 'checkbox', fixed: 'left'}
  193. ,{field: 'prograss', title: '任务'}
  194. ,{field: 'time', title: '所需时间'}
  195. ,{field: 'complete', title: '完成情况'
  196. ,templet: function(d){
  197. if(d.complete == '已完成'){
  198. return '<del style="color: #5FB878;">'+ d.complete +'</del>'
  199. }else if(d.complete == '进行中'){
  200. return '<span style="color: #FFB800;">'+ d.complete +'</span>'
  201. }else{
  202. return '<span style="color: #FF5722;">'+ d.complete +'</span>'
  203. }
  204. }
  205. }
  206. ]]
  207. ,skin: 'line'
  208. });
  209. });
  210. //回复留言
  211. admin.events.replyNote = function(othis){
  212. var nid = othis.data('id');
  213. layer.prompt({
  214. title: '回复留言 ID:'+ nid
  215. ,formType: 2
  216. }, function(value, index){
  217. //这里可以请求 Ajax
  218. //…
  219. layer.msg('得到:'+ value);
  220. layer.close(index);
  221. });
  222. };
  223. exports('sample', {})
  224. });