login-json.js 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256
  1. function getLoginJson() {
  2. let headerJson = {
  3. "type": "wrapper",
  4. "className": "fixed login_layout m:h-screen m:w-full bg-gray-50",
  5. "body": {
  6. "type": "form",
  7. "className": "h-full pc:p-9 m:p-4 m:pt-20",
  8. "api": {
  9. "method":"post",
  10. "url":"/api/login",
  11. "dataType":"form",
  12. "headers": {
  13. "Authorization": 'Bearer ' + getToken()
  14. },
  15. "requestAdaptor":function(data){
  16. data.data.captchaToken = getCaptchaCode()
  17. return data;
  18. },
  19. "adaptor": function (data, response) {
  20. // token 续期的问题,在app.html中进行续期判断.
  21. if (data.status != "0") {
  22. // 登录请求提交后,刷新验证码
  23. refresh_code();
  24. // 弹出错误提示
  25. } else {
  26. // 存储登录token
  27. let token = data.data.loginToken;
  28. localStorage.setItem("apiToken", token);
  29. }
  30. return {
  31. ...data,
  32. status: data.status,
  33. msg: data.status == "0" ? "" : data.msg,
  34. };
  35. },
  36. "messages": {
  37. "success": "success",
  38. // "failed": "糟糕,失败了!"
  39. }
  40. },
  41. "redirect": "./app.html",
  42. "wrapWithPanel": false,
  43. "body": [
  44. {
  45. "type":"html",
  46. "className":"text-center",
  47. "html":"<h1 class='title-name'>Roma 平台</h1>"
  48. },
  49. {
  50. "type": "input-group",
  51. "label": "",
  52. "body": [
  53. {
  54. "type": "icon",
  55. "icon": "./public/static/icon/shield-user-line.svg"
  56. },
  57. {
  58. "type": "input-text",
  59. "label": false,
  60. "placeholder": "用户名",
  61. "name": "api_name",
  62. "required": true
  63. }
  64. ]
  65. },
  66. {
  67. "type": "input-group",
  68. "label": "",
  69. "body": [
  70. {
  71. "type": "icon",
  72. "icon": "./public/static/icon/lock-password-line.svg",
  73. },
  74. {
  75. "type": "input-password",
  76. "label": false,
  77. "placeholder": "密码",
  78. "name": "api_password",
  79. "required": true
  80. }
  81. ]
  82. },
  83. {
  84. "type": "input-group",
  85. "label": "",
  86. "body": [
  87. {
  88. "type": "icon",
  89. "icon": "./public/static/icon/shield-check-line.svg"
  90. },
  91. {
  92. "type": "input-text",
  93. "label": false,
  94. "placeholder": "验证码",
  95. "name": "api_captcha",
  96. "required": true
  97. },
  98. {
  99. "type": "action",
  100. "body": {
  101. "type": "image",
  102. "height": "38px",
  103. "width": "110px",
  104. "name":"codeUrl",
  105. "imageClassName":"code_img b-none",
  106. "imageMode":"original",
  107. "src": ""
  108. },
  109. // 点击图片 刷新二维码
  110. "onClick": "refresh_code()"
  111. }
  112. ]
  113. },
  114. {
  115. "type": "hidden",
  116. "name": "captchaToken",
  117. "value": ""
  118. },
  119. {
  120. "label": "登 录",
  121. "type": "action",
  122. "actionType": "submit",
  123. "level": "primary",
  124. "className":"w-full h-2.5",
  125. },
  126. {
  127. "type": "wrapper",
  128. "body": [
  129. {
  130. "type": "flex",
  131. "id": "u:e7752d0c1dbe",
  132. "justify": "flex-end",
  133. "items": [
  134. {
  135. "type": "container",
  136. "body": [
  137. {
  138. "type": "tooltip-wrapper",
  139. "tooltip": "请联系管理员,邮箱xxxxx@xxx.com",
  140. "body": [
  141. {
  142. "type": "tpl",
  143. "tpl": "忘记密码?",
  144. "id": "u:47f172268df5",
  145. "wrapperComponent": "",
  146. "hidden": false,
  147. "className": "m-l-none"
  148. }
  149. ],
  150. "enterable": true,
  151. "showArrow": true,
  152. "offset": [
  153. 8,
  154. 6
  155. ],
  156. "id": "u:3878dcf435b8",
  157. "trigger": [
  158. "hover"
  159. ],
  160. "mouseEnterDelay": 0,
  161. "mouseLeaveDelay": 0,
  162. "placement": "bottom",
  163. "inline": true
  164. }
  165. ],
  166. "size": "xs",
  167. "style": {
  168. "position": "static",
  169. "display": "block",
  170. "flex": "1 1 auto",
  171. "flexGrow": 1,
  172. "flexBasis": "auto"
  173. },
  174. "wrapperBody": false,
  175. "isFixedHeight": false,
  176. "isFixedWidth": false,
  177. "id": "u:ec685674b43d"
  178. },
  179. {
  180. "type": "dropdown-button",
  181. "label": "",
  182. "className": "header-menu",
  183. "buttons": [
  184. {
  185. "type": "button",
  186. "label": "中文",
  187. "id": "u:6911502c8fcc",
  188. "onEvent": {
  189. "click": {
  190. "actions": [
  191. {
  192. "script": "localStorage.setItem('language', 'zh-CN')\nlocation.reload()",
  193. "actionType": "custom",
  194. "args": {
  195. }
  196. }
  197. ],
  198. "weight": 0
  199. }
  200. }
  201. },
  202. {
  203. "type": "button",
  204. "label": "English",
  205. "id": "u:e702685a7a45",
  206. "onEvent": {
  207. "click": {
  208. "actions": [
  209. {
  210. "script": "localStorage.setItem('language', 'en-US')\r\nlocation.reload()",
  211. "actionType": "custom"
  212. }
  213. ],
  214. "weight": 0
  215. }
  216. },
  217. "actionType": "",
  218. "link": "/view/user_info"
  219. }
  220. ],
  221. "id": "u:4fedf7a987bf",
  222. "size": "md",
  223. "level": "default",
  224. "align": "right",
  225. "block": false,
  226. "hideCaret": true,
  227. "trigger": "hover",
  228. "icon": "./public/static/icon/language-change.png",
  229. "btnClassName": "no-border"
  230. }
  231. ]
  232. }
  233. ],
  234. "id": "u:d16525b6aae6",
  235. "asideResizor": false,
  236. "pullRefresh": {
  237. "disabled": true
  238. }
  239. },
  240. {
  241. "type": "divider",
  242. "id": "u:4ba78892d2e9"
  243. },
  244. {
  245. "type":"html",
  246. "className":"text-center",
  247. "html":"<p class='mt-10 text-gray-600'>© 2023, Roma Services LLC. All Rights Reserved. An Roma Company</p>"
  248. }
  249. ]
  250. }
  251. };
  252. return headerJson;
  253. }