register.vue 6.0 KB

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