| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113 |
- const tokens = {
- admin: {
- token: 'admin-token'
- },
- editor: {
- token: 'editor-token'
- }
- }
- const users = {
- 'admin-token': {
- roles: ['admin'],
- introduction: 'I am a super administrator',
- avatar: 'https://wpimg.wallstcn.com/f778738c-e4f8-4870-b634-56703b4acafe.gif',
- name: 'Super Admin'
- },
- 'editor-token': {
- roles: ['editor'],
- introduction: 'I am an editor',
- avatar: 'https://wpimg.wallstcn.com/f778738c-e4f8-4870-b634-56703b4acafe.gif',
- name: 'Normal Editor'
- }
- }
- module.exports = [
- // user login
- {
- url: '/vue-element-admin/user/login',
- type: 'post',
- response: config => {
- const { username } = config.body
- const token = tokens[username]
- // mock error
- if (!token) {
- return {
- code: 60204,
- message: 'Account and password are incorrect.'
- }
- }
- return {
- code: 20000,
- data: token
- }
- }
- },
- // get user info
- {
- url: '/vue-element-admin/user/info\.*',
- type: 'get',
- response: config => {
- // const { token } = config.query
- // const info = users[token]
- const info = users['admin-token']
- // mock error
- if (!info) {
- return {
- code: 50008,
- message: 'Login failed, unable to get user details.'
- }
- }
- return {
- code: 20000,
- data: info
- }
- }
- },
- // user logout
- {
- url: '/vue-element-admin/user/logout',
- type: 'post',
- response: _ => {
- return {
- code: 20000,
- data: 'success'
- }
- }
- },
- // 测试表单
- {
- url: '/get/payment/lists',
- type: 'post',
- response: _ => {
- return {"code":200,
- "message":"\u64cd\u4f5c\u6210\u529f",
- "data":{"current_page":1,"data":[
- {
- "uid":"UID-123",
- "title":"TITLE321",
- "code":"CODD123",
- "status":2,
- "created_at":"2022-04-27 08:17:24",
- "updated_at":"2022-04-27 08:17:24",
- },{
- "uid":"UID-1321",
- "title":"TITLE31231",
- "code":"CODD1343",
- "status":1,
- "created_at":"2022-04-27 08:17:24",
- "updated_at":"2022-04-27 08:17:24",
- }
- ],"first_page_url":"http:\/\/iosadminapi.test\/ios\/manage\/api\/app\/Yard\/lists?page=1","from":1,"last_page":1,"last_page_url":"http:\/\/iosadminapi.test\/ios\/manage\/api\/app\/Yard\/lists?page=1","next_page_url":null,"path":"http:\/\/iosadminapi.test\/ios\/manage\/api\/app\/Yard\/lists","per_page":20,"prev_page_url":null,"to":7,"total":7},
- "handshake":""}
- }
- },
- ]
|