main.js 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  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. App.mpType = 'app'
  57. const app = new Vue({
  58. ...App
  59. })
  60. app.$mount()