register.vue 6.4 KB

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