register.vue 5.9 KB

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