register.vue 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287
  1. <template>
  2. <view class="container">
  3. <view class="left-bottom-sign"></view>
  4. <view class="back-btn yticon icon-zuojiantou-up" @click="navBack"></view>
  5. <view class="right-top-sign"></view>
  6. <!-- 设置白色背景防止软键盘把下部绝对定位元素顶上来盖住输入框等 -->
  7. <view class="wrapper">
  8. <view class="left-top-sign">REGISTER</view>
  9. <view class="welcome">
  10. 欢迎加入!
  11. </view>
  12. <view class="input-content">
  13. <view class="input-item">
  14. <text class="tit">手机号码</text>
  15. <input type="number" :value="phone" placeholder="请输入手机号码" maxlength="11" data-key="phone" @input="inputChange" />
  16. </view>
  17. <view class="input-item">
  18. <text class="tit">验证码</text>
  19. <view class="verify-code">
  20. <input type="mobile" value="" placeholder="6位验证码" maxlength="6"
  21. data-key="verifyCode" @input="inputChange" style="width: 60%;" />
  22. <button style="width: 40%;" :disabled="sendDisabled" @click="doGetVerify">{{sendText}}</button>
  23. </view>
  24. </view>
  25. <view class="input-item">
  26. <text class="tit">密码</text>
  27. <input type="mobile" value="" placeholder="8-18位数字、字母组合" placeholder-class="input-empty" maxlength="20"
  28. data-key="password" @input="inputChange" @confirm="doRegister" />
  29. </view>
  30. </view>
  31. <button style="background-color: #39b54a;" class="confirm-btn" @click="doRegister" :disabled="registering">注册</button>
  32. </view>
  33. <view class="register-section">
  34. 已经有账号?
  35. <text @click="toLogin">马上登录</text>
  36. </view>
  37. </view>
  38. </template>
  39. <script>
  40. import {
  41. mapMutations
  42. } from 'vuex';
  43. export default {
  44. data() {
  45. return {
  46. phone: '',
  47. password: '',
  48. registering: false,
  49. sendText: '获取验证码',
  50. sendDisabled: false
  51. }
  52. },
  53. onLoad() {
  54. },
  55. methods: {
  56. ...mapMutations(['login']),
  57. inputChange(e) {
  58. const key = e.currentTarget.dataset.key;
  59. this[key] = e.detail.value;
  60. },
  61. navBack() {
  62. uni.navigateBack();
  63. },
  64. toLogin() {
  65. uni.redirectTo({
  66. url: "/pages/public/login"
  67. })
  68. },
  69. doGetVerify() {
  70. const that = this
  71. if (!that.phone || that.phone.length != 11) {
  72. uni.showToast({
  73. title:'请输入正确手机号!',
  74. icon:'none'
  75. })
  76. return
  77. }
  78. that.$api.request('get', 'captchaSms', {
  79. phonenumber: that.phone,
  80. }).then(res => {
  81. that.sendDisabled = true
  82. let sec = 60
  83. let interval = setInterval(() => {
  84. sec--;
  85. that.sendText = sec + 's后重发'
  86. if (sec <= 0) {
  87. that.sendDisabled = false
  88. that.sendText = "获取验证码"
  89. clearInterval(interval)
  90. }
  91. }, 1000)
  92. })
  93. },
  94. async doRegister() {
  95. const that = this
  96. that.registering = true;
  97. that.$api.request('get','register', {
  98. phone: that.phone,
  99. password: that.password,
  100. verifyCode: that.verifyCode
  101. }, (failres => {
  102. uni.showToast({
  103. title:failres.msg
  104. })
  105. that.registering = false
  106. })).then(res => {
  107. //注册成功
  108. that.registering = false
  109. uni.redirectTo({
  110. url: './login'
  111. })
  112. })
  113. }
  114. },
  115. }
  116. </script>
  117. <style lang='scss'>
  118. page {
  119. background: #fff;
  120. }
  121. .container {
  122. padding-top: 115px;
  123. position: relative;
  124. width: 100vw;
  125. height: 100vh;
  126. overflow: hidden;
  127. background: #fff;
  128. }
  129. .wrapper {
  130. position: relative;
  131. z-index: 90;
  132. background: #fff;
  133. padding-bottom: 40upx;
  134. }
  135. .back-btn {
  136. position: absolute;
  137. left: 40upx;
  138. z-index: 9999;
  139. padding-top: var(--status-bar-height);
  140. top: 40upx;
  141. font-size: 40upx;
  142. color: $font-color-dark;
  143. }
  144. .left-top-sign {
  145. font-size: 120upx;
  146. color: $page-color-base;
  147. position: relative;
  148. left: -16upx;
  149. }
  150. .right-top-sign {
  151. position: absolute;
  152. top: 80upx;
  153. right: -30upx;
  154. z-index: 95;
  155. &:before,
  156. &:after {
  157. display: block;
  158. content: "";
  159. width: 400upx;
  160. height: 80upx;
  161. background: #b4f3e2;
  162. }
  163. &:before {
  164. transform: rotate(50deg);
  165. border-radius: 0 50px 0 0;
  166. }
  167. &:after {
  168. position: absolute;
  169. right: -198upx;
  170. top: 0;
  171. transform: rotate(-50deg);
  172. border-radius: 50px 0 0 0;
  173. /* background: pink; */
  174. }
  175. }
  176. .left-bottom-sign {
  177. position: absolute;
  178. left: -270upx;
  179. bottom: -320upx;
  180. border: 100upx solid #d0d1fd;
  181. border-radius: 50%;
  182. padding: 180upx;
  183. }
  184. .welcome {
  185. position: relative;
  186. left: 50upx;
  187. top: -90upx;
  188. font-size: 46upx;
  189. color: #555;
  190. text-shadow: 1px 0px 1px rgba(0, 0, 0, .3);
  191. }
  192. .input-content {
  193. padding: 0 60upx;
  194. }
  195. .input-item {
  196. display: flex;
  197. flex-direction: column;
  198. align-items: flex-start;
  199. justify-content: center;
  200. padding: 0 30upx;
  201. background: $page-color-light;
  202. height: 140upx;
  203. border-radius: 4px;
  204. margin-bottom: 50upx;
  205. &:last-child {
  206. margin-bottom: 0;
  207. }
  208. .tit {
  209. height: 50upx;
  210. line-height: 56upx;
  211. font-size: $font-sm+2upx;
  212. color: $font-color-base;
  213. }
  214. input {
  215. height: 60upx;
  216. font-size: $font-base + 2upx;
  217. color: $font-color-dark;
  218. width: 100%;
  219. }
  220. .verify-code {
  221. flex-direction: row;
  222. display: flex;
  223. justify-content:end;
  224. flex-wrap: wrap
  225. }
  226. }
  227. .confirm-btn {
  228. width: 630upx;
  229. height: 76upx;
  230. line-height: 76upx;
  231. border-radius: 50px;
  232. margin-top: 70upx;
  233. background: $uni-color-primary;
  234. color: #fff;
  235. font-size: $font-lg;
  236. &:after {
  237. border-radius: 100px;
  238. }
  239. }
  240. .forget-section {
  241. font-size: $font-sm+2upx;
  242. color: $font-color-spec;
  243. text-align: center;
  244. margin-top: 40upx;
  245. }
  246. .register-section {
  247. position: absolute;
  248. left: 0;
  249. bottom: 50upx;
  250. width: 100%;
  251. font-size: $font-sm+2upx;
  252. color: $font-color-base;
  253. text-align: center;
  254. text {
  255. color: $font-color-spec;
  256. margin-left: 10upx;
  257. }
  258. }
  259. </style>