bysyaItem.js 7.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261
  1. /*var isDrag = false;
  2. var tx, x, dwc, dwsl;*/
  3. $(function () {
  4. /* dwsl = $("#dwsl").val();*/
  5. /* 滚动事件 */
  6. var mScroll = new IScroll(".kzyxcsIscrollBig",{
  7. scrollbars: true,
  8. fadeScrollbars:true,
  9. shrinkScrollbars:'clip',
  10. scrollbars: 'custom',
  11. click:true,
  12. tap:true
  13. });
  14. setTimeout(function () {
  15. mScroll.refresh();
  16. }, 100);
  17. var mScrol1 = new IScroll(".iscrollCenter",{
  18. scrollbars: true,
  19. fadeScrollbars:true,
  20. shrinkScrollbars:'clip',
  21. scrollbars: 'custom',
  22. click:true,
  23. tap:true
  24. });
  25. selectDw(1);
  26. /* loadLeft();
  27. for (var i = 1; i <= dwsl; i++) {
  28. document.getElementById("circle" + i).addEventListener('touchend', function () {
  29. isDrag = false;
  30. });
  31. document.getElementById("circle" + i).addEventListener('touchstart', selectMouse);
  32. document.getElementById("circle" + i).addEventListener('touchmove', moveMouse);
  33. }*/
  34. /**
  35. * 拖拽
  36. */
  37. var block = document.getElementById("tb");
  38. var oW,oH;
  39. // 绑定touchstart事件
  40. block.addEventListener("touchstart", function(e) {
  41. var touches = e.touches[0];
  42. oW = touches.clientX - block.offsetLeft;
  43. oH = touches.clientY - block.offsetTop;
  44. //阻止页面的滑动默认事件
  45. document.addEventListener("touchmove",defaultEvent,false);
  46. },false);
  47. // 绑定touchmove事件
  48. block.addEventListener("touchmove", function(e) {
  49. var touches = e.touches[0];
  50. var oLeft = touches.clientX - oW;
  51. var oTop = touches.clientY - oH;
  52. //左右碰界判断
  53. if(oLeft < 0) {
  54. oLeft = 0;
  55. }else if(oLeft > document.documentElement.clientWidth - block.offsetWidth) {
  56. oLeft = (document.documentElement.clientWidth - block.offsetWidth);
  57. }
  58. //上下碰界判断
  59. if(oTop < 0) {
  60. oTop = 0;
  61. }else if(oTop > document.documentElement.clientHeight - block.offsetHeight) {
  62. oTop = (document.documentElement.clientHeight - block.offsetHeight);
  63. }
  64. block.style.left = oLeft + "px";
  65. block.style.top = oTop + "px";
  66. },false);
  67. // 绑定touchend事件
  68. block.addEventListener("touchend",function() {
  69. document.removeEventListener("touchmove",defaultEvent,false);
  70. },false);
  71. /**
  72. * 同步事件
  73. */
  74. /* 弹出修改删除框*/
  75. $("#tb").on("click",function(){
  76. $(".xgmsgbox").show(showOverlay());
  77. mScrol1.refresh();
  78. });
  79. //点击td选中input
  80. $(".listcenter>li,.checkBox").on("click",function (e) {
  81. if (e && e.stopPropagation) {
  82. e.stopPropagation();
  83. } else {
  84. window.event.cancelBubble = true;
  85. }
  86. if ($(this).find("input[type='checkbox']").is(":checked")) {
  87. $(this).find("input[type='checkbox']").removeAttr("checked");
  88. } else {
  89. $(this).find("input[type='checkbox']").prop("checked", true);
  90. }
  91. });
  92. /* 点击遮罩层或者取消按钮隐藏弹出框*/
  93. $("#overlay,.qx,.qd").on("click",function(){
  94. $(".xgmsgbox").hide(hideOverlay());
  95. });
  96. //touchmove的阻止浏览器或者屏幕滚动默认事件
  97. document.addEventListener('touchmove', defaultEvent, false);
  98. });
  99. function defaultEvent(e) {
  100. e.preventDefault();
  101. }
  102. /**
  103. * 温度变更
  104. * @param id
  105. * @param type
  106. */
  107. function changeWd(id, type, obj) {
  108. var gwd = parseFloat($("#gwd" + id).html());
  109. if (type == 1) {
  110. var dwd = $("#dwd" + id).html();
  111. if (parseFloat(dwd) < gwd - 0.5) {
  112. $("#gwd" + id).html(gwd - 0.5);
  113. $("#dwd" + (parseInt(id) + 1)).html(gwd - 0.5);
  114. }
  115. }
  116. if (type == 2) {
  117. var gwd2;
  118. if ($("#gwd" + (parseInt(id) + 1)).html()) {
  119. gwd2 = $("#gwd" + (parseInt(id) + 1)).html();
  120. } else {
  121. gwd2 = 50.5;
  122. }
  123. if (parseFloat(gwd2) > gwd + 0.5) {
  124. $("#gwd" + id).html(gwd + 0.5);
  125. $("#dwd" + (parseInt(id) + 1)).html(gwd + 0.5);
  126. }
  127. }
  128. }
  129. /*function moveMouse(e) {
  130. if (isDrag) {
  131. var n = tx + e.touches[0].pageX - x;
  132. var width = $(window).width() * 0.9 - 15;
  133. var max,min;
  134. if (dwc != dwsl) {
  135. max = $("#circle" + parseInt(dwc + 1)).css("left");
  136. if ((max + "").indexOf("%") != -1) {
  137. max = parseInt(max.substring(0, max.length-1)) / 100 * width;
  138. }
  139. if ((max + "").indexOf("px") != -1) {
  140. max = max.replace("px", "");
  141. }
  142. } else {
  143. max = 50;
  144. }
  145. if (dwc == 1) {
  146. min = 0;
  147. } else {
  148. min = $("#circle" + parseInt(dwc - 1)).css("left");
  149. if ((min + "").indexOf("%") != -1) {
  150. min = parseInt(min.substring(0, min.length-1)) / 100 * width;
  151. }
  152. if ((min + "").indexOf("px") != -1) {
  153. min = min.replace("px", "");
  154. }
  155. }
  156. console.log(min + "-" + max);
  157. if (n <= min || n > max) {
  158. return;
  159. }
  160. $("#circle" + dwc).css("left", (n / width * 100) + "%");
  161. $("#gwd" + dwc).html(parseInt(n / width * 50));
  162. $("#dwd" + (parseInt(dwc) + 1)).html(parseInt(n / width * 50));
  163. return false;
  164. }
  165. }
  166. function selectMouse(e) {
  167. isDrag = true;
  168. tx = parseInt(document.getElementById("circle" + dwc).style.left + 0);
  169. x = e.touches[0].pageX;
  170. return false;
  171. }
  172. function loadLeft() {
  173. for (var i = 1; i <= dwsl; i++) {
  174. var gw = $("#gwd" + i).html();
  175. var width = $(window).width() * 0.9 - 15;
  176. var left = parseInt(gw) / 50 * width;
  177. $("#circle" + i).css("left", left);
  178. }
  179. }*/
  180. /**
  181. * 返回
  182. */
  183. function yxcsBackUrl() {
  184. var zsid = $("#zsid").val();
  185. var zsbz = $("#zsbz").val();
  186. if (zsbz == "2") {
  187. haifm.loadMobilePage("haifm", "mcZsHjkzView.htm?zsid=" + zsid + "&from=zslist");
  188. } else {
  189. haifm.loadMobilePage("haifm", "mcZsView.htm?zsid=" + zsid + "&from=zslist");
  190. }
  191. }
  192. /**
  193. * 档位切换
  194. * @param id
  195. */
  196. function selectDw(key, val) {
  197. var dw = parseInt(key);
  198. if (val != undefined && val != "") {
  199. var xdw = parseInt(val);
  200. if (dw + xdw < 1 || dw + xdw > parseInt($("#dwsl").val())) {
  201. return;
  202. }
  203. $("#dw" + dw).hide();
  204. dw = dw + xdw;
  205. }
  206. $("#dw" + dw).show();
  207. dwc = dw;
  208. // isDrag = false;
  209. }
  210. /**
  211. * 开关
  212. */
  213. function kgbz(obj, id) {
  214. $("#gzsj" + id).removeAttr("disabled");
  215. $("#jssj" + id).removeAttr("disabled");
  216. // var kg = $(obj).parent().parent().find("input");
  217. // if ($(kg).val() == 1) {
  218. // $(kg).val("2");
  219. // $(obj).parent().find("span").attr("style", "background-color:''");
  220. // $("#gzsj" + id).removeAttr("disabled");
  221. // $("#jssj" + id).removeAttr("disabled");
  222. // } else if ($(kg).val() == 2) {
  223. // $(kg).val("1");
  224. // $(obj).parent().find("span").attr("style", "background-color:#f0f0f0");
  225. // $("#gzsj" + id).attr("disabled", "disabled");
  226. // $("#jssj" + id).attr("disabled", "disabled");
  227. // }
  228. }
  229. /* 显示遮罩层 */
  230. function showOverlay(){
  231. $("#overlay").height(pageHeight());
  232. $("#overlay").width(pageWidth());
  233. // fadeTo第一个参数为速度,第二个为透明度
  234. // 多重方式控制透明度,保证兼容性,但也带来修改麻烦的问题
  235. $("#overlay").fadeTo(200, 0.5);
  236. };
  237. /* 隐藏覆盖层 */
  238. function hideOverlay(){
  239. $("#overlay").fadeOut(200);
  240. };
  241. /* 当前页面高度 */
  242. function pageHeight(){
  243. return document.body.scrollHeight;
  244. };
  245. /* 当前页面宽度 */
  246. function pageWidth(){
  247. return document.body.scrollWidth;
  248. };