main.js 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207
  1. import Vue from 'vue'
  2. import App from './App'
  3. import store from '@/store';
  4. //引入uview组件库
  5. import uView from 'uview-ui';
  6. Vue.use(uView);
  7. //mescroll刷新组件
  8. import MescrollBody from "@/components/mescroll-body/mescroll-body.vue"
  9. Vue.component('mescroll-body', MescrollBody)
  10. //vuex
  11. let vuexStore = require("@/store/$u.mixin.js");
  12. Vue.mixin(vuexStore);
  13. //引入路由拦截
  14. // import {router,RouterMount} from './router.js'
  15. // Vue.use(router)
  16. //封装api
  17. import { api } from 'assets/http/api.js'
  18. Vue.prototype.$api = api
  19. //封装缓存
  20. import simpleCache from "@/utils/cache.js"
  21. Vue.prototype.$cache = simpleCache
  22. //封装日期时间工具类
  23. import dateTime from 'utils/dateTime.js'
  24. Vue.prototype.$dateTime = dateTime
  25. //封装提示工具
  26. import dialog from 'utils/dialog.js'
  27. Vue.prototype.$dialog = dialog
  28. //全局变量
  29. import Global from './utils/global'
  30. Vue.prototype.$global = Global
  31. // 全局注入
  32. import Mixin from './utils/mixin'
  33. Vue.mixin(Mixin)
  34. // 微信函数封装
  35. import Mpi from './utils/mpi'
  36. Vue.prototype.$mpi = Mpi
  37. //引入工具类
  38. import util from 'utils/util.js'
  39. Vue.prototype.$util = util
  40. //校验文件
  41. import verify from 'utils/verify.js'
  42. Vue.prototype.$verify = verify
  43. //登陆类型
  44. Vue.prototype.$loginType={
  45. STAFF:'staff',
  46. ENTERPRISE:'enterprise',
  47. AGENCY:'agency'
  48. }
  49. Vue.prototype.ColorList=['red','orange','yellow','olive','green','cyan','blue','purple','mauve', 'pink','brown']
  50. //设备类型【通过前缀查找】
  51. Vue.prototype.$device_prefix={
  52. SMOKE:'ctwing/smoke3',//烟感
  53. GAS:'ctwing/gasmonitoring',//气感,燃气监控
  54. }
  55. //设备类型【通过设备类型查找】
  56. Vue.prototype.$device_type={
  57. FIRE_HYDRANT:'960417', //消防栓
  58. ELECTRIC_METER:'100030'//电表
  59. }
  60. //员工消息模板
  61. Vue.prototype.$staffTmplIds=[
  62. //审核结果通知。可用于员工认证审核和访客申请审核
  63. 'QeE-CxbJGd05fo0lGkVa33OLqYulzy0WLnUZg3DeRM8'
  64. ]
  65. //管理员消息模板
  66. Vue.prototype.$adminTmplIds=[
  67. //设备告警通知
  68. 'xfsqjKLVz_P8dBIpdP91uGx709hE7b3k99gqm3wUwMU',
  69. //访客申请开门通知
  70. '3nd5TxKeVg9iZ5uQRi0R16D8RhCPQifUcfVUOo1ER1Y',
  71. //员工认证通知
  72. 'enS3r9XGVNq0go-7l3dU17MONZwEVISqMvDLPmKcxFc'
  73. ]
  74. //小程序版本
  75. Vue.prototype.$miniprogramState='formal'
  76. // Vue.prototype.$miniprogramState='trial'
  77. //封装提示框
  78. Vue.prototype.$showModel = (content,isShowCancel=true,title='提示',)=>{
  79. return new Promise((resolve,reject)=>{
  80. uni.showModal({
  81. title: title,
  82. content: content,
  83. showCancel:isShowCancel,
  84. success: (res)=>{
  85. if (res.confirm) {
  86. resolve(res)
  87. }
  88. }
  89. });
  90. })
  91. }
  92. //封装提示框
  93. Vue.prototype.$showToast=function(title,type,position){
  94. this.$refs.uToast.show({
  95. title: title,
  96. position:position||'top',
  97. type: type ||'success'
  98. })
  99. }
  100. Vue.prototype.$navigateBack=(delta=1)=>{
  101. uni.navigateBack({
  102. delta
  103. })
  104. }
  105. //是否认证登陆
  106. Vue.prototype.$isAuth=()=>{
  107. return simpleCache.get('loginType')
  108. }
  109. //创建时间
  110. Vue.prototype.$createDateTime=()=>{
  111. var mydate = new Date();
  112. var str = "" + mydate.getFullYear() + "-";
  113. //判断小于是是直接小于10月就可以了
  114. if(mydate.getMonth()<10){
  115. str +="0"+ (mydate.getMonth() + 1) + "-";
  116. }else{
  117. str += (mydate.getMonth() + 1) + "-";
  118. }
  119. //判断小于是是直接小于10日就可以了
  120. if(mydate.getDate()<10){
  121. str += "0"+mydate.getDate() + " ";
  122. }else{
  123. str += mydate.getDate() + " ";
  124. }
  125. if(mydate.getHours()<10){
  126. str += "0"+mydate.getHours() + ":";
  127. }else{
  128. str += mydate.getHours() + ":";
  129. }
  130. if(mydate.getMinutes()<10){
  131. str += "0"+mydate.getMinutes() + ":";
  132. }else{
  133. str += mydate.getMinutes() + ":";
  134. }
  135. if(mydate.getSeconds()<10){
  136. str += "0"+mydate.getSeconds();
  137. }else{
  138. str += mydate.getSeconds();
  139. }
  140. return str;
  141. }
  142. //封装判空函数
  143. Vue.prototype.$isEmpty=function(value){
  144. switch (typeof value) {
  145. case 'undefined':
  146. return true;
  147. case 'string':
  148. if(value=='undefined') return true
  149. if (value.replace(/(^[ \t\n\r]*)|([ \t\n\r]*$)/g, '').length == 0) return true;
  150. break;
  151. case 'boolean':
  152. if (!value) return true;
  153. break;
  154. case 'number':
  155. if (0 === value || isNaN(value)) return true;
  156. break;
  157. case 'object':
  158. if (null === value || value.length === 0) return true;
  159. for (var i in value) {
  160. return false;
  161. }
  162. return true;
  163. }
  164. return false;
  165. }
  166. Vue.config.productionTip = false
  167. App.mpType = 'app'
  168. const app = new Vue({
  169. store,
  170. ...App
  171. })
  172. //v1.3.5起 H5端 你应该去除原有的app.$mount();使用路由自带的渲染方式
  173. // #ifdef H5
  174. RouterMount(app,router,'#app')
  175. // #endif
  176. // #ifndef H5
  177. app.$mount(); //为了兼容小程序及app端必须这样写才有效果
  178. // #endif