register.vue 6.1 KB

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