sample.js 8.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299
  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. axisLabel : {
  118. formatter: '{value} 万'
  119. }
  120. },
  121. {
  122. type : 'value',
  123. name : '下载量',
  124. axisLabel : {
  125. formatter: '{value} 万'
  126. }
  127. }
  128. ],
  129. series : [
  130. {
  131. name:'访问量',
  132. type:'line',
  133. data:[900, 850, 950, 1000, 1100, 1050, 1000, 1150, 1250, 1370, 1250, 1100]
  134. },
  135. {
  136. name:'下载量',
  137. type:'line',
  138. yAxisIndex: 1,
  139. data:[850, 850, 800, 950, 1000, 950, 950, 1150, 1100, 1240, 1000, 950]
  140. },
  141. {
  142. name:'平均访问量',
  143. type:'line',
  144. data:[870, 850, 850, 950, 1050, 1000, 980, 1150, 1000, 1300, 1150, 1000]
  145. }
  146. ]
  147. }
  148. ]
  149. ,elemDataView = $('#LAY-index-pagetwo').children('div')
  150. ,renderDataView = function(index){
  151. echartsApp[index] = echarts.init(elemDataView[index], layui.echartsTheme);
  152. echartsApp[index].setOption(options[index]);
  153. window.onresize = echartsApp[index].resize;
  154. };
  155. //没找到DOM,终止执行
  156. if(!elemDataView[0]) return;
  157. renderDataView(0);
  158. });
  159. //地图
  160. layui.use(['carousel', 'echarts'], function(){
  161. var $ = layui.$
  162. ,carousel = layui.carousel
  163. ,echarts = layui.echarts;
  164. var echartsApp = [], options = [
  165. {
  166. title : {
  167. text: '全国的 layui 用户分布',
  168. subtext: '不完全统计'
  169. },
  170. tooltip : {
  171. trigger: 'item'
  172. },
  173. dataRange: {
  174. orient: 'horizontal',
  175. min: 0,
  176. max: 60000,
  177. text:['高','低'],
  178. splitNumber:0
  179. },
  180. series : [
  181. {
  182. name: '全国的 layui 用户分布',
  183. type: 'map',
  184. mapType: 'china',
  185. selectedMode : 'multiple',
  186. itemStyle:{
  187. normal:{label:{show:true}},
  188. emphasis:{label:{show:true}}
  189. },
  190. data:[
  191. {name:'西藏', value:60},
  192. {name:'青海', value:167},
  193. {name:'宁夏', value:210},
  194. {name:'海南', value:252},
  195. {name:'甘肃', value:502},
  196. {name:'贵州', value:570},
  197. {name:'新疆', value:661},
  198. {name:'云南', value:8890},
  199. {name:'重庆', value:10010},
  200. {name:'吉林', value:5056},
  201. {name:'山西', value:2123},
  202. {name:'天津', value:9130},
  203. {name:'江西', value:10170},
  204. {name:'广西', value:6172},
  205. {name:'陕西', value:9251},
  206. {name:'黑龙江', value:5125},
  207. {name:'内蒙古', value:1435},
  208. {name:'安徽', value:9530},
  209. {name:'北京', value:51919},
  210. {name:'福建', value:3756},
  211. {name:'上海', value:59190},
  212. {name:'湖北', value:37109},
  213. {name:'湖南', value:8966},
  214. {name:'四川', value:31020},
  215. {name:'辽宁', value:7222},
  216. {name:'河北', value:3451},
  217. {name:'河南', value:9693},
  218. {name:'浙江', value:62310},
  219. {name:'山东', value:39231},
  220. {name:'江苏', value:35911},
  221. {name:'广东', value:55891}
  222. ]
  223. }
  224. ]
  225. }
  226. ]
  227. ,elemDataView = $('#LAY-index-pagethree').children('div')
  228. ,renderDataView = function(index){
  229. echartsApp[index] = echarts.init(elemDataView[index], layui.echartsTheme);
  230. echartsApp[index].setOption(options[index]);
  231. window.onresize = echartsApp[index].resize;
  232. };
  233. //没找到DOM,终止执行
  234. if(!elemDataView[0]) return;
  235. renderDataView(0);
  236. });
  237. //项目进展
  238. layui.use('table', function(){
  239. var $ = layui.$
  240. ,table = layui.table;
  241. table.render({
  242. elem: '#LAY-index-prograss'
  243. ,url: layui.setter.base + 'json/console/prograss.js' //模拟接口
  244. ,cols: [[
  245. {type: 'checkbox', fixed: 'left'}
  246. ,{field: 'prograss', title: '任务'}
  247. ,{field: 'time', title: '所需时间'}
  248. ,{field: 'complete', title: '完成情况'
  249. ,templet: function(d){
  250. if(d.complete == '已完成'){
  251. return '<del style="color: #5FB878;">'+ d.complete +'</del>'
  252. }else if(d.complete == '进行中'){
  253. return '<span style="color: #FFB800;">'+ d.complete +'</span>'
  254. }else{
  255. return '<span style="color: #FF5722;">'+ d.complete +'</span>'
  256. }
  257. }
  258. }
  259. ]]
  260. ,skin: 'line'
  261. });
  262. });
  263. //回复留言
  264. admin.events.replyNote = function(othis){
  265. var nid = othis.data('id');
  266. layer.prompt({
  267. title: '回复留言 ID:'+ nid
  268. ,formType: 2
  269. }, function(value, index){
  270. //这里可以请求 Ajax
  271. //…
  272. layer.msg('得到:'+ value);
  273. layer.close(index);
  274. });
  275. };
  276. exports('sample', {})
  277. });