login.html 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348
  1. <!DOCTYPE html>
  2. <html lang="zh">
  3. <head>
  4. <meta charset="UTF-8" />
  5. <title>Roma</title>
  6. <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  7. <link rel="icon" type="image/x-ico" href=""/>
  8. <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1"/>
  9. <meta http-equiv="X-UA-Compatible" content="IE=Edge" />
  10. <link rel="stylesheet" href="./public/static/amis-sdk/helper.css">
  11. <link rel="stylesheet" href="./public/static/amis-sdk/sdk.css">
  12. <style>
  13. html,
  14. body,
  15. .app-wrapper {
  16. /* position: relative; */
  17. width: 100%;
  18. height: 100%;
  19. margin: 0;
  20. padding: 0;
  21. touch-action: pan-y;
  22. overflow: hidden;
  23. }
  24. :root {
  25. --Form-item-gap: 1.3rem;
  26. --InputGroup-height: 2.5rem;
  27. --Button-height: 2.5rem;
  28. --InputGroup-paddingX: .6rem;
  29. --InputGroup-addOn-bg: var(--Form-input-bg);
  30. /* --fontSizeBase: .9rem; */
  31. }
  32. .app-wrapper {
  33. /* position: relative; */
  34. width: 100%;
  35. height: 100%;
  36. margin: 0;
  37. padding: 0;
  38. }
  39. .amis-scope .cxd-Icon{height: 1rem}
  40. .amis-scope .cxd-TextControl-input input{height: 100% !important;}
  41. .amis-scope .cxd-TextControl-input:hover{border:var(--Form-input-borderWidth) solid var(--Form-input-borderColor)}
  42. .amis-scope .cxd-InputGroup .cxd-TextControl-input{border-left-width: 0;padding-left: 0;}
  43. .code_img{cursor: pointer;}
  44. .amis-scope .cxd-Form{
  45. font-size: var(--Form-fontSize);
  46. position: none !important;
  47. max-width: 700px;
  48. margin: 0 auto;
  49. margin-top: 10vh;
  50. /* position:; */
  51. }
  52. .amis-scope .cxd-Wrapper--md, .amis-scope .cxd-Container--md {
  53. width: 100%;
  54. height: 100%;
  55. }
  56. .amis-scope h1 {
  57. font-size: 4vw;
  58. }
  59. @media (max-width: 768px) {
  60. .amis-scope .cxd-Form{
  61. font-size: var(--Form-fontSize);
  62. position: none !important;
  63. margin: 0 auto;
  64. margin-top: 0vh;
  65. /* position:; */
  66. }
  67. .amis-scope .cxd-Wrapper--md, .amis-scope .cxd-Container--md {
  68. padding: 0;
  69. }
  70. }
  71. .amis-scope .cxd-Button--default {
  72. border: none;
  73. outline: none;
  74. }
  75. .amis-scope .cxd-Button--default:not(:disabled):not(.is-disabled):hover {
  76. color: none;
  77. background: none;
  78. border-color: none;
  79. border-width: none;
  80. border-style: none;
  81. box-shadow: none;
  82. border: none;
  83. outline: none;
  84. }
  85. .amis-scope .m-r-xs {
  86. margin-top:-5px;
  87. width: 30px;
  88. height: 30px;
  89. }
  90. .amis-scope .cxd-Form .cxd-Wrapper--md, .amis-scope .cxd-Container--md {
  91. height: 1%;
  92. }
  93. </style>
  94. </head>
  95. <body>
  96. <div id="root" class="app-wrapper"></div>
  97. <script type='text/javascript' src='./public/static/amis-sdk/sdk.js'></script>
  98. <script src="./lang/en-US.js"></script>
  99. <script src="./lang/zh-CN.js"></script>
  100. <script type="text/javascript">
  101. (function () {
  102. let amis = amisRequire('amis/embed');
  103. // 引入语言包内容
  104. let enUSLocale = enUs()
  105. let zhCNLocale = zhCn()
  106. //多语言映射
  107. const languageMap = {
  108. "en-US": {
  109. register: enUSLocale.register,
  110. replaceText: enUSLocale.replaceText,
  111. langReplaceTextIgnoreKeys: enUSLocale.langReplaceTextIgnoreKeys
  112. },
  113. "zh-CN": {
  114. register: zhCNLocale.register,
  115. replaceText: zhCNLocale.replaceText,
  116. langReplaceTextIgnoreKeys: zhCNLocale.langReplaceTextIgnoreKeys
  117. }
  118. }
  119. // 缓存中设置的语言
  120. let lang = localStorage.getItem('language')
  121. //内置组件的翻译信息
  122. let langRegister = {}
  123. //json配置的全文翻译信息
  124. let langReplaceText = {}
  125. //需要忽略json配置的全文替换key
  126. let langReplaceTextIgnoreKeys = {}
  127. if (undefined !== languageMap[lang]) {
  128. langRegister = languageMap[lang].register
  129. langReplaceText = languageMap[lang].replaceText
  130. langReplaceTextIgnoreKeys = languageMap[lang].langReplaceTextIgnoreKeys
  131. } else {
  132. // 未找到默认中文
  133. lang = 'zh-CN'
  134. }
  135. // 没有替换或忽略替换配置,则为{}
  136. if (undefined !== langReplaceText && Object.keys(langReplaceText).length !== 0) {
  137. } else {
  138. langReplaceText = {}
  139. }
  140. if (undefined !== langReplaceTextIgnoreKeys && Object.keys(langReplaceTextIgnoreKeys).length !== 0) {
  141. } else {
  142. langReplaceTextIgnoreKeys = {}
  143. }
  144. // 页面json内容
  145. const amisJSON = {
  146. "type": "wrapper",
  147. "className": "fixed login_layout m:h-screen m:w-full bg-gray-50",
  148. "body": {
  149. "type": "form",
  150. "className": "h-full pc:p-9 m:p-4 m:pt-20",
  151. "api": {
  152. "method":"post",
  153. "url":"/login",
  154. "adaptor": function (data) {
  155. if (data.status !== 0) {
  156. // 登录请求提交后,刷新验证码
  157. refresh_code();
  158. }
  159. return data;
  160. },
  161. },
  162. "redirect": "/",
  163. "wrapWithPanel": false,
  164. "body": [
  165. {
  166. "type": "wrapper",
  167. "body": [
  168. {
  169. "type": "flex",
  170. "justify": "flex-end",
  171. "items": [
  172. {
  173. "type": "dropdown-button",
  174. "label": "",
  175. "className": "header-menu",
  176. "buttons": [
  177. {
  178. "type": "button",
  179. "label": "中文",
  180. "id": "u:6911502c8fcc",
  181. "onEvent": {
  182. "click": {
  183. "actions": [
  184. {
  185. "script": "localStorage.setItem('language', 'zh-CN')\nlocation.reload()",
  186. "actionType": "custom",
  187. "args": {
  188. }
  189. }
  190. ],
  191. "weight": 0
  192. }
  193. }
  194. },
  195. {
  196. "type": "button",
  197. "label": "English",
  198. "id": "u:e702685a7a45",
  199. "onEvent": {
  200. "click": {
  201. "actions": [
  202. {
  203. "script": "localStorage.setItem('language', 'en-US')\r\nlocation.reload()",
  204. "actionType": "custom"
  205. }
  206. ],
  207. "weight": 0
  208. }
  209. },
  210. "actionType": "",
  211. "link": "/view/user_info"
  212. }
  213. ],
  214. "id": "u:4fedf7a987bf",
  215. "size": "md",
  216. "level": "default",
  217. "align": "right",
  218. "block": false,
  219. "hideCaret": true,
  220. "trigger": "hover",
  221. "icon": "./public/static/icon/language-change.png",
  222. "btnClassName": "no-border"
  223. }
  224. ],
  225. "id": "u:e7752d0c1dbe"
  226. }
  227. ],
  228. "id": "u:d16525b6aae6",
  229. "asideResizor": false,
  230. "pullRefresh": {
  231. "disabled": true
  232. }
  233. },
  234. {
  235. "type":"html",
  236. "className":"text-center",
  237. "html":"<h1 class='title-name'>Roma 平台</h1>"
  238. },
  239. {
  240. "type": "input-group",
  241. "label": "",
  242. "body": [
  243. {
  244. "type": "icon",
  245. "icon": "./public/static/icon/shield-user-line.svg"
  246. },
  247. {
  248. "type": "input-text",
  249. "label": false,
  250. "placeholder": "用户名",
  251. "name": "name",
  252. "required": true
  253. }
  254. ]
  255. },
  256. {
  257. "type": "input-group",
  258. "label": "",
  259. "body": [
  260. {
  261. "type": "icon",
  262. "icon": "./public/static/icon/lock-password-line.svg",
  263. },
  264. {
  265. "type": "input-password",
  266. "label": false,
  267. "placeholder": "密码",
  268. "name": "pwd",
  269. "required": true
  270. }
  271. ]
  272. },
  273. {
  274. "type": "input-group",
  275. "label": "",
  276. "body": [
  277. {
  278. "type": "icon",
  279. "icon": "./public/static/icon/shield-check-line.svg"
  280. },
  281. {
  282. "type": "input-text",
  283. "label": false,
  284. "placeholder": "验证码",
  285. "name": "code",
  286. "required": true
  287. },
  288. {
  289. "type": "action",
  290. "body": {
  291. "type": "image",
  292. "height": "38px",
  293. "width": "110px",
  294. "name":"codeUrl",
  295. "imageClassName":"code_img b-none",
  296. "imageMode":"original",
  297. "src": "/login/verify"
  298. },
  299. // 点击图片 刷新二维码
  300. "onClick": "refresh_code()"
  301. }
  302. ]
  303. },
  304. {
  305. "label": "登 录",
  306. "type": "action",
  307. "actionType": "submit",
  308. "level": "primary",
  309. "className":"w-full h-2.5",
  310. },
  311. // {
  312. // "type":"html",
  313. // "className":"text-center",
  314. // "html":"<p class='mt-10 text-gray-600'>Roma平台</p>"
  315. // },
  316. ]
  317. }
  318. };
  319. let amisScoped = amis.embed(
  320. '#root',
  321. amisJSON,
  322. {
  323. locale: lang
  324. },
  325. {
  326. replaceText: langReplaceText,
  327. langReplaceTextIgnoreKeys: langReplaceTextIgnoreKeys
  328. }
  329. );
  330. })();
  331. // 刷新验证码
  332. function refresh_code()
  333. {
  334. document.querySelector('.code_img').src = '/login/verify?' + Math.random();
  335. }
  336. </script>
  337. </body>
  338. </html>