main.js 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. import Vue from 'vue'
  2. import App from './App'
  3. // #ifdef H5
  4. import wx from 'weixin-jsapi'
  5. import './mixins/mixin'
  6. console.info('v2.4.51');
  7. Vue.prototype.wx = wx //声明扫码
  8. Vue.prototype.audios = [] //待播放的语音集合
  9. // #endif
  10. // #ifdef APP-PLUS
  11. Vue.prototype.$ws = null//websocket
  12. // #endif
  13. Vue.config.productionTip = false
  14. Date.prototype.Format = function (fmt) {
  15. var o = {
  16. "M+": this.getMonth() + 1, //月份
  17. "d+": this.getDate(), //日
  18. "h+": this.getHours(), //小时
  19. "m+": this.getMinutes(), //分
  20. "s+": this.getSeconds(), //秒
  21. "q+": Math.floor((this.getMonth() + 3) / 3), //季度
  22. S: this.getMilliseconds(), //毫秒
  23. };
  24. if (/(y+)/.test(fmt))
  25. fmt = fmt.replace(
  26. RegExp.$1,
  27. (this.getFullYear() + "").substr(4 - RegExp.$1.length)
  28. );
  29. for (var k in o)
  30. if (new RegExp("(" + k + ")").test(fmt))
  31. fmt = fmt.replace(
  32. RegExp.$1,
  33. RegExp.$1.length == 1
  34. ? o[k]
  35. : ("00" + o[k]).substr(("" + o[k]).length)
  36. );
  37. return fmt;
  38. };
  39. // 日期过滤器
  40. Vue.filter('formatDate', function(timestamp, format){
  41. console.log(timestamp, format);
  42. if(timestamp){
  43. return new Date(timestamp).Format(format);
  44. }else{
  45. return '';
  46. }
  47. })
  48. // 日期过滤器(去掉秒)
  49. Vue.filter('filterSecondDate', function(dateStr){
  50. if(dateStr && dateStr.length === 19){
  51. return dateStr.slice(0, -3);
  52. }else{
  53. return dateStr;
  54. }
  55. })
  56. // 多个名称显示
  57. Vue.filter('filterNames', function(arr, fieldName){
  58. if(Array.isArray((arr))){
  59. return arr.map(v => v[fieldName]).toString();
  60. }else{
  61. return '';
  62. }
  63. })
  64. App.mpType = 'app'
  65. const app = new Vue({
  66. ...App
  67. })
  68. app.$mount()