register.vue 6.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288
  1. <template>
  2. <view class="container">
  3. <view class="container_text">
  4. <image class="banner-img" src="/static/img/img001.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/img03.png"></image></view>
  14. <view class="login_name"><input class="uni-input" v-model="username" 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="password" focus placeholder="请输入密码" /></view>
  19. </view>
  20. <view class="login_input flex">
  21. <view class="login_img"><image src="/static/icon/img04.png"></image></view>
  22. <view class="login_name"><input class="uni-input" type="password" v-model="repassword" focus placeholder="请重复输入密码" /></view>
  23. </view>
  24. <view class="login_input flex" style="display: none;">
  25. <view class="login_img"><image src="/static/icon/img07.png"></image></view>
  26. <view class="login_name"><input class="uni-input" type="text" v-model="invitation" focus placeholder="请输入邀请码" /></view>
  27. </view>
  28. <!-- <view class="login_input flex">
  29. <view class="login_img"><image src="/static/icon/img06.png"></image></view>
  30. <view class="login_name flex">
  31. <input class="uni-input width" v-model="code" focus placeholder="请输入验证码" />
  32. <view class="code" @click="verification">{{ countDown == 0 ? '验证码' : countDown }}</view>
  33. </view>
  34. </view> -->
  35. <view><button type="green" @click="register" class="uni-button uni-button-green">注册账号</button></view>
  36. <view><button class="uni-button uni-button-green uni-button-green-plain" type="green" plain="true" hover-class="none" @click="login">返回登录</button></view>
  37. </view>
  38. </view>
  39. </template>
  40. <script>
  41. import { register, verify } from '@/api/login.js';
  42. export default {
  43. data() {
  44. return {
  45. username:'',
  46. phone: '', //用户
  47. password: '', //密码
  48. repassword: '',
  49. invitation: '', //邀请码
  50. code: '', //验证码
  51. time: '', //保存倒计时对象
  52. countDown: 0 ,//倒计时
  53. };
  54. },
  55. onLoad() {
  56. // 获取扫码邀请人id
  57. this.invitation = uni.getStorageSync('spread')||'';
  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.username == '') {
  80. obj.$api.msg('请输入用户名');
  81. return;
  82. }
  83. if (obj.password == '') {
  84. obj.$api.msg('请输入密码');
  85. return;
  86. }
  87. if (obj.repassword == '') {
  88. obj.$api.msg('请再次输入密码');
  89. return;
  90. }
  91. if (obj.repassword != obj.password) {
  92. obj.$api.msg('两次密码不正确');
  93. return;
  94. }
  95. // if (obj.code == '') {
  96. // obj.$api.msg('请输入验证码');
  97. // return;
  98. // }
  99. register({
  100. username:obj.username,
  101. mobile: obj.phone, //账号
  102. // code: obj.code, //验证码
  103. password: obj.password ,//密码
  104. // confirm_password: obj.repassword ,//密码
  105. }).then(function(e) {
  106. uni.showToast({
  107. title:'注册成功',
  108. duration:2000,
  109. position:'top',
  110. icon:'none'
  111. });
  112. setTimeout(function () {
  113. uni.navigateTo({
  114. url: '/pages/public/login'
  115. });
  116. },1000)
  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. background: #FFFFFF;
  163. .container {
  164. width: 100%;
  165. height: 100%;
  166. }
  167. }
  168. .container_text {
  169. width: 100%;
  170. height: 500rpx;
  171. top: 0rpx;
  172. .banner-img {
  173. width: 100%;
  174. height: 100%;
  175. }
  176. }
  177. .login_text {
  178. margin: auto 30rpx;
  179. position: relative;
  180. padding: 100rpx 102rpx;
  181. background-color: #ffffff;
  182. margin-top: -180rpx;
  183. border-radius: 20rpx;
  184. .login_input {
  185. border-bottom: 1px solid #f0f0f0;
  186. margin-bottom: 65rpx;
  187. .login_img image {
  188. height: 35rpx;
  189. width: 29rpx;
  190. margin-right: 20rpx;
  191. }
  192. .uni-input {
  193. text-align: left;
  194. width: 470rpx;
  195. font-size: 28rpx !important;
  196. }
  197. .login_name {
  198. color: #333333;
  199. }
  200. }
  201. .other {
  202. margin-top: 60rpx;
  203. .fenge {
  204. width: 30%;
  205. height: 2rpx;
  206. background-color: #eeeeee;
  207. }
  208. .qita {
  209. font-size: 28rpx;
  210. color: #999999;
  211. }
  212. }
  213. .weixin {
  214. width: 75rpx;
  215. height: 75rpx;
  216. margin: 25rpx auto;
  217. }
  218. .weixin image {
  219. width: 100%;
  220. height: 100%;
  221. }
  222. .weixin_text {
  223. text-align: center;
  224. font-size: 28rpx;
  225. color: #999999;
  226. }
  227. .forget {
  228. font-size: 28rpx;
  229. width: 100%;
  230. text-align: right;
  231. color: #999999;
  232. }
  233. .uni-button-green {
  234. color: #ffffff;
  235. background-color: #5dbc7c;
  236. margin: 40rpx 10rpx;
  237. border-radius: 50rpx;
  238. }
  239. .uni-button-green-plain {
  240. border: 1px solid #5dbc7c;
  241. margin: 40rpx 10rpx;
  242. border-radius: 50rpx;
  243. color: #5dbc7c;
  244. background-color: #ffffff;
  245. }
  246. .uni-button {
  247. height: 85rpx;
  248. line-height: 85rpx;
  249. }
  250. }
  251. .loginTitle {
  252. position: absolute;
  253. top: 250rpx;
  254. width: 100%;
  255. text-align: center;
  256. color: white;
  257. font-size: 40rpx;
  258. }
  259. .forget {
  260. width: 100rpx;
  261. font-size: 24rpx;
  262. color: #ffffff;
  263. margin: 0px auto;
  264. border-bottom: 1px solid #ffffff;
  265. }
  266. .width {
  267. width: 325rpx !important;
  268. }
  269. .code {
  270. color: #5dbc7c;
  271. font-size: 23rpx;
  272. border-left: 1px solid #eeeeee;
  273. width: 150rpx;
  274. flex-shrink: 0;
  275. text-align: center;
  276. }
  277. uni-button {
  278. height: 80rpx !important;
  279. line-height: 80rpx !important;
  280. }
  281. </style>