register.vue 6.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317
  1. <template>
  2. <view class="container">
  3. <view class="container_text" >
  4. <image class="banner-img" src="../../users/static/beijing.jpg" 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="../../users/static/phone.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="../../users/static/code.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="../../users/static/yzm.png"></image></view>
  18. <view class="login_name"><input class="uni-input" type="text" v-model="invitation" focus placeholder="请输入邀请码" /></view>
  19. </view>
  20. <view class="login_input flex">
  21. <view class="login_img"><image src="../../users/static/yzm.png"></image></view>
  22. <view class="login_name flex">
  23. <input class="uni-input width" v-model="code" focus placeholder="请输入验证码" />
  24. <view class="code" @click="verification">{{ countDown == 0 ? '验证码' : countDown }}</view>
  25. </view>
  26. </view>
  27. <view><button type="green" @click="register" class="uni-button uni-button-yello">注册</button></view>
  28. <view class="choose">
  29. <view class="reg" @click="forget">忘记密码</view>
  30. <view class="xian">|</view>
  31. <view class="zhuce" @click="deng">手机登录</view>
  32. </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. nickname: '', // 昵称
  49. };
  50. },
  51. onLoad() {
  52. this.invitation = uni.getStorageSync('spread')||'';
  53. console.log(this.invitation);
  54. },
  55. watch: {
  56. // 监听倒计时
  57. countDown(i) {
  58. if (i == 0) {
  59. clearInterval(this.time);
  60. }
  61. }
  62. },
  63. methods: {
  64. // 注册
  65. register() {
  66. let obj = this;
  67. if (obj.phone == '') {
  68. obj.$api.msg('请输入电话号码');
  69. return;
  70. }
  71. if (obj.nickname == '') {
  72. obj.$api.msg('请输入昵称');
  73. return;
  74. }
  75. if (!/(^1[1|2|3|4|5|6|7|8|9][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. nickname:obj.nickname,
  101. account: obj.phone, //账号
  102. captcha: obj.code, //验证码
  103. password: obj.password ,//密码
  104. spread:obj.invitation//上级推广人
  105. }).then(function(e) {
  106. uni.showToast({
  107. title:'注册成功',
  108. duration:2000,
  109. position:'top'
  110. });
  111. setTimeout(function () {
  112. uni.navigateTo({
  113. url: '/pages/public/login'
  114. });
  115. },1000)
  116. });
  117. //调用注册接口,成功跳转登录页
  118. },
  119. // 忘记密码
  120. forget() {
  121. uni.navigateTo({
  122. url: "/pages/users/login/forget"
  123. })
  124. },
  125. deng() {
  126. uni.navigateTo({
  127. url: "/pages/users/login/index"
  128. })
  129. },
  130. //发送验证码
  131. verification() {
  132. let obj = this;
  133. if (this.phone == '') {
  134. this.$api.msg('请输入电话号码');
  135. return;
  136. }
  137. if (this.phone.length < 11) {
  138. this.$api.msg('请输入正确的手机号');
  139. return;
  140. }
  141. // 判断是否在倒计时
  142. if (obj.countDown > 0) {
  143. return false;
  144. } else {
  145. obj.countDown = 60;
  146. obj.time = setInterval(() => {
  147. obj.countDown--;
  148. }, 1000);
  149. //调用验证码接口
  150. verify({
  151. phone: obj.phone,
  152. type: 'register'
  153. })
  154. .then(({ data }) => {})
  155. .catch(err => {
  156. console.log(err);
  157. });
  158. }
  159. },
  160. login() {
  161. //返回登录
  162. // uni.navigateTo({
  163. // url: '/pages/public/login'
  164. // });
  165. }
  166. }
  167. };
  168. </script>
  169. <style lang="scss">
  170. page {
  171. height: 100%;
  172. }
  173. .container {
  174. width: 100%;
  175. height: 100%;
  176. background-size: 100%;
  177. }
  178. .container_text {
  179. width: 100%;
  180. height: 500rpx;
  181. top: 0rpx;
  182. .banner-img {
  183. width: 100%;
  184. height: 100%;
  185. }
  186. }
  187. .login_text {
  188. // margin: auto 30rpx;
  189. position: relative;
  190. padding: 100rpx 102rpx;
  191. background-color: #ffffff;
  192. margin-top: -20rpx;
  193. border-radius: 20rpx;
  194. .login_input {
  195. border-bottom: 1px solid #f0f0f0;
  196. margin-bottom: 65rpx;
  197. .login_img image {
  198. height: 35rpx;
  199. width: 29rpx;
  200. margin-right: 20rpx;
  201. }
  202. .uni-input {
  203. text-align: left;
  204. width: 470rpx;
  205. font-size: 28rpx !important;
  206. }
  207. .login_name {
  208. color: #333333;
  209. }
  210. }
  211. .other {
  212. margin-top: 60rpx;
  213. .fenge {
  214. width: 30%;
  215. height: 2rpx;
  216. background-color: #eeeeee;
  217. }
  218. .qita {
  219. font-size: 28rpx;
  220. color: #999999;
  221. }
  222. }
  223. .weixin {
  224. width: 75rpx;
  225. height: 75rpx;
  226. margin: 25rpx auto;
  227. }
  228. .weixin image {
  229. width: 100%;
  230. height: 100%;
  231. }
  232. .weixin_text {
  233. text-align: center;
  234. font-size: 28rpx;
  235. color: #999999;
  236. }
  237. .forget {
  238. font-size: 28rpx;
  239. width: 100%;
  240. text-align: right;
  241. color: #999999;
  242. }
  243. .uni-button-yello {
  244. color: #ffffff;
  245. // margin: 40rpx 10rpx;
  246. // border-radius: 50rpx;
  247. background: linear-gradient(-30deg, #FF3106, #FF8F3B);
  248. border-radius: 10rpx;
  249. }
  250. .uni-button {
  251. height: 85rpx;
  252. line-height: 85rpx;
  253. }
  254. }
  255. .loginTitle {
  256. position: absolute;
  257. top: 250rpx;
  258. width: 100%;
  259. text-align: center;
  260. color: white;
  261. font-size: 40rpx;
  262. }
  263. .forget {
  264. width: 100rpx;
  265. font-size: 24rpx;
  266. color: #ffffff;
  267. margin: 0px auto;
  268. border-bottom: 1px solid #ffffff;
  269. }
  270. .width {
  271. width: 325rpx !important;
  272. }
  273. .code {
  274. color: #ff762d;
  275. font-size: 23rpx;
  276. border-left: 1px solid #eeeeee;
  277. width: 150rpx;
  278. flex-shrink: 0;
  279. text-align: center;
  280. }
  281. .choose {
  282. display: flex;
  283. justify-content: center;
  284. margin-top: 15rpx;
  285. .reg {
  286. font-size: 28rpx;
  287. font-weight: 500;
  288. color: #ff8d3a;
  289. }
  290. .xian {
  291. color: #FF4C4C;
  292. padding-left: 10rpx;
  293. }
  294. .zhuce {
  295. font-size: 28rpx;
  296. font-weight: 500;
  297. color: #FF4C4C;
  298. padding-left: 10rpx;
  299. }
  300. }
  301. uni-button {
  302. height: 80rpx !important;
  303. line-height: 80rpx !important;
  304. }
  305. </style>