register.vue 6.4 KB

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