12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091 |
- // #ifndef VUE3
- import Vue from 'vue'
- import App from './App'
- //导入网络请求包
- import {$http} from '@escook/request-miniprogram'
- //5.导入store的自定义模块
- import store from '@/information/store.js'
- //导入uView组件库
- import uView from '@/uni_modules/uview-ui'
- //导入公共方法
- import RepeatClick from './utils/RepeatClick.js'
- import TimeUtils from './utils/TimeUtils.js'
- Vue.prototype.$noMultipleClicks = RepeatClick.noMultipleClicks;
- Vue.prototype.$getTimeStamp = TimeUtils.getTimeStamp;
- Vue.prototype.$getRecentDateArray = TimeUtils.getRecentDateArray;
- //挂载到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'
- })
- }
- //封装格式化处理日期时间的方法
- 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;
- }
- 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
|