base.js 1.2 KB

1234567891011121314151617181920212223242526272829303132333435
  1. import Vue from 'vue'
  2. console.info('loader success base.js...')
  3. Vue.prototype.routerTo = function (path) {
  4. this.$router.push({path: path})
  5. }
  6. Vue.prototype.timetrans = function (date) {
  7. var time = new Date(date * 1000)
  8. var Y = time.getFullYear() + '-'
  9. var M = (time.getMonth() + 1 < 10 ? '0' + (time.getMonth() + 1) : time.getMonth() + 1) + '-'
  10. var D = (time.getDate() < 10 ? '0' + (time.getDate()) : time.getDate()) + ' '
  11. var h = (time.getHours() < 10 ? '0' + time.getHours() : time.getHours()) + ':'
  12. var m = (time.getMinutes() < 10 ? '0' + time.getMinutes() : time.getMinutes()) + ':'
  13. var s = (time.getSeconds() < 10 ? '0' + time.getSeconds() : time.getSeconds())
  14. return Y + M + D + h + m + s
  15. }
  16. Vue.prototype.ClickInput = function (e) {
  17. e.target.select()
  18. }
  19. ;(function (doc, win) {
  20. var docEl = doc.documentElement
  21. var resizeEvt = 'orientationchange' in win ? 'orientationchange' : 'resize'
  22. var recalc = function () {
  23. var clientWidth = docEl.clientWidth
  24. if (clientWidth === undefined) return
  25. docEl.style.fontSize = 37.5 * (clientWidth / 375) + 'px'
  26. }
  27. if (doc.addEventListener === undefined) return
  28. win.addEventListener(resizeEvt, recalc, false)
  29. doc.addEventListener('DOMContentLoaded', recalc, false)
  30. })(document, window)