mock demo

const Mock = require(‘mockjs’)
Mock.Random.extend({
phone: function() {
const phonePrefixs = [‘132’, ‘135’, ‘189’] // 自己写前缀哈
return this.pick(phonePrefixs) + Mock.mock(/\d{8}/) // Number()
}
})

const Action = process.env.VUE_APP_DEFAULT_MODEL + ‘Driver’

module.exports = [
{
url: ${Action}/getList,
type: ‘post’,
response: config => {
const { page } = config.body
console.log(‘page’, page)
return {
status: 1,
…Mock.mock({
‘data|10’: [{
‘id|+1’: 1,
‘name’: ‘@cname’, // 姓名
‘card_id’: ‘@id’, // 身份证号
‘mobile’: ‘@phone’, // 手机号
‘wechat’: ‘@word’, // 微信号
‘avatar’: ‘https://aijiutang.oss-cn-beijing.aliyuncs.com/static_img/default_avatar.png’, // 头像地址
‘card_front’: ‘http://img4.cache.netease.com/help/2010/2/8/20100208160221dded6.gif’, // 身份证前照
‘card_back’: ‘http://img4.cache.netease.com/help/2010/2/8/2010020816034074fe3.gif’, // 身份证后
‘driver_license’: ‘https://gimg2.baidu.com/image_search/src=http%3A%2F%2F5b0988e595225.cdn.sohucs.com%2Fimages%2F20171028%2Fe86bc98afac64b399a4d97131790965c.jpeg&refer=http%3A%2F%2F5b0988e595225.cdn.sohucs.com&app=2002&size=f9999,10000&q=a80&n=0&g=0n&fmt=jpeg?sec=1622900332&t=998223f7a7c6b979ece8b565cd9a3fcb’, // 驾驶证
‘job_license’: ‘https://photo.16pic.com/00/17/20/16pic_1720832_b.jpg’, // 上岗证
‘driver_license_id’: Mock.mock(’@id()’), // 驾驶证号
‘driver_type|1’: [‘C1’, ‘C2’, ‘A1’, ‘B1’], // 准驾车型
‘driver_issued_date’: ‘@date(“yyyy-MM-dd”)’, // 驾驶证初领日期
‘driver_validity_date’: ‘@date(“yyyy-MM-dd”)’, // 驾驶证有效期至
‘job_license_id’: Mock.mock(’@id()’), // 上岗证号
‘job_type’: ‘普货卫华’, // 从业类别
‘job_issued_date’: ‘@date(“yyyy-MM-dd”)’, // 上岗证初领日期
‘job_validity_date’: ‘@date(“yyyy-MM-dd”)’, // 上岗证有效期限
‘father_status’: ‘健康’, // 父亲现状
‘father_age|60-90’: 90, // 父亲年龄
‘mother_status’: ‘健康’, // 母亲现状
‘mother_age|60-90’: 90, // 母亲年龄
‘brother_and_sister|0-5’: 5, // 兄妹数量
‘spouse_status’: ‘健康’, // 配偶现状
‘spouse_name’: ‘@cname’, // 配偶姓名
‘spouse_mobile’: ‘@phone’, // 配偶联系电话
‘children|0-3’: [ // 子女
{
name: ‘@cname’,
‘age|1-30’: 30
}
], // 子女数量
‘total_value|100-99999’: 99999, // 价值总额
‘nature_of_employment|1’: [‘劳务派遣’, ‘合同制’, ‘雇佣’], // 用工性质
‘on_duty_status|1’: [‘在岗’, ‘离职’, ‘退休’], // 在岗状态
‘departure_time’: ‘@date(“yyyy-MM-dd”)’, // 离职时间
‘departure_reason’: ‘离职原因’ // 离职原因
}]
}),
total: 100,
msg: ‘调用成功’
}
}
},

// get user info
{
url: ${Action}/detailList,
type: ‘post’,
response: config => {
const { notice_id } = config.body
console.log(‘notice_id’, notice_id)
// const list = detailList[+notice_id]
const detailList = []
for(let j = 0; j < 10; j++) {
let d = {
id: j,
company: (compony[Math.floor(Math.random() * 10)]) + ‘有限公司’,
contact_person: (contactPerson[Math.floor(Math.random() * 10)]),
mobile: (mobile[Math.floor(Math.random() * 10)]),
fileList: [
{name:‘修正文档.pdf’,‘url’:’’},
{name:‘附件资质说明.doc’,‘url’:’’}
],
fbDetailList: [
{name:‘关于道路规划预案一’, add_time:‘2021-04-03’},
{name:‘关于道路规划预案二’, add_time:‘2021-04-06’},
{name:‘关于道路施工规划预案一’, add_time:‘2021-04-083’},
{name:‘关于道路施工规划预案二’, add_time:‘2021-04-02’}
],
add_time: ‘2021-04-19’
}
detailList.push(d)
}
return {
status: 1,
data: detailList,
total: detailList.length
}
}
},
{
url: ${Action}/fbList,
type: ‘post’,
response: config => {
const { notice_id } = config.body
console.log(‘notice_id’, notice_id)
// const list = detailList[+notice_id]
const detailList = []
for(let j = 0; j < 10; j++) {
let d = {
id: j,
company: (compony[Math.floor(Math.random() * 10)]) + ‘有限公司’,
contact_person: (contactPerson[Math.floor(Math.random() * 10)]),
mobile: (mobile[Math.floor(Math.random() * 10)]),
fileList: [
{name:‘修正文档.pdf’,‘url’:’’},
{name:‘附件资质说明.doc’,‘url’:’’}
],
fbDetailList: [
{name:‘关于道路规划预案一’, add_time:‘2021-04-03’},
{name:‘关于道路规划预案二’, add_time:‘2021-04-06’},
{name:‘关于道路施工规划预案一’, add_time:‘2021-04-083’},
{name:‘关于道路施工规划预案二’, add_time:‘2021-04-02’}
],
add_time: ‘2021-04-19’
}
detailList.push(d)
}
return {
status: 1,
data: detailList,
total: detailList.length
}
}
},

// user logout
{
url: ${Action}/deleteItem,
type: ‘post’,
response: config => {
const { id } = config.body
if (Array.isArray(id)) {
id.forEach(i => list.splice(i, 1))
} else {
list.splice(id, 1)
}

  return {
    status: 1,
    data: 'success'
  }
}

},
{
url: ${Action}/getOne,
type: ‘post’,
response: config => {
const { id } = config.body
return {
status: 1,
data: list[+id]||[]
}
}
},
{
url: ${Action}/addOne,
type: ‘post’,
response: config => {
const { title, feedback, notice_time, id } = config.body
const read = Math.floor(Math.random() * 100), total = 100
const row = { id: id!==undefined?id:list.length, title, feedback, notice_time, add_time: notice_time, total, read, percentage: Math.floor(read * 100 / total) }
if (id!==undefined) {
list[+id] = row
console.log(‘row’, row)
} else {
list.unshift(row)
}
return {
status: 1,
data: true
}
}
}
]

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值