Blame view

main.js 2.29 KB
4b045f7c   刘淇   江阴初始化项目
1
2
  import App from './App'
  import store from './store'
e133a83d   chenbiao   add 接口文档更新
3
  // 引入封装的接口api
93c5ecb3   chenbiao   add 添加filter.js 设...
4
  import common from "./common/common.js";
e133a83d   chenbiao   add 接口文档更新
5
  import { myRequest } from './common/requestServer.js'
93c5ecb3   chenbiao   add 添加filter.js 设...
6
  //引入封装的过滤器 filters
3b7af3a2   chenbiao   add 我的钱包 接口联调
7
  import filters from './common/filters.js'
e133a83d   chenbiao   add 接口文档更新
8
  // 挂在Vue属性 全局通过this.$myRequest()可以访问到
dd5ecdbd   chenbiao   add 接口文档更新
9
  Vue.prototype.$common = common
e133a83d   chenbiao   add 接口文档更新
10
  Vue.prototype.$myRequest = myRequest
4b045f7c   刘淇   江阴初始化项目
11
  
93c5ecb3   chenbiao   add 添加filter.js 设...
12
13
14
15
16
  // 添加全局filter
  Object.keys(filters).map(v => {
      Vue.filter(v, filters[v])
  })
  
4b045f7c   刘淇   江阴初始化项目
17
18
19
20
21
22
23
24
25
26
  // #ifndef VUE3
  import Vue from 'vue'
  Vue.config.productionTip = false
  Vue.prototype.$store = store
  Vue.prototype.$adpid = "1111111111"
  Vue.prototype.$backgroundAudioData = {
  	playing: false,
  	playTime: 0,
  	formatedPlayTime: '00:00:00'
  }
19569f2b   刘淇   购买券
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
  
  Vue.filter('priceFormat', function(value, arg) {
    return (value / 100).toFixed(2)
  })
  
  Vue.filter('timeFormat', function(value, arg) {
  
    var time = '';
    if (null != value && "" != value) {
      var timer = parseInt(value);
      if (timer == 0) {
        return '0秒';
      }
      var days = parseInt(timer / (60 * 60 * 24));
      var hours = parseInt((timer % (60 * 60 * 24)) / (60 * 60));
      var minutes = parseInt((timer % (60 * 60)) / (60))
      var seconds = parseInt(timer % (60));
      if (days > 0) {
        time = time + days +'天';
      }
      if (hours > 0) {
        time = time + hours +'小时';
      }
      if (minutes > 0) {
        time = time + minutes +'分钟';
      }
      if (seconds > 0) {
        time = time + seconds +'秒';
      }
      return time;
    }
    return time;
  
  })
  
  Vue.prototype.getGlobalUser = function(key) {
    var userInfo = uni.getStorageSync("globalUser");
    if (userInfo != null && userInfo != "" && userInfo != undefined) {
      return userInfo;
    } else {
      return null;
    }
  }
  
  Vue.prototype.getWxOpenid= function(key) {
    var WxOpenid = uni.getStorageSync("WxOpenid");
    if (WxOpenid != null && WxOpenid != "" && WxOpenid != undefined) {
      return WxOpenid;
    } else {
      return "";
    }
  }
  
  
4b045f7c   刘淇   江阴初始化项目
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
  App.mpType = 'app'
  const app = new Vue({
  	store,
  	...App
  })
  app.$mount()
  // #endif
  
  // #ifdef VUE3
  import {
  	createSSRApp
  } from 'vue'
  export function createApp() {
  	const app = createSSRApp(App)
  	app.use(store)
  	app.config.globalProperties.$adpid = "1111111111"
  	app.config.globalProperties.$backgroundAudioData = {
  		playing: false,
  		playTime: 0,
  		formatedPlayTime: '00:00:00'
  	}
  	return {
  		app
  	}
  }
  // #endif