home.js 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. ;
  2. layui.define(['form','carousel','flow','laytpl'], function (e) {
  3. var s = layui.$,
  4. form = layui.form,
  5. flow = layui.flow,
  6. laytpl = layui.laytpl,
  7. carousel = layui.carousel;
  8. carousel.render({
  9. elem: '#index'
  10. ,width: '100%'
  11. ,height:s('body').width() *0.5
  12. ,arrow: 'none'
  13. });
  14. flow.load({
  15. elem: '.goods-list-recommend'
  16. ,done: function(page, next){
  17. s.post('/index/goods/load.html',{page:page,category:0},function(r){
  18. if (!r.code) {
  19. var tpl = s('#goods-list-recommend').html();
  20. laytpl(tpl).render(r.data, function(html){
  21. next(html, page < r.pages);
  22. })
  23. }else{
  24. layer.msg(r.msg)
  25. }
  26. });
  27. }
  28. });
  29. var home = function(){
  30. s('.layui-fluid').css('height',document.body.clientHeight+'px');
  31. if (s('.scroll').length > 0) {
  32. var head = document.getElementsByTagName('head')[0];
  33. var script = document.createElement('script');
  34. script.type = 'text/javascript';
  35. script.src = '/static/plugins/scroll/scroll.js';
  36. script.onload = script.onreadystatechange = function () {
  37. if (!this.readyState || this.readyState === "loaded" || this.readyState === "complete"){
  38. s('.scroll').myScroll({
  39. speed: 40,
  40. rowHeight: 32
  41. });
  42. script.onload = script.onreadystatechange = null;
  43. }
  44. };
  45. head.appendChild(script);
  46. }
  47. // home.prototype.dialognotice();
  48. }
  49. home.prototype.dialognotice = function() {
  50. layer.open({
  51. type: 1
  52. ,title: false
  53. ,closeBtn: false
  54. ,skin:'dialog-box'
  55. ,area: '300px;'
  56. ,shade: 0.8
  57. ,moveType: 1
  58. ,content: s('#dialognotice').html()
  59. ,success: function(layero){
  60. s('.layui-btn-confirm').on('click',function(){
  61. layer.closeAll()
  62. })
  63. }
  64. });
  65. };
  66. e('home',new home());
  67. })