index.js 7.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235
  1. function idldl(){
  2. $.get("tem/sesCheck.php",{},function(result){
  3. if(result=="0"){
  4. document.getElementById("idlno").style.display="";
  5. document.getElementById("idlyes").style.display="none";
  6. }else{
  7. document.getElementById("idlno").style.display="none";
  8. document.getElementById("idlyes").style.display="";
  9. a=result.split(" ");
  10. document.getElementById("itouxiang").src=a[3];
  11. document.getElementById("imoney").innerHTML=a[2];
  12. document.getElementById("iuserid").innerHTML=a[0];
  13. }
  14. });
  15. }
  16. //团购倒计时开始
  17. var responsesj;
  18. var time_server_client,timerID,xs,time_end1,time_end2,time_end3,time_end4,time_end5,timerID1,timerID2,timerID3,timerID4,timerID5;
  19. function show_time(djsid)
  20. {
  21. var time_now,time_distance,str_time;
  22. var int_day,int_hour,int_minute,int_second;
  23. var time_now=new Date();
  24. time_now=time_now.getTime()+time_server_client;
  25. if(djsid==1){time_end=time_end1;timerID=timerID1;}
  26. else if(djsid==2){time_end=time_end2;timerID=timerID2;}
  27. else if(djsid==3){time_end=time_end3;timerID=timerID3;}
  28. else if(djsid==4){time_end=time_end4;timerID=timerID4;}
  29. else if(djsid==5){time_end=time_end5;timerID=timerID5;}
  30. time_distance=time_end-time_now;
  31. if(time_distance>0)
  32. {
  33. int_day=parseInt(Math.floor(time_distance/86400000))
  34. time_distance-=int_day*86400000;
  35. int_hour=parseInt(Math.floor(time_distance/3600000))
  36. time_distance-=int_hour*3600000;
  37. int_minute=parseInt(Math.floor(time_distance/60000))
  38. time_distance-=int_minute*60000;
  39. int_second=parseInt(Math.floor(time_distance/1000))
  40. mm = Math.floor((time_distance % 1000)/100);
  41. tv=int_day+"<span class='s1'>天</span>";
  42. tv=tv+int_hour+"<span class='s1'>时</span>";
  43. tv=tv+int_minute+"<span class='s1'>分</span>";
  44. tv=tv+int_second+"." + mm+"<span class='s1'>秒</span>";
  45. document.getElementById("djs"+djsid).innerHTML=""+tv;
  46. setTimeout("show_time("+djsid+")",100);
  47. }
  48. else
  49. {
  50. tv="<span class='feng'>已结束</span>";
  51. document.getElementById("djs"+djsid).innerHTML=tv;
  52. document.getElementById("s"+djsid+"sj1").innerHTML=0;
  53. document.getElementById("s"+djsid+"sj2").innerHTML=0;
  54. document.getElementById("s"+djsid+"sj3").innerHTML=0;
  55. clearTimeout(timerID)
  56. }
  57. }
  58. var xmlHttpsj = false;
  59. try {
  60. xmlHttpsj = new ActiveXObject("Msxml2.XMLHTTP");
  61. } catch (e) {
  62. try {
  63. xmlHttpsj = new ActiveXObject("Microsoft.XMLHTTP");
  64. } catch (e2) {
  65. xmlHttpsj = false;
  66. }
  67. }
  68. if (!xmlHttpsj && typeof XMLHttpRequest != 'undefined') {
  69. xmlHttpsj = new XMLHttpRequest();
  70. }
  71. function updatePagesj() {
  72. if (xmlHttpsj.readyState == 4) {
  73. responsesj = xmlHttpsj.responseText;
  74. if(document.getElementById("dqsj1")){dsj1=document.getElementById("dqsj1").innerHTML;time_end1=new Date(dsj1);time_end1=time_end1.getTime();}//结束的时间
  75. if(document.getElementById("dqsj2")){dsj2=document.getElementById("dqsj2").innerHTML;time_end2=new Date(dsj2);time_end2=time_end2.getTime();}//结束的时间
  76. if(document.getElementById("dqsj3")){dsj3=document.getElementById("dqsj3").innerHTML;time_end3=new Date(dsj3);time_end3=time_end3.getTime();}//结束的时间
  77. if(document.getElementById("dqsj4")){dsj4=document.getElementById("dqsj4").innerHTML;time_end4=new Date(dsj4);time_end4=time_end4.getTime();}//结束的时间
  78. if(document.getElementById("dqsj5")){dsj5=document.getElementById("dqsj5").innerHTML;time_end5=new Date(dsj5);time_end5=time_end5.getTime();}//结束的时间
  79. time_now_server=new Date(responsesj);time_now_server=time_now_server.getTime();
  80. time_now_client=new Date();time_now_client=time_now_client.getTime();
  81. time_server_client=time_now_server-time_now_client;
  82. if(document.getElementById("dqsj1")){timerID1=setTimeout("show_time(1)",100);}
  83. if(document.getElementById("dqsj2")){timerID2=setTimeout("show_time(2)",100);}
  84. if(document.getElementById("dqsj3")){timerID3=setTimeout("show_time(3)",100);}
  85. if(document.getElementById("dqsj4")){timerID4=setTimeout("show_time(4)",100);}
  86. if(document.getElementById("dqsj5")){timerID5=setTimeout("show_time(5)",100);}
  87. }
  88. }
  89. function userChecksj(){
  90. if(document.getElementById("dqsj1")){
  91. var url = document.getElementById("webhttp").innerHTML+"tem/sjCheck.php";
  92. xmlHttpsj.open("post", url, true);
  93. xmlHttpsj.onreadystatechange = updatePagesj;
  94. xmlHttpsj.send(null);
  95. }
  96. }
  97. //团购倒计时结束
  98. //切换代码开始
  99. var Class = {
  100. create: function() {
  101. return function() {
  102. this.initialize.apply(this, arguments);
  103. }
  104. }
  105. }
  106. Object.extend = function(destination, source) {
  107. for (var property in source) {
  108. destination[property] = source[property];
  109. }
  110. return destination;
  111. }
  112. var TransformView = Class.create();
  113. TransformView.prototype = {
  114. //容器对象,滑动对象,切换参数,切换数量
  115. initialize: function(container, slider, parameter, count, options) {
  116. if(parameter <= 0 || count <= 0) return;
  117. var oContainer = document.getElementById(container), oSlider = document.getElementById(slider), oThis = this;
  118. this.Index = 0;//当前索引
  119. this._timer = null;//定时器
  120. this._slider = oSlider;//滑动对象
  121. this._parameter = parameter;//切换参数
  122. this._count = count || 0;//切换数量
  123. this._target = 0;//目标参数
  124. this.SetOptions(options);
  125. this.Up = !!this.options.Up;
  126. this.Step = Math.abs(this.options.Step);
  127. this.Time = Math.abs(this.options.Time);
  128. this.Auto = !!this.options.Auto;
  129. this.Pause = Math.abs(this.options.Pause);
  130. this.onStart = this.options.onStart;
  131. this.onFinish = this.options.onFinish;
  132. oContainer.style.overflow = "hidden";
  133. oContainer.style.position = "relative";
  134. oSlider.style.position = "absolute";
  135. oSlider.style.top = oSlider.style.left = 0;
  136. },
  137. //设置默认属性
  138. SetOptions: function(options) {
  139. this.options = {//默认值
  140. Up: true,//是否向上(否则向左)
  141. Step: 5,//滑动变化率
  142. Time: 10,//滑动延时
  143. Auto: true,//是否自动转换
  144. Pause: 2000,//停顿时间(Auto为true时有效)
  145. onStart: function(){},//开始转换时执行
  146. onFinish: function(){}//完成转换时执行
  147. };
  148. Object.extend(this.options, options || {});
  149. },
  150. //开始切换设置
  151. Start: function() {
  152. if(this.Index < 0){
  153. this.Index = this._count - 1;
  154. } else if (this.Index >= this._count){ this.Index = 0; }
  155. this._target = -1 * this._parameter * this.Index;
  156. this.onStart();
  157. this.Move();
  158. },
  159. //移动
  160. Move: function() {
  161. clearTimeout(this._timer);
  162. var oThis = this, style = this.Up ? "top" : "left", iNow = parseInt(this._slider.style[style]) || 0, iStep = this.GetStep(this._target, iNow);
  163. if (iStep != 0) {
  164. this._slider.style[style] = (iNow + iStep) + "px";
  165. this._timer = setTimeout(function(){ oThis.Move(); }, this.Time);
  166. } else {
  167. this._slider.style[style] = this._target + "px";
  168. this.onFinish();
  169. if (this.Auto) { this._timer = setTimeout(function(){ oThis.Index++; oThis.Start(); }, this.Pause); }
  170. }
  171. },
  172. //获取步长
  173. GetStep: function(iTarget, iNow) {
  174. var iStep = (iTarget - iNow) / this.Step;
  175. if (iStep == 0) return 0;
  176. if (Math.abs(iStep) < 1) return (iStep > 0 ? 1 : -1);
  177. return iStep;
  178. },
  179. //停止
  180. Stop: function(iTarget, iNow) {
  181. clearTimeout(this._timer);
  182. this._slider.style[this.Up ? "top" : "left"] = this._target + "px";
  183. }
  184. };
  185. window.onload=function(){
  186. function Each(list, fun){
  187. for (var i = 0, len = list.length; i < len; i++) { fun(list[i], i); }
  188. };
  189. var objs = document.getElementById("idNum").getElementsByTagName("li");
  190. var tv = new TransformView("idTransformView", "idSlider", 271, document.getElementById("qhai").innerHTML, {
  191. onStart : function(){ Each(objs, function(o, i){ o.className = tv.Index == i ? "on" : ""; }) }//按钮样式
  192. });
  193. tv.Start();
  194. Each(objs, function(o, i){
  195. o.onmouseover = function(){
  196. o.className = "on";
  197. tv.Auto = false;
  198. tv.Index = i;
  199. tv.Start();
  200. }
  201. o.onmouseout = function(){
  202. o.className = "";
  203. tv.Auto = true;
  204. tv.Start();
  205. }
  206. })
  207. }
  208. //切换代码结束