step3.vue 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226
  1. <template>
  2. <view class="step3">
  3. <view class="login-form">
  4. <view class="title">填写资料</view>
  5. <view class="input-item">
  6. <label for="">
  7. <text>中国(+86)</text>
  8. </label>
  9. <input type="number" placeholder="请输入手机号" v-model="form.mobile">
  10. </view>
  11. <view class="input-item">
  12. <label for="">
  13. <text>验证码</text>
  14. </label>
  15. <input type="number" placeholder="" maxlength="6" v-model="form.code">
  16. <button class="send-vcode" @tap="sendSms()" :disabled="!sendable">{{sendable?'获取验证码':countdown+'秒'}}</button>
  17. </view>
  18. <view class="input-item">
  19. <label for="">
  20. <text>密码</text>
  21. </label>
  22. <input type="password" placeholder="请输入密码" v-model="form.password">
  23. </view>
  24. <view class="button-item" style="margin-top: 80upx;">
  25. <button class="confirm" @tap="register()">注册</button>
  26. </view>
  27. <view class="agreement">
  28. <view>
  29. <text>注册代表您已同意</text>
  30. <navigator url="/pages/user/simple-article?title=用户协议" open-type="navigate" style="display: inline;">
  31. <text class="warning">《省心直供APP协议》</text>
  32. </navigator>
  33. <navigator url="/pages/user/simple-article?title=用户协议" open-type="navigate" style="display: inline;">
  34. <text class="warning">《隐私协议》</text>
  35. </navigator>
  36. </view>
  37. </view>
  38. </view>
  39. </view>
  40. </template>
  41. <script>
  42. let timeInterval = null;
  43. const time = 120
  44. export default {
  45. data() {
  46. return {
  47. sendable: true,
  48. countdown: time,
  49. form: {
  50. username: "",
  51. mobile: "",
  52. code: "",
  53. password: "",
  54. user_type: 3,
  55. invite_code: "",
  56. }
  57. }
  58. },
  59. methods: {
  60. register() {
  61. if (this.$verified.mobile(this.form.mobile) &&
  62. this.$verified.required(this.form.code, "请输入手机验证码") &&
  63. this.$verified.required(this.form.password, "请输入密码")) {
  64. this.form.username = this.form.mobile;
  65. this.$http.post({
  66. url: "/user/register",
  67. data: this.form,
  68. success(res) {
  69. uni.showToast({
  70. title: res.data.msg,
  71. icon: "none",
  72. success: () => {
  73. setTimeout(() => {
  74. uni.navigateBack({
  75. delta: 999,
  76. animationType:'none'
  77. })
  78. uni.navigateTo({
  79. url: '/pages/user/login'
  80. })
  81. }, 1500)
  82. }
  83. })
  84. }
  85. })
  86. }
  87. },
  88. sendSms() {
  89. if (this.sendable && this.$verified.mobile(this.form.mobile)) {
  90. this.sendable = false;
  91. this.$http.get({
  92. url: '/sms/send',
  93. data: {
  94. mobile: this.form.mobile,
  95. event: "register"
  96. },
  97. success: (res) => {
  98. uni.showToast({
  99. title: res.data.msg,
  100. icon: "none"
  101. })
  102. timeInterval = setInterval(() => {
  103. if (this.countdown-- === 0) {
  104. clearInterval(timeInterval)
  105. this.countdown = time;
  106. this.sendable = true;
  107. }
  108. }, 1000)
  109. },
  110. fail: () => {
  111. this.sendable = true;
  112. }
  113. })
  114. }
  115. },
  116. },
  117. onLoad: function(option) {
  118. this.form.invite_code = option.invite_code;
  119. this.form.user_type = option.user_type;
  120. }
  121. }
  122. </script>
  123. <style lang="scss" scoped>
  124. .step3 {
  125. background: $primary-color;
  126. height: 100vh;
  127. width: 750rpx;
  128. overflow: hidden;
  129. }
  130. .login-form {
  131. margin: auto;
  132. width: 600upx;
  133. height: 700upx;
  134. background-color: white;
  135. border-radius: 20rpx;
  136. padding: 72upx;
  137. padding-top: 40upx;
  138. box-sizing: border-box;
  139. position: relative;
  140. z-index: 2;
  141. margin-top: 200upx;
  142. &::after {
  143. content: "";
  144. background: url(../../static/images/login/box-bottom.png) no-repeat;
  145. background-size: contain;
  146. width: 564upx;
  147. height: 30upx;
  148. display: block;
  149. position: absolute;
  150. bottom: -30upx;
  151. left: 18upx;
  152. z-index: -1;
  153. }
  154. .title {
  155. font-size: 30upx;
  156. color: #999999;
  157. font-weight: bold;
  158. text-align: center;
  159. margin-bottom: 80upx;
  160. }
  161. }
  162. .input-item {
  163. display: flex;
  164. position: relative;
  165. margin-bottom: 30upx;
  166. border-bottom: 2upx solid $primary-color;
  167. align-items: center;
  168. label {
  169. width: 158upx;
  170. font-size: 30upx;
  171. color: #999999;
  172. }
  173. input {
  174. flex-grow: 1;
  175. padding: 10upx 5upx;
  176. font-size: 30upx;
  177. }
  178. }
  179. .confirm {
  180. height: 80upx;
  181. border: 2upx solid $primary-color;
  182. line-height: 80upx;
  183. margin: 30upx 0;
  184. font-size: 32upx;
  185. background: $primary-color;
  186. color: white;
  187. &::after {
  188. border: none;
  189. }
  190. }
  191. .send-vcode {
  192. background: $primary-color;
  193. color: white;
  194. font-size: 24upx;
  195. position: absolute;
  196. padding: 5upx 0;
  197. width: 160upx;
  198. line-height: normal;
  199. right: 0upx;
  200. top: 10upx;
  201. }
  202. .agreement {
  203. font-size: 22upx;
  204. .warning {
  205. color: $primary-color;
  206. font-weight: bold;
  207. }
  208. }
  209. </style>