register.vue 6.6 KB

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