register.vue 6.5 KB

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