index.js 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110
  1. //index.js
  2. //获取应用实例
  3. var app = getApp();
  4. var util = require("../../utils/util.js");
  5. Page({
  6. data: {
  7. banner:{
  8. delay:3000,
  9. timeoutProcess:null,
  10. currindex:0,
  11. bannerimg:[]
  12. },
  13. nav:[],
  14. ad:[],
  15. course_grp:[],
  16. moreCourses:{
  17. title:"已经到底,查看更多课程 >",
  18. url:"../course/course"
  19. },
  20. userInfo: {},
  21. pageTitle : {}
  22. },
  23. /*点击banner上的圆选择相应的图片 */
  24. bindStlBanner:function(e){
  25. console.log(e);
  26. var that = this;
  27. var bannerIdx = e.currentTarget.dataset.index;
  28. clearTimeout(that.data.banner.timeoutProcess);
  29. that.changeBanner(bannerIdx);
  30. that.data.banner.timeoutProcess = setInterval(that.timetochange,3000);
  31. },
  32. onLoad: function () {
  33. console.log('onLoad index')
  34. var that = this;
  35. var bannerArr = util.getBanner(),
  36. navArr = util.getNav(),
  37. adArr = util.getAd(),
  38. courseGrp = util.getCourse();
  39. that.setData({
  40. banner:{
  41. currindex:0,
  42. bannerimg:bannerArr
  43. },
  44. nav:navArr,
  45. ad:adArr,
  46. course_grp:courseGrp,
  47. pageTitle : {
  48. title : "公司简介",
  49. text : "杭州任联科技有限公司聚焦于智慧城市安防领域,是一家专业研究和推广无线射频识别技术(RFID)的高新技术企业,是中国领先的RFID技术设备制造商和解决方案提供商之一;公司集无线射频识别技术的研发、生产、销售和服务于一体,能够为不同领域的用户度身定制完善的专业的系统解决方案,满足不同行业的个性化需求。",
  50. array : [
  51. {
  52. title : "涉及领域",
  53. text : "智慧校园;电动车防盗解决方案;老人、小孩及特殊人员定位;有源标签资产管理等解决方案。"
  54. },{
  55. title : "研发实力",
  56. text : "创始团队有深厚的华为华三研发背景及资源优势,网关、物联网、平台技术积累深厚,深刻理解行业技术发展趋势。"
  57. }
  58. ]
  59. }
  60. });
  61. that.changeBanner(0);
  62. //调用应用实例的方法获取全局数据
  63. app.getUserInfo(function(userInfo){
  64. //更新数据
  65. that.setData({
  66. userInfo:userInfo
  67. })
  68. })
  69. console.log(that.data);
  70. },
  71. onShow:function(){
  72. console.log("onshow index");
  73. var that = this;
  74. that.data.banner.timeoutProcess = setInterval(that.timetochange,3000);
  75. console.log(that.data);
  76. },
  77. onHide:function(){
  78. var that=this;
  79. clearTimeout(that.data.banner.timeoutProcess);
  80. },
  81. /**根据bannerArray的index显示 */
  82. changeBanner:function(index){
  83. var that = this,
  84. banner = that.data.banner,
  85. currindex = banner.currindex;
  86. banner.bannerimg[currindex].class ='';
  87. banner.bannerimg[index].class = 'active';
  88. banner.currindex = index;
  89. that.setData({
  90. "banner":banner
  91. });
  92. //showImg todo
  93. },
  94. /*轮播banner */
  95. timetochange:function(){
  96. var that = this,
  97. banner = that.data.banner,
  98. currindex = banner.currindex;
  99. if(currindex < banner.bannerimg.length - 1)
  100. {
  101. currindex ++;
  102. }else{
  103. currindex = 0;
  104. }
  105. that.changeBanner(currindex);
  106. }
  107. })