register.vue 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270
  1. <template>
  2. <view class="container">
  3. <view class="container_text" >
  4. <!-- <image class="banner-img" src="/static/img/img01.png" mode="scaleToFill"></image> -->
  5. </view>
  6. <view class="loginTitle"><text>注册</text></view>
  7. <view class="login_text">
  8. <view class="login_input flex">
  9. <view class="login_img"><image src="../../static/icon/phone.png"></image></view>
  10. <view class="login_name"><input class="uni-input" v-model="phone" focus placeholder="请输入账号" /></view>
  11. </view>
  12. <view class="login_input flex">
  13. <view class="login_img"><image src="../../static/icon/pswd.png"></image></view>
  14. <view class="login_name"><input class="uni-input" type="password" v-model="password" focus placeholder="请输入密码" /></view>
  15. </view>
  16. <view class="login_input flex">
  17. <view class="login_img"><image src="../../static/icon/pswd.png"></image></view>
  18. <view class="login_name"><input class="uni-input" type="password" v-model="repassword" focus placeholder="请重复输入密码" /></view>
  19. </view>
  20. <view class="login_input flex">
  21. <view class="login_img"><image src="../../static/icon/tg.png"></image></view>
  22. <view class="login_name"><input class="uni-input" type="text" v-model="invitation" focus placeholder="请输入邀请码" /></view>
  23. </view>
  24. <view class="login_input flex">
  25. <view class="login_img"><image src="../../static/icon/code.png"></image></view>
  26. <view class="login_name flex">
  27. <input class="uni-input width" v-model="code" focus placeholder="请输入验证码" />
  28. <view class="code" @click="verification">{{ countDown == 0 ? '验证码' : countDown }}</view>
  29. </view>
  30. </view>
  31. <view><button type="green" @click="register" class="uni-button uni-button-green">注册账号</button></view>
  32. <view><button class="uni-button uni-button-green uni-button-green-plain" type="green" plain="true" hover-class="none" @click="login">返回登录</button></view>
  33. </view>
  34. </view>
  35. </template>
  36. <script>
  37. import { register, verify } from '@/api/login.js';
  38. export default {
  39. data() {
  40. return {
  41. phone: '', //用户
  42. password: '', //密码
  43. repassword: '',
  44. invitation: '', //邀请码
  45. code: '', //验证码
  46. time: '', //保存倒计时对象
  47. countDown: 0 ,//倒计时
  48. };
  49. },
  50. onLoad() {
  51. // 获取扫码邀请人id
  52. this.invitation = uni.getStorageSync('spread')||'';
  53. },
  54. watch: {
  55. // 监听倒计时
  56. countDown(i) {
  57. if (i == 0) {
  58. clearInterval(this.time);
  59. }
  60. }
  61. },
  62. methods: {
  63. // 注册
  64. register() {
  65. let obj = this;
  66. if (obj.phone == '') {
  67. obj.$api.msg('请输入账号');
  68. return;
  69. }
  70. if (obj.password == '') {
  71. obj.$api.msg('请输入密码');
  72. return;
  73. }
  74. if (obj.repassword == '') {
  75. obj.$api.msg('请再次输入密码');
  76. return;
  77. }
  78. if (obj.repassword != obj.password) {
  79. obj.$api.msg('两次密码不正确');
  80. return;
  81. }
  82. register({
  83. account: obj.phone, //账号
  84. captcha: 123456, //验证码
  85. password: obj.password ,//密码
  86. spread:this.invitation//上级推广人
  87. }).then(function(e) {
  88. uni.showToast({
  89. title:'注册成功',
  90. duration:2000,
  91. position:'top'
  92. });
  93. setTimeout(function () {
  94. uni.navigateTo({
  95. url: '/pages/public/login'
  96. });
  97. },1000)
  98. });
  99. //调用注册接口,成功跳转登录页
  100. },
  101. //发送验证码
  102. verification() {
  103. let obj = this;
  104. if (this.phone == '') {
  105. this.$api.msg('请输入电话号码');
  106. return;
  107. }
  108. if (this.phone.length < 11) {
  109. this.$api.msg('请输入正确的手机号');
  110. return;
  111. }
  112. // 判断是否在倒计时
  113. if (obj.countDown > 0) {
  114. return false;
  115. } else {
  116. obj.countDown = 60;
  117. obj.time = setInterval(() => {
  118. obj.countDown--;
  119. }, 1000);
  120. //调用验证码接口
  121. verify({
  122. phone: obj.phone,
  123. type: 'register'
  124. })
  125. .then(({ data }) => {})
  126. .catch(err => {
  127. console.log(err);
  128. });
  129. }
  130. },
  131. login() {
  132. //返回登录
  133. uni.navigateTo({
  134. url: '/pages/public/login'
  135. });
  136. }
  137. }
  138. };
  139. </script>
  140. <style lang="scss">
  141. page {
  142. height: 100%;
  143. }
  144. .container {
  145. width: 100%;
  146. height: 100%;
  147. background-size: 100%;
  148. }
  149. .container_text {
  150. width: 100%;
  151. height: 500rpx;
  152. top: 0rpx;
  153. background-color: #FF4343;
  154. .banner-img {
  155. width: 100%;
  156. height: 100%;
  157. }
  158. }
  159. .login_text {
  160. margin: auto 30rpx;
  161. position: relative;
  162. padding: 100rpx 102rpx;
  163. background-color: #ffffff;
  164. margin-top: -180rpx;
  165. border-radius: 20rpx;
  166. .login_input {
  167. border-bottom: 1px solid #f0f0f0;
  168. margin-bottom: 65rpx;
  169. .login_img image {
  170. height: 35rpx;
  171. width: 29rpx;
  172. margin-right: 20rpx;
  173. }
  174. .uni-input {
  175. text-align: left;
  176. width: 470rpx;
  177. font-size: 28rpx !important;
  178. }
  179. .login_name {
  180. color: #333333;
  181. }
  182. }
  183. .other {
  184. margin-top: 60rpx;
  185. .fenge {
  186. width: 30%;
  187. height: 2rpx;
  188. background-color: #eeeeee;
  189. }
  190. .qita {
  191. font-size: 28rpx;
  192. color: #999999;
  193. }
  194. }
  195. .weixin {
  196. width: 75rpx;
  197. height: 75rpx;
  198. margin: 25rpx auto;
  199. }
  200. .weixin image {
  201. width: 100%;
  202. height: 100%;
  203. }
  204. .weixin_text {
  205. text-align: center;
  206. font-size: 28rpx;
  207. color: #999999;
  208. }
  209. .forget {
  210. font-size: 28rpx;
  211. width: 100%;
  212. text-align: right;
  213. color: #999999;
  214. }
  215. .uni-button-green {
  216. color: #ffffff;
  217. background-color: $base-color;
  218. margin: 40rpx 10rpx;
  219. border-radius: 50rpx;
  220. }
  221. .uni-button-green-plain {
  222. border: 1px solid $base-color;
  223. margin: 40rpx 10rpx;
  224. border-radius: 50rpx;
  225. color: $base-color;
  226. background-color: #ffffff;
  227. }
  228. .uni-button {
  229. height: 85rpx;
  230. line-height: 85rpx;
  231. }
  232. }
  233. .loginTitle {
  234. position: absolute;
  235. top: 250rpx;
  236. width: 100%;
  237. text-align: center;
  238. color: white;
  239. font-size: 40rpx;
  240. }
  241. .forget {
  242. width: 100rpx;
  243. font-size: 24rpx;
  244. color: #ffffff;
  245. margin: 0px auto;
  246. border-bottom: 1px solid #ffffff;
  247. }
  248. .width {
  249. width: 325rpx !important;
  250. }
  251. .code {
  252. color: $base-color;
  253. font-size: 23rpx;
  254. border-left: 1px solid #eeeeee;
  255. width: 150rpx;
  256. flex-shrink: 0;
  257. text-align: center;
  258. }
  259. uni-button {
  260. height: 80rpx !important;
  261. line-height: 80rpx !important;
  262. }
  263. </style>