course.js 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. // pages/course/course.js
  2. var util = require("../../utils/util.js");
  3. Page({
  4. data:{
  5. courses:[],
  6. banner:{
  7. delay:3000,
  8. timeoutProcess:null,
  9. currindex:0,
  10. bannerimg:[]
  11. },
  12. bannerTitle:"·项目概述·",
  13. chanpinTitle:"·相关产品·",
  14. bannerTitleImages : "https://rlzcgl.oss-cn-beijing.aliyuncs.com/wxminiprogram/images/Rlianimage/superBike.jpg",
  15. bannerText : "任联电动车防盗系统解决方案是杭州任联自主研发的成熟解决方案。其基本原理为:基于物联网超低功耗RFID有源技术和大数据轨迹刻画技术,监控中心、固定基站、车载基站、手持搜索机无缝...共同打造城市公共安全。(详情请登录任联官网http://www.renlianiot.com/查看)",
  16. ad:[]
  17. },
  18. onLoad:function(options){
  19. // 页面初始化 options为页面跳转所带来的参数
  20. var that=this;
  21. var coursesArr = util.getCourses(),
  22. bannerArr = util.getBanner(),
  23. bannerTitle = that.data.bannerTitle,
  24. chanpinTitle = that.chanpinTitle,
  25. ddongcheAD = util.getdiaodongcheData();
  26. that.setData({
  27. courses:coursesArr,
  28. banner:{
  29. currindex:0,
  30. bannerimg:bannerArr
  31. },
  32. ad:ddongcheAD
  33. });
  34. console.log(that.data.ad);
  35. that.changeBanner(0);
  36. },
  37. onReady:function(){
  38. // 页面渲染完成
  39. },
  40. onShow:function(){
  41. // 页面显示
  42. },
  43. onHide:function(){
  44. // 页面隐藏
  45. },
  46. onUnload:function(){
  47. // 页面关闭
  48. },
  49. changeBanner:function(index){
  50. var that = this,
  51. banner = that.data.banner,
  52. currindex = banner.currindex;
  53. banner.bannerimg[currindex].class ='';
  54. banner.bannerimg[index].class = 'active';
  55. banner.currindex = index;
  56. that.setData({
  57. "banner":banner
  58. });
  59. //showImg todo
  60. },
  61. timetochange:function(){
  62. var that = this,
  63. banner = that.data.banner,
  64. currindex = banner.currindex;
  65. if(currindex < banner.bannerimg.length - 1)
  66. {
  67. currindex ++;
  68. }else{
  69. currindex = 0;
  70. }
  71. that.changeBanner(currindex);
  72. },
  73. bindStlBanner:function(e){
  74. console.log(e);
  75. var that = this;
  76. var bannerIdx = e.currentTarget.dataset.index;
  77. clearTimeout(that.data.banner.timeoutProcess);
  78. that.changeBanner(bannerIdx);
  79. that.data.banner.timeoutProcess = setInterval(that.timetochange,3000);
  80. }
  81. })