xiaota-global-index

// 表格全局组件
import tableComponent from '@/common/base/tableComponent'
// 输入框全局组件
import searchComponent from '@/common/base/searchComponent'
// 子组件头部全局组件
import childHeadComponent from '@/common/base/childHeadComponent'
// index新增全局组件
import indexAddComponent from '@/common/base/indexAddComponent'
// 分页全局组件
import paginationComponent from '@/common/base/paginationComponent'
// 表单
import formComponent from '@/common/base/formComponent'
// selectArr
import selectArr from '@/common/js/selectArr.js'
const global = {
  install: function (Vue) {
    var base = window.location.origin
    Vue.prototype.baseUrlSale = base + '/service/sale-service'
    Vue.prototype.baseUrlClass = base + '/service/class-service'
    Vue.prototype.baseUrlTeacher = base + '/service/teacher-service'
    Vue.prototype.baseUrlStaff = base + '/service/staff-service'
    Vue.prototype.baseUrlStudent = base + '/service/student-service'
    Vue.prototype.baseUrlShop = base + '/service/shop-service'
    Vue.prototype.baseUrlPay = base + '/service/pay-service'
    Vue.prototype.baseUrlCourse = base + '/service/course-service'
    Vue.prototype.baseUrlOperation = base + '/service/operation-service'
    Vue.prototype.baseUrlUpload = base + '/service/file-service'
    // 本地调试使用
    if (process.env.NODE_ENV === 'development') {
      let baseurl = 'https://test.kidsmos.com/service'
      Vue.prototype.baseUrlSale = baseurl + '/sale-service'
      Vue.prototype.baseUrlClass = baseurl + '/class-service'
      Vue.prototype.baseUrlTeacher = baseurl + '/teacher-service'
      Vue.prototype.baseUrlStaff = baseurl + '/staff-service'
      Vue.prototype.baseUrlStudent = baseurl + '/student-service'
      Vue.prototype.baseUrlShop = baseurl + '/shop-service'
      Vue.prototype.baseUrlPay = baseurl + '/pay-service'
      Vue.prototype.baseUrlCourse = baseurl + '/course-service'
      Vue.prototype.baseUrlOperation = baseurl + '/operation-service'
      Vue.prototype.baseUrlUpload = baseurl + '/file-service'
    }
    // 全局组件
    Vue.component('tableComponent', tableComponent)
    Vue.component('searchComponent', searchComponent)
    Vue.component('childHeadComponent', childHeadComponent)
    Vue.component('indexAddComponent', indexAddComponent)
    Vue.component('paginationComponent', paginationComponent)
    Vue.component('formComponent', formComponent)
    // selectArr
    Vue.prototype.selectArr = selectArr
    // 提出cookie
    Vue.prototype.getCookieItem = (key) => {
      var arr = document.cookie.split('; ')
      for (var i = 0; i < arr.length; i++) {
        var res = arr[i].split('=')
        if (res[0] == key) {
          if (res.length == 3) {
            return res[1] + '='
          } else {
            return res[1]
          }
        }
      }
    }
    // 设置cookie
    Vue.prototype.setCookie = (name, value, day) => {
      var date = new Date()
      date.setDate(date.getDate() + day)
      document.cookie = name + '=' + value + ';expires=' + date
    }
    // 手机字符串截取
    Vue.prototype.clintTel = (tel) => {
      const [star, end] = [tel.substr(0, 3), tel.substr(-4)]
      return `${star}****${end}`
    },
    //
    Vue.prototype.statusChange = {
      1: '待支付',
      2: '已支付',
      3: '已取消',
      4: '配货中',
      5: '已发货',
      6: '已收货',
      7: '已退货'
    }
    // 分钟格式转换
    Vue.prototype.getMinute = (time) => {
      var h = Math.floor(time / 60)
      var m = time % 60
      m = m < 10 ? '0' + m : m
      return `${h}:${m}`
    }
    // 星期转化
    Vue.prototype.weeks = {
      1: '一',
      2: '二',
      3: '三',
      4: '四',
      5: '五',
      6: '六',
      7: '日'
    }
    // 班级类型
    Vue.prototype.classType = {
      1: '主线课',
      2: '试听课',
      3: '补课班'
    }
    // 班级状态
    Vue.prototype.classStatus = {
      0: '已失效',
      1: '正常'
    }
    // 是否停课
    Vue.prototype.isStops = {
      0: '否',
      1: '是'
    }
    // 班级状态
    Vue.prototype.scheduleStatus = {
      0: '待上课',
      1: '上课中',
      2: '已下课'
    }
    // 时间转分钟
    Vue.prototype.timeTamp = (time) => {
      var h = Number(time.split(':')[0])
      var m = Number(time.split(':')[1])
      return h * 60 + m
    }
    // 课程状态
    Vue.prototype.courseStatus = {
      0: '无效',
      1: '进行中',
      2: '结课',
      3: '退课',
      4: '课时转出'
    }
    // 购课方式
    Vue.prototype.purchasingType = {
      0: '正常购课',
      1: '补费换课',
      2: '0元换课'
    }
    // 是否停课
    Vue.prototype.deleteStatus = {
      0: '有效',
      1: '已取消'
    }
    // 性质
    Vue.prototype.isNew = {
      0: '新签',
      1: '续签',
      2: '活动'
    }
    // 出勤
    Vue.prototype.attendance = {
      1: '缺勤',
      2: '出勤'
    }
    // 性别
    Vue.prototype.sex = {
      '0': '女',
      '1': '男',
      '-1': '未知'
    }
    // 退费状态
    Vue.prototype.refundStatus = {
      1: '同意退费',
      2: '待处理(管理层)',
      3: '待处理(财务)',
      4: '已退费',
      5: '已拒绝(管理层)'
    }
    // 审批状态
    Vue.prototype.auditStatus = {
      1: '待审批',
      2: '已通过',
      3: '已拒绝',
      4: '已撤回'
    }
    // 试听情况
    Vue.prototype.auditStatus2 = {
      0: '未试听',
      1: '已试听'
    }
    // 课时包类型
    Vue.prototype.lessonPackageType = {
      1: '常规课时包',
      2: '活动课时包'
    }
    // 付费情况
    Vue.prototype.isPaid = {
      0: '未付费',
      1: '已付费'
    }
    // 赠送课时类型
    Vue.prototype.giftType = {
      1: '推荐人在被推荐人首次试听完成赠送',
      2: '推荐人在被推荐人首次购课赠送',
      3: '被推荐人首次购课赠送',
      4: '班主任赠课申请赠送'
    }
    // 记录类型
    Vue.prototype.recordType = {
      1: '-',
      2: '+'
    }
    // 跟进类型
    Vue.prototype.followUpType = {
      1: '普通',
      2: '课前跟进',
      3: '课后跟进',
      4: '试听课约课'
    }
  }
}
export default global
原文地址:https://www.cnblogs.com/xiaoxiao95/p/12726544.html