示例#1
0
文件: mock.js 项目: raiyee/EasyHi
mock(/\/initialize\/get-base-data$/, ({url}) => {
  const mobile = getItem('mobile')

  let tcode = /center\/([^/]+)\/initialize/.exec(url)

  tcode = tcode && tcode[1]

  const {roles, currentRole} = mobile && PERMISSIONS.find(({mobiles}) => mobiles.includes(+mobile)) ||
  {roles: [VISITOR], currentRole: VISITOR}

  return {
    error: tcode == null || TCODES.includes(+tcode) ? '' : '未找到符合的商户,请确认 url 是否正确!',
    roles,
    currentRole,
    mobile,
    isEnterprise: Random.boolean(),
    style: Random.boolean(),
    theme: Random.pick('blue', 'green', 'purple', 'red', 'navy', Random.color()),
    merchantName: Random.ctitle(),
    merchantLogo: randomImg(),
    serviceMobile: randomMobile(),
    coachAlias: Random.pick(['教练', '老师', '教官', '导师']),
    checkIn: Random.boolean(),
    isOnlinePayment: Random.boolean(),
    sceneUrlPrefix: Random.url('http'),
    oauthUrlTemplate: Random.url()
  }
})
示例#2
0
文件: mock.js 项目: raiyee/EasyHi
mock(/\/merchant-coach\/get-coach\/\d+$/, ({url}) => {
  const coachId = pathToRegexp('/merchant-coach/get-coach/:coachId').exec(url)[1]
  return mock({
    coachId,
    coachName: '@cname',
    coachGender: '@boolean',
    coachPortrait: randomImg(60, 60),
    coachRate: '',
    userId: randomId(),
    coachMobile: randomMobile(),
    mobileVisible: '@boolean',
    coachPrize: '@cparagraph(0, 3)',
    teachingExp: '@cparagraph(0, 3)',
    coachProfile: '@cparagraph(0, 3)',
    coachSpeciality: '@cparagraph(0, 3)',
    activeCourseTypes: ['高级私教课', '私教课', '普通私教课', '中级私教课', '至尊私教课'].map((val) => {
      return val
    }),
    restTimes: randomArr(3).map(() => mock({
      restId: randomId(),
      restRange: ['@datetime', '@datetime']
    })),
    coachReviews: randomArr(3).map(() => {
      return mock({
        reviewId: randomId(),
        userId: randomId(),
        userName: '@cname',
        userGender: '@boolean',
        userPortrait: randomImg(60, 60),
        coachRate: '@float(0,4,0,2)',
        reviewContent: '@cparagraph(0, 3)',
        reviewTime: Random.date('yyyy-MM-dd'),
        reviewImgs: [randomImg(60, 60)],
        reviewReply: '@cparagraph(0, 3)',
        reviewVisible: '@boolean'
      })
    })
  })
})
示例#3
0
文件: mock.js 项目: raiyee/EasyHi
mock(/\/(cash-coupon\/detail)|(experience\/inst-detail)\/\d+/, ({url}) => {
  // 1 活动, 2 赠送
  const sourceType = Random.pick(1, 2)

  return mock({
    userName: '@cname',
    userMobile: randomMobile(),
    voucherInstId: randomId(),
    voucherName: '@ctitle',
    voucherValue: '@float(0, 100, 0, 2)',
    voucherTimes: '@natural(0, 100, 0, 2)',
    availableTimes: '@natural(0, 100, 0, 2)',
    miniConsume: url.indexOf('cash') + 1 ? '@float(0, 100, 0, 2)' : 0,
    receivedTime: '@datetime',
    usedTime: '@datetime',
    sourceContent: sourceType - 1 ? '@cname' : '@ctitle',
    sourceType,
    sourceActivityRange: sourceType - 1 ? null : ['@date', '@date'],
    voucherExpiredRange: ['@date', '@date'],
    applicableCourses: randomArr(5).map(() => Random.cword(5, 8)),
    purchasedContent: '@ctitle'
  })
})