register.vue 6.2 KB

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