main.js 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143
  1. import Vue from 'vue'
  2. import App from './App'
  3. //引入uview组件库
  4. import uView from 'uview-ui';
  5. Vue.use(uView);
  6. import MescrollBody from "@/components/mescroll-body/mescroll-body.vue"
  7. Vue.component('mescroll-body', MescrollBody)
  8. //引入路由拦截
  9. import {router,RouterMount} from './router.js' //路径换成自己的
  10. Vue.use(router)
  11. //封装api
  12. import { api } from 'assets/http/api.js'
  13. Vue.prototype.$api = api
  14. //引入util.js
  15. import Util from 'utils/util.js'
  16. Vue.prototype.$util = Util
  17. //封装缓存
  18. import simpleCache from "@/utils/cache.js"
  19. Vue.prototype.$cache = simpleCache
  20. //登陆类型
  21. Vue.prototype.$loginType={
  22. STAFF:'staff',
  23. ENTERPRISE:'enterprise'
  24. }
  25. //设备类型【通过前缀查找】
  26. Vue.prototype.$device_prefix={
  27. SMOKE:'ctwing/smoke3',//烟感
  28. GAS:'ctwing/gasmonitoring',//气感,燃气监控
  29. }
  30. //设备类型【通过设备类型查找】
  31. Vue.prototype.$device_type={
  32. FIRE_HYDRANT:'960417', //消防栓
  33. }
  34. //订阅消息模板
  35. Vue.prototype.$tmplIds=['veqKChqdSGXaidd4h4OOzTv6nm-qVwwT__Pz0ghRyFY']
  36. //小程序版本
  37. Vue.prototype.$miniprogramState={
  38. DEVELOPER:'developer', //开发版
  39. TRIAL:'trial', //体验版
  40. FORMAL:'formal',//正式版
  41. }
  42. //封装提示框
  43. Vue.prototype.$showModel = (content,isShowCancel=true,title='提示',)=>{
  44. return new Promise((resolve,reject)=>{
  45. uni.showModal({
  46. title: title,
  47. content: content,
  48. showCancel:isShowCancel,
  49. success: (res)=>{
  50. if (res.confirm) {
  51. resolve(res)
  52. }
  53. }
  54. });
  55. })
  56. }
  57. //是否认证登陆
  58. Vue.prototype.$isAuth=()=>{
  59. return simpleCache.get('loginType')
  60. }
  61. //创建时间
  62. Vue.prototype.$createDateTime=()=>{
  63. var mydate = new Date();
  64. var str = "" + mydate.getFullYear() + "-";
  65. //判断小于是是直接小于10月就可以了
  66. if(mydate.getMonth()<10){
  67. str +="0"+ (mydate.getMonth() + 1) + "-";
  68. }else{
  69. str += (mydate.getMonth() + 1) + "-";
  70. }
  71. //判断小于是是直接小于10日就可以了
  72. if(mydate.getDate()<10){
  73. str += "0"+mydate.getDate() + " ";
  74. }else{
  75. str += mydate.getDate() + " ";
  76. }
  77. if(mydate.getHours()<10){
  78. str += "0"+mydate.getHours() + ":";
  79. }else{
  80. str += mydate.getHours() + ":";
  81. }
  82. if(mydate.getMinutes()<10){
  83. str += "0"+mydate.getMinutes() + ":";
  84. }else{
  85. str += mydate.getMinutes() + ":";
  86. }
  87. if(mydate.getSeconds()<10){
  88. str += "0"+mydate.getSeconds();
  89. }else{
  90. str += mydate.getSeconds();
  91. }
  92. return str;
  93. }
  94. //封装判空函数
  95. Vue.prototype.$isEmpty=function(value){
  96. switch (typeof value) {
  97. case 'undefined':
  98. return true;
  99. case 'string':
  100. if(value=='undefined') return true
  101. if (value.replace(/(^[ \t\n\r]*)|([ \t\n\r]*$)/g, '').length == 0) return true;
  102. break;
  103. case 'boolean':
  104. if (!value) return true;
  105. break;
  106. case 'number':
  107. if (0 === value || isNaN(value)) return true;
  108. break;
  109. case 'object':
  110. if (null === value || value.length === 0) return true;
  111. for (var i in value) {
  112. return false;
  113. }
  114. return true;
  115. }
  116. return false;
  117. }
  118. Vue.config.productionTip = false
  119. App.mpType = 'app'
  120. const app = new Vue({
  121. ...App
  122. })
  123. //v1.3.5起 H5端 你应该去除原有的app.$mount();使用路由自带的渲染方式
  124. // #ifdef H5
  125. RouterMount(app,router,'#app')
  126. // #endif
  127. // #ifndef H5
  128. app.$mount(); //为了兼容小程序及app端必须这样写才有效果
  129. // #endif