register.vue 6.3 KB

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