诡异!!!ecshop 首页广告轮播 只显示三张图片。。。。

2016-07-07 15:11 来源:www.chinab4c.com 作者:ecshop专家

ecshop首页广告轮播,不知道怎么回事,怎么设置都不行,只显示三张图片。。。

以下是首页代码
  1. <div class="container" id="idTransformView" style="overflow: hidden; position: relative;">
  2. <ul class="slider" id="idSlider" style="position: absolute; left: 0px; top: -420px;">
  3. <li><a href="http://pds9.com/category.php?id=1&brand=57&price_min=0&price_max=0" target="_blank"><img src="data/afficheimg/20140416taydqh.jpg"></a></li>
  4. <li><a href="http://www.pds9.com" target="_blank"><img src="data/afficheimg/20140416zxaahx.jpg"></a></li>
  5. <li><a href="http://pds9.com/category.php?id=12" target="_blank"><img src="data/afficheimg/20140416jgqwht.jpg"></a></li>
  6. <li><a href="http://pds9.com/category.php?id=6" target="_blank"><img src="data/afficheimg/20140416btcanj.jpg"></a></li>
  7. <li><a href="http://pds9.com/goods.php?id=424" target="_blank"><img src="data/afficheimg/20140416wltnxi.jpg"></a></li>
  8. <li><a href="http://" target="_blank"><img src="data/afficheimg/20140416mwsean.jpg"></a></li>

  9. </ul>
  10. <ul class="num" id="idNum">


  11. <li class="">
  12. 1 </li>
  13. <li class="on">
  14. 2 </li>
  15. <li class="">
  16. 3 </li>
  17. <li class="">
  18. 4 </li>
  19. <li class="">
  20. 5 </li>
  21. <li class="">
  22. 6 </li>

  23. </ul>
  24. </div>


  25. <script type="text/javascript">
  26. var $ = function (id) {
  27. return "string" == typeof id ? document.getElementById(id) : id;
  28. };
  29. var Class = {
  30. create: function() {
  31. return function() {
  32. this.initialize.apply(this, arguments);
  33. }
  34. }
  35. }
  36. Object.extend = function(destination, source) {
  37. for (var property in source) {
  38. destination[property] = source[property];
  39. }
  40. return destination;
  41. }
  42. var TransformView = Class.create();
  43. TransformView.prototype = {
  44. //容器对象,滑动对象,切换参数,切换数量
  45. initialize: function(container, slider, parameter, count, opti**) {
  46. if(parameter <= 0 || count <= 0) return;
  47. var oContainer = $(container), oSlider = $(slider), oThis = this;
  48. this.Index = 0;//当前索引

  49. this._timer = null;//定时器
  50. this._slider = oSlider;//滑动对象
  51. this._parameter = parameter;//切换参数
  52. this._count = count || 0;//切换数量
  53. this._target = 0;//目标参数

  54. this.SetOpti**(opti**);

  55. this.Up = !!this.opti**.Up;
  56. this.Step = Math.abs(this.opti**.Step);
  57. this.Time = Math.abs(this.opti**.Time);
  58. this.Auto = !!this.opti**.Auto;
  59. this.Pause = Math.abs(this.opti**.Pause);
  60. this.**tart = this.opti**.**tart;
  61. this.onFinish = this.opti**.onFinish;

  62. oContainer.style.overflow = "hidden";
  63. oContainer.style.position = "relative";

  64. oSlider.style.position = "absolute";
  65. oSlider.style.top = oSlider.style.left = 0;
  66. },
  67. //设置默认属性
  68. SetOpti**: function(opti**) {
  69. this.opti** = {//默认值
  70. Up: true,//是否向上(否则向左)
  71. Step: 5,//滑动变化率
  72. Time: 10,//滑动延时
  73. Auto: true,//是否自动转换
  74. Pause: 2000,//停顿时间(Auto为true时有效)
  75. **tart: function(){},//开始转换时执行
  76. onFinish: function(){}//完成转换时执行
  77. };
  78. Object.extend(this.opti**, opti** || {});
  79. },
  80. //开始切换设置
  81. Start: function() {
  82. if(this.Index < 0){
  83. this.Index = this._count - 1;
  84. } else if (this.Index >= this._count){this.Index = 0;}

  85. this._target = -1 * this._parameter * this.Index;
  86. this.**tart();
  87. this.Move();
  88. },
  89. //移动
  90. Move: function() {
  91. clearTimeout(this._timer);
  92. var oThis = this, style = this.Up ? "top" : "left", iNow = parseInt(this._slider.style[style]) || 0, iStep = this.GetStep(this._target, iNow);

  93. if (iStep != 0) {
  94. this._slider.style[style] = (iNow + iStep) + "px";
  95. this._timer = setTimeout(function(){oThis.Move();}, this.Time);
  96. } else {
  97. this._slider.style[style] = this._target + "px";
  98. this.onFinish();
  99. if (this.Auto) { this._timer = setTimeout(function(){oThis.Index++; oThis.Start();}, this.Pause); }
  100. }
  101. },
  102. //获取步长
  103. GetStep: function(iTarget, iNow) {
  104. var iStep = (iTarget - iNow) / this.Step;
  105. if (iStep == 0) return 0;
  106. if (Math.abs(iStep) < 1) return (iStep > 0 ? 1 : -1);
  107. return iStep;
  108. },
  109. //停止
  110. Stop: function(iTarget, iNow) {
  111. clearTimeout(this._timer);
  112. this._slider.style[this.Up ? "top" : "left"] = this._target + "px";
  113. }
  114. };
  115. window.onload=function(){
  116. function Each(list, fun){
  117. for (var i = 0, len = list.length; i < len; i++) {fun(list[i], i);}
  118. };

  119. var objs = $("idNum").getElementsByTagName("li");

  120. var tv = new TransformView("idTransformView", "idSlider", 420, 3, {
  121. **tart : function(){ Each(objs, function(o, i){o.className = tv.Index == i ? "on" : "";}) }//按钮样式
  122. });

  123. tv.Start();

  124. Each(objs, function(o, i){
  125. o.onmouseover = function(){
  126. o.className = "on";
  127. tv.Auto = false;
  128. tv.Index = i;
  129. tv.Start();
  130. }
  131. o.onmouseout = function(){
  132. o.className = "";
  133. tv.Auto = true;
  134. tv.Start();
  135. }
  136. })

  137. ////////////////////////test2

  138. var objs2 = $("idNum2").getElementsByTagName("li");

  139. var tv2 = new TransformView("idTransformView2", "idSlider2", 990, 3, {
  140. **tart: function(){ Each(objs2, function(o, i){o.className = tv2.Index == i ? "on" : "";}) },//按钮样式
  141. Up: false
  142. });

  143. tv2.Start();

  144. Each(objs2, function(o, i){
  145. o.onmouseover = function(){
  146. o.className = "on";
  147. tv2.Auto = false;
  148. tv2.Index = i;
  149. tv2.Start();
  150. }
  151. o.onmouseout = function(){
  152. o.className = "";
  153. tv2.Auto = true;
  154. tv2.Start();
  155. }
  156. })

  157. $("idStop").onclick = function(){tv2.Auto = false; tv2.Stop();}
  158. $("idStart").onclick = function(){tv2.Auto = true; tv2.Start();}
  159. $("idNext").onclick = function(){tv2.Index++; tv2.Start();}
  160. $("idPre").onclick = function(){tv2.Index--;tv2.Start();}
  161. $("idFast").onclick = function(){ if(--tv2.Step <= 0){tv2.Step = 1;} }
  162. $("idSlow").onclick = function(){ if(++tv2.Step >= 10){tv2.Step = 10;} }
  163. $("idReduce").onclick = function(){ tv2.Pause-=1000; if(tv2.Pause <= 0){tv2.Pause = 0;} }
  164. $("idAdd").onclick = function(){ tv2.Pause+=1000; if(tv2.Pause >= 5000){tv2.Pause = 5000;} }

  165. $("idReset").onclick = function(){
  166. tv2.Step = Math.abs(tv2.opti**.Step);
  167. tv2.Time = Math.abs(tv2.opti**.Time);
  168. tv2.Auto = !!tv2.opti**.Auto;
  169. tv2.Pause = Math.abs(tv2.opti**.Pause);
  170. }

  171. }
  172. </script>
复制代码



请教各位,这究竟是神马问题啊?明明6张图片呢。只显示仨,但是轮播哪里依旧显示123456只是123可点,456不显示也不可点击。

回答:
问题基本解决,修改index_ad.lbi 库文件
  1. var tv = new TransformView("idTransformView", "idSlider", 420, 3, {
  2. **tart : function(){ Each(objs, function(o, i){ o.className = tv.Index == i ? "on" : ""; }) }//按钮样式
  3. });
复制代码
修改为var tv = new TransformView("idTransformView", "idSlider", 420, 6
3改为6,6为图片数量
  1. var tv2 = new TransformView("idTransformView2", "idSlider2", 990, 3, {
  2. **tart: function(){ Each(objs2, function(o, i){ o.className = tv2.Index == i ? "on" : ""; }) },//按钮样式
  3. Up: false
  4. });
复制代码
一样把3改为6.


如果能把3这个数字改为图片总数的变量就更好了。

仔细检查下代码