register.vue 6.3 KB

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