main.js 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  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.prototype.$imghost = 'http://static.yfpyx.com/projectimg' // 线上图片服务器路径常量
  10. Vue.filter('timeFormat',function(time){
  11. function fun(a){
  12. return String(a).length==1?'0'+a: a
  13. }
  14. let date= new Date(time*1000)
  15. let y=date.getFullYear()
  16. let m=date.getMonth()+1
  17. let d=date.getDate()
  18. let h=date.getHours()
  19. let min=date.getMinutes()
  20. let sec=date.getSeconds()
  21. return `${y}-${fun(m)}-${fun(d)} ${fun(h)}:${fun(min)}:${fun(sec)}`
  22. })
  23. Vue.prototype.formatTime = function (thistime,fmt = 'yyyy-MM-dd hh:mm:ss') {
  24. let $this = new Date(thistime)
  25. let o = {
  26. 'M+': $this.getMonth() + 1,
  27. 'd+': $this.getDate(),
  28. 'h+': $this.getHours(),
  29. 'm+': $this.getMinutes(),
  30. 's+': $this.getSeconds(),
  31. 'q+': Math.floor(($this.getMonth() + 3) / 3),
  32. 'S': $this.getMilliseconds()
  33. }
  34. if (/(y+)/.test(fmt)) {
  35. fmt = fmt.replace(RegExp.$1, ($this.getFullYear() + '').substr(4 - RegExp.$1.length))
  36. }
  37. for (var k in o) {
  38. if (new RegExp('(' + k + ')').test(fmt)) {
  39. fmt = fmt.replace(RegExp.$1, (RegExp.$1.length === 1) ? (o[k]) : (('00' + o[k]).substr(('' + o[k]).length)))
  40. }
  41. }
  42. return fmt
  43. }
  44. const app = new Vue({
  45. ...App
  46. })
  47. app.$mount()