user.js 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113
  1. const tokens = {
  2. admin: {
  3. token: 'admin-token'
  4. },
  5. editor: {
  6. token: 'editor-token'
  7. }
  8. }
  9. const users = {
  10. 'admin-token': {
  11. roles: ['admin'],
  12. introduction: 'I am a super administrator',
  13. avatar: 'https://wpimg.wallstcn.com/f778738c-e4f8-4870-b634-56703b4acafe.gif',
  14. name: 'Super Admin'
  15. },
  16. 'editor-token': {
  17. roles: ['editor'],
  18. introduction: 'I am an editor',
  19. avatar: 'https://wpimg.wallstcn.com/f778738c-e4f8-4870-b634-56703b4acafe.gif',
  20. name: 'Normal Editor'
  21. }
  22. }
  23. module.exports = [
  24. // user login
  25. {
  26. url: '/vue-element-admin/user/login',
  27. type: 'post',
  28. response: config => {
  29. const { username } = config.body
  30. const token = tokens[username]
  31. // mock error
  32. if (!token) {
  33. return {
  34. code: 60204,
  35. message: 'Account and password are incorrect.'
  36. }
  37. }
  38. return {
  39. code: 20000,
  40. data: token
  41. }
  42. }
  43. },
  44. // get user info
  45. {
  46. url: '/vue-element-admin/user/info\.*',
  47. type: 'get',
  48. response: config => {
  49. // const { token } = config.query
  50. // const info = users[token]
  51. const info = users['admin-token']
  52. // mock error
  53. if (!info) {
  54. return {
  55. code: 50008,
  56. message: 'Login failed, unable to get user details.'
  57. }
  58. }
  59. return {
  60. code: 20000,
  61. data: info
  62. }
  63. }
  64. },
  65. // user logout
  66. {
  67. url: '/vue-element-admin/user/logout',
  68. type: 'post',
  69. response: _ => {
  70. return {
  71. code: 20000,
  72. data: 'success'
  73. }
  74. }
  75. },
  76. // 测试表单
  77. {
  78. url: '/get/payment/lists',
  79. type: 'post',
  80. response: _ => {
  81. return {"code":200,
  82. "message":"\u64cd\u4f5c\u6210\u529f",
  83. "data":{"current_page":1,"data":[
  84. {
  85. "uid":"UID-123",
  86. "title":"TITLE321",
  87. "code":"CODD123",
  88. "status":2,
  89. "created_at":"2022-04-27 08:17:24",
  90. "updated_at":"2022-04-27 08:17:24",
  91. },{
  92. "uid":"UID-1321",
  93. "title":"TITLE31231",
  94. "code":"CODD1343",
  95. "status":1,
  96. "created_at":"2022-04-27 08:17:24",
  97. "updated_at":"2022-04-27 08:17:24",
  98. }
  99. ],"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},
  100. "handshake":""}
  101. }
  102. },
  103. ]