register.vue 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293
  1. <template>
  2. <view class="content">
  3. <view class="title-img">
  4. <image src="../../static/img/logo.png" mode=""></image>
  5. </view>
  6. <view class="title-LOGO">
  7. 艺绘
  8. </view>
  9. <view class="bg">
  10. <image src="../../static/img/pbbg.png" mode=""></image>
  11. </view>
  12. <view class="register-content">
  13. <view class="res-box">
  14. <image src="../../static/img/pb03.png" mode=""></image>
  15. <view class="input-box">
  16. <input class="input" type="number" v-model="phone" placeholder="请输入手机号">
  17. </view>
  18. </view>
  19. <view class="res-box">
  20. <image src="../../static/img/pb02.png" mode=""></image>
  21. <view class="input-box">
  22. <input class="input" type="password" v-model="loginPass" placeholder="请输入密码">
  23. </view>
  24. </view>
  25. <view class="res-box">
  26. <image src="../../static/img/pb01.png" mode=""></image>
  27. <view class="input-box">
  28. <input class="input" type="number" v-model="code" placeholder="请输入验证码">
  29. <view class="time" @click="getYzm" v-show="isHq">
  30. 获取验证码
  31. </view>
  32. <view class="djs" v-show="!isHq">
  33. {{countDown}}
  34. </view>
  35. </view>
  36. </view>
  37. </view>
  38. <view class="button" @click="registerTo()">
  39. 注册
  40. </view>
  41. <view class="tishi">
  42. <view class="for-pass" @click="getNavto('/pages/set/changePass')">
  43. 忘记密码
  44. </view>
  45. <view class="ss">
  46. </view>
  47. <view class="for-phone" @click="getNavto('/pages/public/login')" >
  48. 账号登录
  49. </view>
  50. </view>
  51. </view>
  52. </template>
  53. <script>
  54. import {
  55. register,
  56. verify
  57. } from '@/api/login.js';
  58. export default {
  59. data() {
  60. return {
  61. isHq: true,
  62. phone: '', //用户
  63. loginPass: '', //密码
  64. payPass: '',
  65. invitation: '', //邀请码
  66. code: '', //验证码
  67. time: '', //保存倒计时对象
  68. countDown: 60 //倒计时
  69. };
  70. },
  71. onLoad() {
  72. // 获取扫码邀请人id
  73. this.invitation = uni.getStorageSync('spread') || '';
  74. },
  75. methods: {
  76. //注册
  77. registerTo(){
  78. let obj= this
  79. let jiaoyan = /^1(3[0-9]|4[01456879]|5[0-35-9]|6[2567]|7[0-8]|8[0-9]|9[0-35-9])\d{8}$/
  80. if (!jiaoyan.test(obj.phone)) {
  81. this.$api.msg('请输入正确的手机号!')
  82. return
  83. }else if(obj.phone == ''){
  84. this.$api.msg('请输入手机号')
  85. return
  86. }else if(obj.loginPass==''){
  87. this.$api.msg('请输入密码')
  88. return
  89. }else if(obj.code == ''){
  90. this.$api.msg('请输入验证码')
  91. return
  92. }else if(obj.code.length!=6){
  93. this.$api.msg('请输入正确的验证码')
  94. return
  95. }
  96. else{
  97. register({
  98. account:obj.phone,
  99. captcha:obj.code,
  100. password:obj.loginPass,
  101. spread:obj.invitation
  102. }).then(res=>{
  103. console.log(res,'res');
  104. this.$api.msg('注册成功')
  105. setTimeout(function(){
  106. uni.navigateTo({
  107. url:'/pages/public/login'
  108. })
  109. },1000)
  110. })
  111. }
  112. },
  113. //跳转详情
  114. getNavto(url){
  115. uni.navigateTo({
  116. url:url
  117. })
  118. },
  119. //获取验证码
  120. getYzm() {
  121. let obj = this
  122. let jiaoyan = /^1(3[0-9]|4[01456879]|5[0-35-9]|6[2567]|7[0-8]|8[0-9]|9[0-35-9])\d{8}$/
  123. if (!jiaoyan.test(obj.phone)) {
  124. this.$api.msg('请输入正确的手机号!')
  125. return
  126. }
  127. let setTime = setInterval(
  128. function() {
  129. obj.isHq = false
  130. obj.countDown--;
  131. if (obj.countDown == 0) {
  132. clearInterval(setTime)
  133. // let setOut = setTimeout(() => {
  134. obj.isHq = true
  135. obj.countDown=10;
  136. // }, 1000)
  137. }
  138. }, 1000)
  139. //调用验证码接口
  140. verify({
  141. phone: obj.phone,
  142. type: 'register'
  143. })
  144. .then(({ data }) => {
  145. console.log(data,'data');
  146. })
  147. .catch(err => {
  148. console.log(err);
  149. });
  150. }
  151. }
  152. };
  153. </script>
  154. <style lang="scss">
  155. page,
  156. .content {
  157. min-height: 100%;
  158. background-color: #181818;
  159. .bg {
  160. width: 750rpx;
  161. height: 200rpx;
  162. image {
  163. width: 100%;
  164. height: 100%;
  165. }
  166. }
  167. .title-img {
  168. margin: 70rpx auto 0;
  169. width: 161px;
  170. height: 161px;
  171. border-radius: 50%;
  172. overflow: hidden;
  173. image {
  174. width: 100%;
  175. height: 100%;
  176. }
  177. }
  178. .title-LOGO {
  179. text-align: center;
  180. margin: 30rpx;
  181. font-size: 36px;
  182. font-family: PingFang SC;
  183. font-weight: 400;
  184. color: #FFFFFF;
  185. }
  186. .register-content {
  187. .res-box {
  188. height: 110rpx;
  189. width: 600rpx;
  190. align-items: center;
  191. display: flex;
  192. margin: 0 75rpx;
  193. border-bottom: #f3f3f3 solid 2rpx;
  194. image {
  195. width: 31rpx;
  196. height: 40rpx;
  197. }
  198. .input-box {
  199. margin-left: 40rpx;
  200. display: flex;
  201. justify-content: space-between;
  202. align-items: center;
  203. .input {
  204. color: #9977F6;
  205. // line-height: 40rpx;
  206. }
  207. .time {
  208. width: 150rpx;
  209. height: 50rpx;
  210. line-height: 50rpx;
  211. text-align: center;
  212. border-radius: 10rpx;
  213. color: #FFFFFF;
  214. background: linear-gradient(270deg, #6E8DF7, #9977F6);
  215. }
  216. .djs {
  217. margin-left: 100rpx;
  218. width: 50rpx;
  219. height: 50rpx;
  220. line-height: 50rpx;
  221. text-align: center;
  222. border-radius: 10rpx;
  223. color: #FFFFFF;
  224. background: linear-gradient(270deg, #6E8DF7, #9977F6);
  225. }
  226. }
  227. }
  228. }
  229. .button {
  230. margin: 40rpx auto;
  231. text-align: center;
  232. width: 604rpx;
  233. height: 90rpx;
  234. background: linear-gradient(270deg, #6E8DF7, #9977F6);
  235. border-radius: 10rpx;
  236. font-size: 34rpx;
  237. font-weight: 500;
  238. color: #FFFFFF;
  239. line-height: 90rpx;
  240. }
  241. .tishi {
  242. display: flex;
  243. align-items: center;
  244. justify-content: center;
  245. .for-pass {
  246. font-size: 28rpx;
  247. font-weight: 500;
  248. color: #FFFFFF;
  249. }
  250. .ss {
  251. height: 26rpx;
  252. width: 3rpx;
  253. background-color: #f3f3f3;
  254. margin: 0 10rpx;
  255. }
  256. .for-phone {
  257. font-size: 28rpx;
  258. font-weight: 500;
  259. color: #FFFFFF;
  260. }
  261. }
  262. }
  263. </style>