util.js 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130
  1. function formatTime(date) {
  2. var year = date.getFullYear()
  3. var month = date.getMonth() + 1
  4. var day = date.getDate()
  5. var hour = date.getHours()
  6. var minute = date.getMinutes()
  7. var second = date.getSeconds()
  8. return [year, month, day].map(formatNumber).join('-') + ' ' + [hour, minute, second].map(formatNumber).join(':')
  9. }
  10. function formatNumber(n) {
  11. n = n.toString()
  12. return n[1] ? n : '0' + n
  13. }
  14. module.exports = {
  15. formatTime: formatTime
  16. }
  17. // function imageUtil(e) {
  18. // var imageSize = {};
  19. // var originalWidth = e.detail.width;//图片原始宽
  20. // var originalHeight = e.detail.height;//图片原始高
  21. // var originalScale = originalHeight / originalWidth;//图片高宽比
  22. // //获取屏幕宽高
  23. // wx.getSystemInfo({
  24. // success: function (res) {
  25. // var windowWidth = res.windowWidth;
  26. // var windowHeight = res.windowHeight;
  27. // var windowscale = windowHeight / windowWidth;//屏幕高宽比
  28. // imageSize.imageHeight = (windowWidth * originalHeight) / originalWidth;
  29. // }
  30. // })
  31. // //return imageSize;
  32. // }
  33. // module.exports = {
  34. // imageUtil: imageUtil
  35. // }
  36. // import _Promise from 'bluebird';
  37. // /**
  38. // * @param {Function} fun 接口
  39. // * @param {Object} options 接口参数
  40. // * @returns {Promise} Promise对象
  41. // */
  42. // function Promise(fun, options) {
  43. // options = options || {};
  44. // return new _Promise((resolve, reject) => {
  45. // if (typeof fun !== 'function') {
  46. // reject();
  47. // }
  48. // options.success = resolve;
  49. // options.fail = reject;
  50. // fun(options);
  51. // });
  52. // }
  53. // /**
  54. // * 手势库
  55. // */
  56. // function touchstart(e, _this) {
  57. // const t = e.touches[0],
  58. // startX = t.clientX,
  59. // startY = t.clientY;
  60. // _this.setData({
  61. // 'gesture.startX': startX,
  62. // 'gesture.startY': startY,
  63. // 'gesture.out': true
  64. // })
  65. // }
  66. // /**
  67. // * 左滑
  68. // * @returns {boolean} 布尔值
  69. // */
  70. // function isLeftSlide(e, _this) {
  71. // if (_this.data.gesture.out) {
  72. // const t = e.touches[0],
  73. // deltaX = t.clientX - _this.data.gesture.startX,
  74. // deltaY = t.clientY - _this.data.gesture.startY;
  75. // if (deltaX < -20 && deltaX > -40 && deltaY < 8 && deltaY > -8) {
  76. // _this.setData({
  77. // 'gesture.out': false
  78. // })
  79. // return true;
  80. // } else {
  81. // return false;
  82. // }
  83. // }
  84. // }
  85. // /**
  86. // * 右滑
  87. // * @returns {boolean} 布尔值
  88. // */
  89. // function isRightSlide(e, _this) {
  90. // if (_this.data.gesture.out) {
  91. // const t = e.touches[0],
  92. // deltaX = t.clientX - _this.data.gesture.startX,
  93. // deltaY = t.clientY - _this.data.gesture.startY;
  94. // if (deltaX > 20 && deltaX < 40 && deltaY < 8 && deltaY > -8) {
  95. // _this.setData({
  96. // 'gesture.out': false
  97. // })
  98. // return true;
  99. // } else {
  100. // return false;
  101. // }
  102. // }
  103. // }
  104. // module.exports = {
  105. // Promise: Promise,
  106. // Gesture: {
  107. // touchstart: touchstart,
  108. // isLeftSlide: isLeftSlide,
  109. // isRightSlide: isRightSlide
  110. // }
  111. // }