main.js 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. import Vue from 'vue'
  2. import App from './App'
  3. import uView from "uview-ui"
  4. Vue.use(uView)
  5. import {myRequest} from './util/api.js'
  6. Vue.prototype.$myRequest=myRequest
  7. Vue.config.productionTip = false
  8. App.mpType = 'app'
  9. Vue.filter('timeFormat',function(time){
  10. function fun(a){
  11. return String(a).length==1?'0'+a: a
  12. }
  13. let date= new Date(time*1000)
  14. let y=date.getFullYear()
  15. let m=date.getMonth()+1
  16. let d=date.getDate()
  17. let h=date.getHours()
  18. let min=date.getMinutes()
  19. let sec=date.getSeconds()
  20. return `${y}-${fun(m)}-${fun(d)} ${fun(h)}:${fun(min)}:${fun(sec)}`
  21. })
  22. Vue.prototype.formatTime = function (thistime,fmt = 'yyyy-MM-dd hh:mm:ss') {
  23. let $this = new Date(thistime)
  24. let o = {
  25. 'M+': $this.getMonth() + 1,
  26. 'd+': $this.getDate(),
  27. 'h+': $this.getHours(),
  28. 'm+': $this.getMinutes(),
  29. 's+': $this.getSeconds(),
  30. 'q+': Math.floor(($this.getMonth() + 3) / 3),
  31. 'S': $this.getMilliseconds()
  32. }
  33. if (/(y+)/.test(fmt)) {
  34. fmt = fmt.replace(RegExp.$1, ($this.getFullYear() + '').substr(4 - RegExp.$1.length))
  35. }
  36. for (var k in o) {
  37. if (new RegExp('(' + k + ')').test(fmt)) {
  38. fmt = fmt.replace(RegExp.$1, (RegExp.$1.length === 1) ? (o[k]) : (('00' + o[k]).substr(('' + o[k]).length)))
  39. }
  40. }
  41. return fmt
  42. }
  43. const app = new Vue({
  44. ...App
  45. })
  46. app.$mount()