| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153 |
- import Vue from 'vue'
- import App from './App'
- //引入uview组件库
- import uView from 'uview-ui';
- Vue.use(uView);
- import MescrollBody from "@/components/mescroll-body/mescroll-body.vue"
- Vue.component('mescroll-body', MescrollBody)
- //引入路由拦截
- import {router,RouterMount} from './router.js' //路径换成自己的
- Vue.use(router)
- //封装api
- import { api } from 'assets/http/api.js'
- Vue.prototype.$api = api
- //引入util.js
- import Util from 'utils/util.js'
- Vue.prototype.$util = Util
- //封装缓存
- import simpleCache from "@/utils/cache.js"
- Vue.prototype.$cache = simpleCache
- //登陆类型
- Vue.prototype.$loginType={
- STAFF:'staff',
- ENTERPRISE:'enterprise',
- AGENCY:'agency'
- }
- //设备类型【通过前缀查找】
- Vue.prototype.$device_prefix={
- SMOKE:'ctwing/smoke3',//烟感
- GAS:'ctwing/gasmonitoring',//气感,燃气监控
- }
- //设备类型【通过设备类型查找】
- Vue.prototype.$device_type={
- FIRE_HYDRANT:'960417', //消防栓
- }
- //订阅消息模板
- Vue.prototype.$tmplIds=['QeE-CxbJGd05fo0lGkVa39wj3L5rKeXZclFsyC4am00']
- //小程序版本
- Vue.prototype.$miniprogramState={
- DEVELOPER:'developer', //开发版
- TRIAL:'trial', //体验版
- FORMAL:'formal',//正式版
- }
- //封装提示框
- Vue.prototype.$showModel = (content,isShowCancel=true,title='提示',)=>{
- return new Promise((resolve,reject)=>{
- uni.showModal({
- title: title,
- content: content,
- showCancel:isShowCancel,
- success: (res)=>{
- if (res.confirm) {
- resolve(res)
- }
- }
- });
- })
- }
- //封装提示框
- Vue.prototype.$showToast=function(title,type,position){
- this.$refs.uToast.show({
- title: title,
- position:position||'top',
- type: type ||'success'
- })
- }
- //是否认证登陆
- Vue.prototype.$isAuth=()=>{
- return simpleCache.get('loginType')
- }
- //创建时间
- Vue.prototype.$createDateTime=()=>{
- var mydate = new Date();
- var str = "" + mydate.getFullYear() + "-";
- //判断小于是是直接小于10月就可以了
- if(mydate.getMonth()<10){
- str +="0"+ (mydate.getMonth() + 1) + "-";
- }else{
- str += (mydate.getMonth() + 1) + "-";
- }
- //判断小于是是直接小于10日就可以了
- if(mydate.getDate()<10){
- str += "0"+mydate.getDate() + " ";
- }else{
- str += mydate.getDate() + " ";
- }
- if(mydate.getHours()<10){
- str += "0"+mydate.getHours() + ":";
- }else{
- str += mydate.getHours() + ":";
- }
- if(mydate.getMinutes()<10){
- str += "0"+mydate.getMinutes() + ":";
- }else{
- str += mydate.getMinutes() + ":";
- }
- if(mydate.getSeconds()<10){
- str += "0"+mydate.getSeconds();
- }else{
- str += mydate.getSeconds();
- }
- return str;
- }
- //封装判空函数
- Vue.prototype.$isEmpty=function(value){
- switch (typeof value) {
- case 'undefined':
- return true;
- case 'string':
- if(value=='undefined') return true
- if (value.replace(/(^[ \t\n\r]*)|([ \t\n\r]*$)/g, '').length == 0) return true;
- break;
- case 'boolean':
- if (!value) return true;
- break;
- case 'number':
- if (0 === value || isNaN(value)) return true;
- break;
- case 'object':
- if (null === value || value.length === 0) return true;
- for (var i in value) {
- return false;
- }
- return true;
- }
- return false;
- }
- Vue.config.productionTip = false
- App.mpType = 'app'
- const app = new Vue({
- ...App
- })
- //v1.3.5起 H5端 你应该去除原有的app.$mount();使用路由自带的渲染方式
- // #ifdef H5
- RouterMount(app,router,'#app')
- // #endif
- // #ifndef H5
- app.$mount(); //为了兼容小程序及app端必须这样写才有效果
- // #endif
|