register.vue 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231
  1. <template>
  2. <view class="container">
  3. <view class="wjmm" style="text-align: right;padding-right: 30rpx;font-size: 36rpx;" @click="dl()">
  4. 登錄
  5. </view>
  6. <view class="tit" style="padding-top:120rpx;">
  7. 郵箱
  8. </view>
  9. <input type="text" class="shuru" placeholder="請翰入郵箱" v-model="email">
  10. <view class="tit" >
  11. 獲取郵箱驗證碼
  12. </view>
  13. <view class="flex" style="width: 673rpx;justify-content: space-between;margin: auto;border:1px solid red;">
  14. <input type="password" class=" yzm" placeholder="請翰入密碼" v-model="email">
  15. <view class="code yzmbtn" @click="verification">{{ countDown == 0 ? '验证码' : countDown }}</view>
  16. </view>
  17. <view class="tit" >
  18. 密碼
  19. </view>
  20. <input type="password" class="shuru" placeholder="請翰入密碼" v-model="email">
  21. <view class="tit">
  22. 確認密碼
  23. </view>
  24. <input type="password" class="shuru" placeholder="請翰入密碼" v-model="email">
  25. <view class="tit" >
  26. 邀請碼
  27. </view>
  28. <input type="text" class="shuru" placeholder="請翰入邀請碼" v-model="email">
  29. <!-- <view class="login_text">
  30. <view class="login_input flex">
  31. <view class="login_img"><image src="/static/icon/img03.png"></image></view>
  32. <view class="login_name"><input class="uni-input" v-model="phone" focus placeholder="请输入手机号" /></view>
  33. </view>
  34. <view class="login_input flex">
  35. <view class="login_img"><image src="/static/icon/img04.png"></image></view>
  36. <view class="login_name"><input class="uni-input" type="password" v-model="password" focus placeholder="请输入密码" /></view>
  37. </view>
  38. <view class="login_input flex">
  39. <view class="login_img"><image src="/static/icon/img04.png"></image></view>
  40. <view class="login_name"><input class="uni-input" type="password" v-model="repassword" focus placeholder="请重复输入密码" /></view>
  41. </view>
  42. <view class="login_input flex" style="display: none;">
  43. <view class="login_img"><image src="/static/icon/img07.png"></image></view>
  44. <view class="login_name"><input class="uni-input" type="text" v-model="invitation" focus placeholder="请输入邀请码" /></view>
  45. </view>
  46. <view class="login_input flex">
  47. <view class="login_img"><image src="/static/icon/img06.png"></image></view>
  48. <view class="login_name flex">
  49. <input class="uni-input width" v-model="code" focus placeholder="请输入验证码" />
  50. <view class="code" @click="verification">{{ countDown == 0 ? '验证码' : countDown }}</view>
  51. </view>
  52. </view>
  53. <view><button type="green" @click="register" class="uni-button uni-button-green">注册账号</button></view>
  54. <view><button class="uni-button uni-button-green uni-button-green-plain" type="green" plain="true" hover-class="none" @click="login">返回登录</button></view>
  55. </view> -->
  56. </view>
  57. </template>
  58. <script>
  59. import { register, verify } from '@/api/login.js';
  60. export default {
  61. data() {
  62. return {
  63. phone: '', //用户
  64. password: '', //密码
  65. repassword: '',
  66. invitation: '', //邀请码
  67. code: '', //验证码
  68. time: '', //保存倒计时对象
  69. countDown: 0 ,//倒计时
  70. };
  71. },
  72. onLoad() {
  73. // 获取扫码邀请人id
  74. this.invitation = uni.getStorageSync('spread')||'';
  75. },
  76. watch: {
  77. // 监听倒计时
  78. countDown(i) {
  79. if (i == 0) {
  80. clearInterval(this.time);
  81. }
  82. }
  83. },
  84. methods: {
  85. dl() {
  86. uni.navigateTo({
  87. url: '/pages/public/login'
  88. })
  89. },
  90. // 注册
  91. register() {
  92. let obj = this;
  93. if (obj.phone == '') {
  94. obj.$api.msg('请输入电话号码');
  95. return;
  96. }
  97. if (!/(^1[3|4|5|7|8][0-9]{9}$)/.test(this.phone)) {
  98. obj.$api.msg('请输入正确的手机号');
  99. return;
  100. }
  101. if (obj.password == '') {
  102. obj.$api.msg('请输入密码');
  103. return;
  104. }
  105. if (obj.repassword == '') {
  106. obj.$api.msg('请再次输入密码');
  107. return;
  108. }
  109. if (obj.repassword != obj.password) {
  110. obj.$api.msg('两次密码不正确');
  111. return;
  112. }
  113. // if ((obj.invitation = '')) {
  114. // obj.$api.msg('请输入邀请码');
  115. // return;
  116. // }
  117. // if (obj.code == '') {
  118. // obj.$api.msg('请输入验证码');
  119. // return;
  120. // }
  121. register({
  122. account: obj.phone, //账号
  123. // captcha: obj.code, //验证码
  124. password: obj.password ,//密码
  125. spread:this.invitation//上级推广人
  126. }).then(function(e) {
  127. uni.showToast({
  128. title:'注册成功',
  129. duration:2000,
  130. position:'top'
  131. });
  132. setTimeout(function () {
  133. uni.navigateTo({
  134. url: '/pages/public/login'
  135. });
  136. },1000)
  137. });
  138. //调用注册接口,成功跳转登录页
  139. },
  140. //发送验证码
  141. verification() {
  142. let obj = this;
  143. if (this.phone == '') {
  144. this.$api.msg('请输入电话号码');
  145. return;
  146. }
  147. if (this.phone.length < 11) {
  148. this.$api.msg('请输入正确的手机号');
  149. return;
  150. }
  151. // 判断是否在倒计时
  152. if (obj.countDown > 0) {
  153. return false;
  154. } else {
  155. obj.countDown = 60;
  156. obj.time = setInterval(() => {
  157. obj.countDown--;
  158. }, 1000);
  159. //调用验证码接口
  160. verify({
  161. phone: obj.phone,
  162. type: 'register'
  163. })
  164. .then(({ data }) => {})
  165. .catch(err => {
  166. console.log(err);
  167. });
  168. }
  169. },
  170. login() {
  171. //返回登录
  172. uni.navigateTo({
  173. url: '/pages/public/login'
  174. });
  175. }
  176. }
  177. };
  178. </script>
  179. <style lang="scss">
  180. page {
  181. height: 100%;
  182. background-color: #fff;
  183. font-size: 32rpx;
  184. }
  185. .container {
  186. width: 100%;
  187. height: 100%;
  188. background-size: 100%;
  189. }
  190. .shuru {
  191. display: block;
  192. background-color: #f5f5f5;
  193. width: 673rpx;
  194. height: 95rpx;
  195. margin: auto;
  196. padding-left: 30rpx;
  197. text-align: 95rpx;
  198. }
  199. .tit {
  200. padding:40rpx 48rpx 20rpx;
  201. }
  202. .gologin {
  203. width: 204rpx;
  204. height: 98rpx;
  205. line-height: 98rpx;
  206. background-color: #fcd535;
  207. text-align: center;
  208. border-radius: 20rpx;
  209. }
  210. .wjmm {
  211. color: #fcd535;
  212. }
  213. .yzm {
  214. width: 400rpx;
  215. height: 95rpx;
  216. }
  217. .yzmbtn {
  218. width: 234rpx;
  219. height: 95rpx;
  220. background-color: #f5f5f5;
  221. text-align: center;
  222. line-height: 95rpx;
  223. color: #fcd535;
  224. }
  225. </style>