register.vue 6.2 KB

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