fixedbar.js 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. mbui.define([], function (exports) {
  2. $('body').append('<div class="mbui-fixed-bar">\
  3. <div class="fixed-bar-box">\
  4. <button class="fixed-bar-btn"><span class="menutoggle"><span></span></span></button>\
  5. </div>\
  6. <div class="fixed-bar-item">\
  7. <a href="/qiye/index/index">工作台</a>\
  8. <a href="/qiye/customer/index">客户<br>管理</a>\
  9. <a href="/qiye/contract/index">合同<br>管理</a>\
  10. <a href="/qiye/project/index">项目<br>管理</a>\
  11. <a href="/qiye/msg/index">消息<br>通知</a>\
  12. </div>\
  13. </div>');
  14. $('.fixed-bar-btn').click(function () {
  15. $(this).toggleClass('active');
  16. return $('.fixed-bar-item').toggleClass('open');
  17. });
  18. $('.fixed-bar-item').on('click','a',function(e){
  19. e.preventDefault();
  20. let href=$(this).attr('href');
  21. location.replace(href);
  22. })
  23. var startX, startY, moveX, moveY;
  24. var browserWidth = $(window).width();
  25. var browserHeight = $(window).height();
  26. var $button = $('.mbui-fixed-bar');
  27. $button.on('touchstart', function(e){
  28. startX = e.touches[0].pageX - parseInt($button.css('left'));
  29. startY = e.touches[0].pageY - parseInt($button.css('top'));
  30. $button.on('touchmove', function(e){
  31. e.preventDefault();
  32. moveX = e.touches[0].pageX - startX;
  33. moveY = e.touches[0].pageY - startY;
  34. if(moveY>100 && moveY<browserHeight-206){
  35. $button.css({
  36. top: moveY + 'px'
  37. });
  38. }
  39. if(moveX>8 && moveX<browserWidth-166){
  40. $button.css({
  41. left: moveX + 'px'
  42. });
  43. }
  44. });
  45. $button.on('touchend', function(){
  46. $button.off('touchmove').off('touchend');
  47. });
  48. });
  49. // 导出Tab模块
  50. exports('fixedbar', function () {
  51. });
  52. });