| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207 |
- import Vue from 'vue'
- import App from './App'
- import store from '@/store';
- //引入uview组件库
- import uView from 'uview-ui';
- Vue.use(uView);
- //mescroll刷新组件
- import MescrollBody from "@/components/mescroll-body/mescroll-body.vue"
- Vue.component('mescroll-body', MescrollBody)
- //vuex
- let vuexStore = require("@/store/$u.mixin.js");
- Vue.mixin(vuexStore);
- //引入路由拦截
- // import {router,RouterMount} from './router.js'
- // Vue.use(router)
- //封装api
- import { api } from 'assets/http/api.js'
- Vue.prototype.$api = api
- //封装缓存
- import simpleCache from "@/utils/cache.js"
- Vue.prototype.$cache = simpleCache
- //封装日期时间工具类
- import dateTime from 'utils/dateTime.js'
- Vue.prototype.$dateTime = dateTime
- //封装提示工具
- import dialog from 'utils/dialog.js'
- Vue.prototype.$dialog = dialog
- //全局变量
- import Global from './utils/global'
- Vue.prototype.$global = Global
- // 全局注入
- import Mixin from './utils/mixin'
- Vue.mixin(Mixin)
- // 微信函数封装
- import Mpi from './utils/mpi'
- Vue.prototype.$mpi = Mpi
- //引入工具类
- import util from 'utils/util.js'
- Vue.prototype.$util = util
- //校验文件
- import verify from 'utils/verify.js'
- Vue.prototype.$verify = verify
- //登陆类型
- Vue.prototype.$loginType={
- STAFF:'staff',
- ENTERPRISE:'enterprise',
- AGENCY:'agency'
- }
- Vue.prototype.ColorList=['red','orange','yellow','olive','green','cyan','blue','purple','mauve', 'pink','brown']
- //设备类型【通过前缀查找】
- Vue.prototype.$device_prefix={
- SMOKE:'ctwing/smoke3',//烟感
- GAS:'ctwing/gasmonitoring',//气感,燃气监控
- }
- //设备类型【通过设备类型查找】
- Vue.prototype.$device_type={
- FIRE_HYDRANT:'960417', //消防栓
- ELECTRIC_METER:'100030'//电表
- }
- //员工消息模板
- Vue.prototype.$staffTmplIds=[
- //审核结果通知。可用于员工认证审核和访客申请审核
- 'QeE-CxbJGd05fo0lGkVa33OLqYulzy0WLnUZg3DeRM8'
- ]
- //管理员消息模板
- Vue.prototype.$adminTmplIds=[
- //设备告警通知
- 'xfsqjKLVz_P8dBIpdP91uGx709hE7b3k99gqm3wUwMU',
- //访客申请开门通知
- '3nd5TxKeVg9iZ5uQRi0R16D8RhCPQifUcfVUOo1ER1Y',
- //员工认证通知
- 'enS3r9XGVNq0go-7l3dU17MONZwEVISqMvDLPmKcxFc'
- ]
- //小程序版本
- Vue.prototype.$miniprogramState='formal'
- // Vue.prototype.$miniprogramState='trial'
- //封装提示框
- 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.$navigateBack=(delta=1)=>{
- uni.navigateBack({
- delta
- })
- }
- //是否认证登陆
- 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({
- store,
- ...App
- })
- //v1.3.5起 H5端 你应该去除原有的app.$mount();使用路由自带的渲染方式
- // #ifdef H5
- RouterMount(app,router,'#app')
- // #endif
- // #ifndef H5
- app.$mount(); //为了兼容小程序及app端必须这样写才有效果
- // #endif
|