main.js 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  1. import Vue from 'vue'
  2. import App from './App'
  3. //接口请求方式一
  4. import api from '@/common/api'
  5. Vue.prototype.$api = api
  6. // 接口请求方式二 (url,method,data(请求参数),noToken, noLoading)
  7. import { myRequest } from '@/common/request.js'
  8. Vue.prototype.$http = myRequest
  9. import store from './store'
  10. Vue.prototype.$store = store
  11. //提示框
  12. import layer from '@/common/layer'
  13. Vue.prototype.$layer = layer
  14. // 页面跳转
  15. import * as navTo from '@/common/navTo'
  16. Vue.prototype.$navTo = navTo
  17. // 验证登入有效等...
  18. import method from '@/common/methodTool'
  19. Vue.prototype.$method = method
  20. import filters from './filters/index.js'
  21. //import share from '@/js_sdk/share.js'
  22. //Vue.mixin(share)
  23. import uView from "uview-ui";
  24. Vue.use(uView);
  25. // 全局过滤器
  26. // Object.keys(filters).forEach((filterName) => {
  27. // console.log('filterName', filterName, Vue)
  28. // Vue.filter(filterName, filters[filterName])
  29. // })
  30. Vue.filter('formate', function(time, formate = 'yyyy-mm-dd hh:mm:ss') {
  31. var padDate = function (va) {
  32. va = va < 10 ? '0' + va : va
  33. return va
  34. }
  35. if (time) {
  36. var value = new Date(time * 1000); //时间戳为10位需*1000,时间戳为13位的话不需乘1000
  37. // var value = new Date(parseFloat(time))
  38. var year = value.getFullYear()
  39. var month = padDate(value.getMonth() + 1)
  40. var day = padDate(value.getDate())
  41. var hour = padDate(value.getHours())
  42. var minutes = padDate(value.getMinutes())
  43. var seconds = padDate(value.getSeconds())
  44. let res = ''
  45. switch (formate) {
  46. case 'mm-dd': {
  47. res = month + '-' + day
  48. break
  49. }
  50. case 'yyyy-mm-dd': {
  51. res = year + '-' + month + '-' + day
  52. break
  53. }
  54. case 'yyyy-mm': {
  55. res = year + '-' + month
  56. break
  57. }
  58. case 'mm月dd日': {
  59. res = month + '月' + day + '日'
  60. break
  61. }
  62. case 'yyyy年mm月dd日': {
  63. res = year + '年' + month + '月' + day + '日'
  64. break
  65. }
  66. case 'yyyy年mm月': {
  67. res = year + '年' + month + '月'
  68. break
  69. }
  70. case 'hh:mm': {
  71. res = hour + ':' + minutes
  72. break
  73. }
  74. case 'yyyy-mm-dd hh:mm': {
  75. res = year + '-' + month + '-' + day + ' ' + hour + ':' + minutes
  76. break
  77. }
  78. case 'yyyy.mm.dd':
  79. res = year + '.' + month + '.' + day
  80. break
  81. case 'yyyy-mm-dd hh:mm:ss':
  82. default: {
  83. res = year + '-' + month + '-' + day + ' ' + hour + ':' + minutes + ':' + seconds
  84. break
  85. }
  86. }
  87. return res
  88. }
  89. return '--'
  90. });
  91. Vue.config.productionTip = false
  92. App.mpType = 'app'
  93. const app = new Vue({
  94. ...App
  95. })
  96. app.$mount()