register.vue 6.7 KB

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