123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596 |
- // #ifndef VUE3
- import Vue from 'vue'
- import App from './App'
- //导入网络请求包
- import {$http} from '@escook/request-miniprogram'
- //5.导入store的自定义模块
- import store from '@/store/store.js'
- //导入uView组件库
- import uView from '@/uni_modules/uview-ui'
- //导入公共方法
- import Common from './utils/Common.js'
- import APIHandler from './utils/APIHandler.js'
- //挂载公共方法实例
- Vue.prototype.$getRecentDateArray = Common.getRecentDateArray;
- Vue.prototype.$timestampToTime = Common.timestampToTime;
- //API数据获取与处理
- Vue.prototype.$initGrade = APIHandler.initGrade;
- Vue.prototype.$initHomework = APIHandler.initHomework;
- Vue.prototype.$initHome = APIHandler.initHome;
- Vue.prototype.$initApp = APIHandler.initApp;
- //格式化处理日期时间的方法
- Date.prototype.format = function(fmt) {
- let o = {
- "M+": this.getMonth() + 1, //月份
- "d+": this.getDate(), //日
- "h+": this.getHours(), //小时
- "m+": this.getMinutes(), //分
- "s+": this.getSeconds(), //秒
- "q+": Math.floor((this.getMonth() + 3) / 3), //季度
- "S": this.getMilliseconds() //毫秒
- };
- if (/(y+)/.test(fmt)) fmt = fmt.replace(RegExp.$1, (this.getFullYear() + "").substr(4 - RegExp.$1.length));
- for (let k in o)
- if (new RegExp("(" + k + ")").test(fmt)) fmt = fmt.replace(RegExp.$1, (RegExp.$1.length == 1) ? (o[k]) :
- (("00" + o[k]).substr(("" + o[k]).length)));
- return fmt;
- }
- //挂载到uni.$http上方便调用
- uni.$http = $http
- //请求根路径
- // $http.baseUrl = 'https://www.uinav.com'
- //挂载请求拦截器
- $http.beforeRequest = function(options) {
- uni.showLoading({
- title: '数据加载中...'
- })
- //挂载请求头
- //判断当前请求的是否为有权限的接口
- // if(options.url.indexOf('/pages/login/login') !== -1){
- //为header中添加必要信息(权限字段)
- // options.header = {
- // }
- //}
- }
- //挂载响应拦截器
- $http.afterRequest = function() {
- uni.hideLoading()
- }
- //封装的展示消息提示方法
- uni.$showMsg = function(title = '请求失败', duration = 1500) {
- uni.showToast({
- title,
- duration,
- icon: 'none'
- })
- }
- Vue.config.productionTip = false
- App.mpType = 'app'
- //app实例对象
- const app = new Vue({
- ...App,
- //6.挂载到app实例对象里
- store
- })
- app.$mount()
- // #endif
- // #ifdef VUE3
- import {
- createSSRApp
- } from 'vue'
- import App from './App.vue'
- export function createApp() {
- const app = createSSRApp(App)
- return {
- app
- }
- }
- // #endif
|