SignUp.vue 8.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354
  1. <template>
  2. <div
  3. class="rule-desc"
  4. @keydown.enter="submit"
  5. >
  6. <div class="wrapper-1">
  7. <button
  8. class="close"
  9. @click="$router.go(-1)"
  10. />
  11. <h1 class="">
  12. 欢迎注册
  13. </h1>
  14. <div class="form-item">
  15. <img
  16. :class="{
  17. animate__animated: ifTipUserName,
  18. animate__headShake: ifTipUserName
  19. }"
  20. src="@/assets/images/username-icon.png"
  21. alt=""
  22. draggable="false"
  23. >
  24. <input
  25. ref="first-focus"
  26. v-model.trim="userName"
  27. type="text"
  28. placeholder="请输入账号..."
  29. >
  30. </div>
  31. <div class="form-item">
  32. <img
  33. :class="{
  34. animate__animated: ifTipPassword,
  35. animate__headShake: ifTipPassword
  36. }"
  37. src="@/assets/images/password-icon.png"
  38. alt=""
  39. draggable="false"
  40. >
  41. <input
  42. v-model="password"
  43. type="password"
  44. placeholder="请输入密码..."
  45. @keydown.stop
  46. >
  47. </div>
  48. <div class="form-item form-item-password-repeat">
  49. <img
  50. :class="{
  51. animate__animated: ifTipPasswordRepeat,
  52. animate__headShake: ifTipPasswordRepeat
  53. }"
  54. src="@/assets/images/password-icon.png"
  55. alt=""
  56. draggable="false"
  57. >
  58. <input
  59. v-model="passwordRepeat"
  60. type="password"
  61. placeholder="请再次输入密码..."
  62. >
  63. <div
  64. v-show="ifTipPasswordRepeatText"
  65. class="tip-text"
  66. >
  67. 两次输入密码不一致!
  68. </div>
  69. </div>
  70. <button
  71. class="submit"
  72. @click="submit"
  73. >
  74. <div class="text-wrapper">
  75. 立即注册
  76. </div>
  77. </button>
  78. <button
  79. class="sign-up"
  80. @click="$router.replace({name: 'Login'})"
  81. >
  82. <div class="text-wrapper">
  83. 已有账号,去登录
  84. </div>
  85. </button>
  86. </div>
  87. </div>
  88. </template>
  89. <script>
  90. export default {
  91. data() {
  92. return {
  93. userName: '',
  94. password: '',
  95. passwordRepeat: '',
  96. ifTipUserName: false,
  97. ifTipPassword: false,
  98. ifTipPasswordRepeat: false,
  99. }
  100. },
  101. computed: {
  102. ifTipPasswordRepeatText() {
  103. if (this.password && this.passwordRepeat && this.password !== this.passwordRepeat) {
  104. return true
  105. } else {
  106. return false
  107. }
  108. }
  109. },
  110. mounted() {
  111. window.ifPreventKeyOperationInScene = true
  112. this.$refs['first-focus'].focus()
  113. },
  114. beforeDestroy() {
  115. window.ifPreventKeyOperationInScene = false
  116. },
  117. methods: {
  118. submit: globalUtils.throttle(function() {
  119. if (this.userName.length === 0) {
  120. this.ifTipUserName = true
  121. setTimeout(() => {
  122. this.ifTipUserName = false
  123. }, 1000)
  124. return
  125. }
  126. if (this.password.length === 0) {
  127. this.ifTipPassword = true
  128. setTimeout(() => {
  129. this.ifTipPassword = false
  130. }, 1000)
  131. return
  132. }
  133. if (this.passwordRepeat === 0 || this.ifTipPasswordRepeatText) {
  134. this.ifTipPasswordRepeat = true
  135. setTimeout(() => {
  136. this.ifTipPasswordRepeat = false
  137. }, 1000)
  138. return
  139. }
  140. globalApi.signUp(this.userName, this.password).then((res) => {
  141. this.$alert('即将为您自动登录...', '注册成功!', {
  142. confirmButtonText: '确定',
  143. callback: action => {
  144. if (action === 'confirm') {
  145. globalApi.login(this.userName, this.password).then((res) => {
  146. this.$router.go(-1)
  147. }).catch(error => {
  148. window.alert(error)
  149. })
  150. }
  151. }
  152. })
  153. }).catch(error => {
  154. window.alert(error)
  155. })
  156. }, 1500),
  157. },
  158. }
  159. </script>
  160. <style lang="less" scoped>
  161. .rule-desc {
  162. position: fixed;
  163. left: 0;
  164. top: 0;
  165. width: 100%;
  166. height: 100%;
  167. background: rgba(46,32,19,0.55);
  168. backdrop-filter: blur(5px);
  169. z-index: 10000;
  170. > .wrapper-1 {
  171. width: 624px;
  172. height: calc(624px * 525 / 637);
  173. position: absolute;
  174. left: 50%;
  175. top: 50%;
  176. transform: translate(-50%, -50%);
  177. background-image: url(@/assets/images/sign-up-bg.png);
  178. background-size: contain;
  179. background-repeat: no-repeat;
  180. background-position: center center;
  181. text-align: center;
  182. padding: 29px 100px 40px 100px;
  183. overflow: auto;
  184. > .close {
  185. position: absolute;
  186. top: 19px;
  187. right: 100px;
  188. width: 45px;
  189. height: 45px;
  190. opacity: 0;
  191. }
  192. > h1 {
  193. display: inline-block;
  194. background-image: url(@/assets/images/title-decorator-long.png);
  195. background-size: contain;
  196. background-repeat: no-repeat;
  197. background-position: center center;
  198. padding: 0 45px 20px 45px;
  199. font-size: 36px;
  200. font-family: LiSu-Regular, LiSu;
  201. font-weight: 400;
  202. color: #9A2D0A;
  203. margin-bottom: 30px;
  204. }
  205. > .form-item {
  206. height: 43px;
  207. width: 300px;
  208. border-bottom: 1px solid #A4573F;
  209. display: inline-flex;
  210. align-items: center;
  211. padding: 0 12px;
  212. margin-bottom: 10px;
  213. > img {
  214. flex: 0 0 auto;
  215. width: 26px;
  216. height: 26px;
  217. margin-right: 14px;
  218. }
  219. > input {
  220. flex: 1 0 1px;
  221. font-size: 16px;
  222. font-family: Source Han Sans CN-Regular, Source Han Sans CN;
  223. font-weight: 400;
  224. color: #9A2D0A;
  225. }
  226. }
  227. > .form-item-password-repeat {
  228. position: relative;
  229. > .tip-text {
  230. position: absolute;
  231. top: calc(100% + 3px);
  232. color: red;
  233. font-size: 14px;
  234. }
  235. }
  236. > button.submit {
  237. background-image: url(@/assets/images/button-border-long-transparent.png);
  238. background-size: contain;
  239. background-repeat: no-repeat;
  240. background-position: center center;
  241. height: 50px;
  242. width: 300px;
  243. padding: 4px 8px 4px 6px;
  244. margin-top: 20px;
  245. margin-bottom: 10px;
  246. > .text-wrapper {
  247. height: 100%;
  248. width: 100%;
  249. background: rgba(143, 72, 49, 0.8);
  250. display: flex;
  251. justify-content: center;
  252. align-items: center;
  253. font-size: 20px;
  254. font-family: LiSu-Regular, LiSu;
  255. font-weight: 400;
  256. color: #FFFFFF;
  257. letter-spacing: 4px;
  258. }
  259. }
  260. > button.sign-up {
  261. background-image: url(@/assets/images/button-border-long-transparent.png);
  262. background-size: contain;
  263. background-repeat: no-repeat;
  264. background-position: center center;
  265. height: 50px;
  266. width: 300px;
  267. padding: 4px 8px 4px 6px;
  268. margin-bottom: 10px;
  269. > .text-wrapper {
  270. height: 100%;
  271. width: 100%;
  272. background: transparent;
  273. display: flex;
  274. justify-content: center;
  275. align-items: center;
  276. font-size: 20px;
  277. font-family: LiSu-Regular, LiSu;
  278. font-weight: 400;
  279. color: #955D4B;
  280. }
  281. }
  282. }
  283. }
  284. .mobile {
  285. .rule-desc {
  286. > .wrapper-1 {
  287. width: 140vw;
  288. height: calc(140vw * 407 / 460);
  289. background-image: url(@/assets/images/sign-up-bg-mobile.png);
  290. padding: 12vw 20vw 8vw 20vw;
  291. > .close {
  292. top: 4vw;
  293. right: 33.5vw;
  294. width: 7.5vw;
  295. height: 7.5vw;
  296. }
  297. > h1 {
  298. padding: 0 9vw 4vw 9vw;
  299. font-size: 6.4vw;
  300. margin-bottom: 10vw;
  301. }
  302. > .form-item {
  303. height: 8.6vw;
  304. width: 60vw;
  305. padding: 0 2.4vw;
  306. margin-bottom: 2vw;
  307. > img {
  308. width: 5.2vw;
  309. height: 5.2vw;
  310. margin-right: 2.8vw;
  311. }
  312. > input {
  313. font-size: 3.7vw;
  314. }
  315. }
  316. > .form-item-password-repeat {
  317. > .tip-text {
  318. top: calc(100% + 0.6vw);
  319. font-size: 2.8vw;
  320. }
  321. }
  322. > button.submit {
  323. height: 10vw;
  324. width: 60vw;
  325. padding: 0.8vw 1.6vw 0.8vw 1.2vw;
  326. margin-top: 12vw;
  327. margin-bottom: 2vw;
  328. > .text-wrapper {
  329. font-size: 4.3vw;
  330. letter-spacing: 0.8vw;
  331. }
  332. }
  333. > button.sign-up {
  334. height: 10vw;
  335. width: 60vw;
  336. padding: 0.8vw 1.6vw 0.8vw 1.2vw;
  337. margin-bottom: 2vw;
  338. > .text-wrapper {
  339. font-size: 4.3vw;
  340. }
  341. }
  342. }
  343. }
  344. }
  345. </style>