register.vue 6.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295
  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="title-img"><image class="title-image" src="../../static/img/login-title.png" mode=""></image></view>
  6. </view>
  7. <view class="loginTitle"><text>欢迎注册易趣CBB</text></view>
  8. <view class="login_text">
  9. <view class="login_input flex">
  10. <view class="login_img"><image src="/static/icon/img03.png"></image></view>
  11. <view class="login_name"><input class="uni-input" v-model="phone" focus placeholder="请输入手机号" /></view>
  12. </view>
  13. <view class="login_input flex">
  14. <view class="login_img"><image src="/static/icon/img04.png"></image></view>
  15. <view class="login_name"><input class="uni-input" type="password" v-model="password" focus placeholder="请输入密码" /></view>
  16. </view>
  17. <view class="login_input flex">
  18. <view class="login_img"><image src="/static/icon/img04.png"></image></view>
  19. <view class="login_name"><input class="uni-input" type="password" v-model="repassword" focus placeholder="请重复输入密码" /></view>
  20. </view>
  21. <view class="login_input flex">
  22. <view class="login_img"><image src="/static/icon/img07.png"></image></view>
  23. <view class="login_name"><input class="uni-input" type="text" v-model="invitation" focus placeholder="请输入邀请码" /></view>
  24. </view>
  25. <view class="login_input flex">
  26. <view class="login_img"><image src="/static/icon/img06.png"></image></view>
  27. <view class="login_name flex">
  28. <input class="uni-input width" v-model="code" focus placeholder="请输入验证码" />
  29. <view class="code" @click="verification">{{ countDown == 0 ? '验证码' : countDown }}</view>
  30. </view>
  31. </view>
  32. <view><button type="green" @click="register" class="uni-button uni-button-green">注册账号</button></view>
  33. <view><button class="uni-button uni-button-green uni-button-green-plain" type="green" plain="true" hover-class="none" @click="login">返回登录</button></view>
  34. </view>
  35. </view>
  36. </template>
  37. <script>
  38. import { register, verify } from '@/api/login.js';
  39. export default {
  40. data() {
  41. return {
  42. phone: '', //用户
  43. password: '', //密码
  44. repassword: '',
  45. invitation: '', //邀请码
  46. code: '', //验证码
  47. time: '', //保存倒计时对象
  48. countDown: 0 //倒计时
  49. };
  50. },
  51. onLoad(options) {
  52. // 获取扫码邀请人id
  53. this.invitation = uni.getStorageSync('spread') || '';
  54. if (options.spread) {
  55. this.invitation = options.spread;
  56. }
  57. },
  58. watch: {
  59. // 监听倒计时
  60. countDown(i) {
  61. if (i == 0) {
  62. clearInterval(this.time);
  63. }
  64. }
  65. },
  66. methods: {
  67. // 注册
  68. register() {
  69. let obj = this;
  70. if (obj.phone == '') {
  71. obj.$api.msg('请输入电话号码');
  72. return;
  73. }
  74. if (!/(^1[2|3|4|5|6|7|8|9][0-9]{9}$)/.test(this.phone)) {
  75. obj.$api.msg('请输入正确的手机号');
  76. return;
  77. }
  78. if (obj.password == '') {
  79. obj.$api.msg('请输入密码');
  80. return;
  81. }
  82. if (obj.repassword == '') {
  83. obj.$api.msg('请再次输入密码');
  84. return;
  85. }
  86. if (obj.repassword != obj.password) {
  87. obj.$api.msg('两次密码不正确');
  88. return;
  89. }
  90. // if ((obj.invitation = '')) {
  91. // obj.$api.msg('请输入邀请码');
  92. // return;
  93. // }
  94. // if (obj.code == '') {
  95. // obj.$api.msg('请输入验证码');
  96. // return;
  97. // }
  98. register({
  99. account: obj.phone, //账号
  100. captcha: obj.code, //验证码
  101. password: obj.password, //密码
  102. spread: this.invitation //上级推广人
  103. }).then(function(e) {
  104. uni.showToast({
  105. title: '注册成功',
  106. duration: 2000,
  107. position: 'top'
  108. });
  109. setTimeout(function() {
  110. uni.navigateTo({
  111. url: '/pages/public/login'
  112. });
  113. }, 1000);
  114. });
  115. //调用注册接口,成功跳转登录页
  116. },
  117. //发送验证码
  118. verification() {
  119. let obj = this;
  120. if (this.phone == '') {
  121. this.$api.msg('请输入电话号码');
  122. return;
  123. }
  124. if (this.phone.length < 11) {
  125. this.$api.msg('请输入正确的手机号');
  126. return;
  127. }
  128. // 判断是否在倒计时
  129. if (obj.countDown > 0) {
  130. return false;
  131. } else {
  132. obj.countDown = 60;
  133. obj.time = setInterval(() => {
  134. obj.countDown--;
  135. }, 1000);
  136. //调用验证码接口
  137. verify({
  138. phone: obj.phone,
  139. type: 'register'
  140. })
  141. .then(({ data }) => {})
  142. .catch(err => {
  143. console.log(err);
  144. });
  145. }
  146. },
  147. login() {
  148. //返回登录
  149. uni.navigateTo({
  150. url: '/pages/public/login'
  151. });
  152. }
  153. }
  154. };
  155. </script>
  156. <style lang="scss">
  157. page {
  158. height: 100%;
  159. }
  160. .container {
  161. width: 100%;
  162. height: 100%;
  163. background-size: 100%;
  164. }
  165. .container_text {
  166. position: relative;
  167. width: 100%;
  168. height: 500rpx;
  169. top: 0rpx;
  170. .banner-img {
  171. width: 100%;
  172. height: 100%;
  173. }
  174. .title-img {
  175. position: absolute;
  176. left: 50%;
  177. top: 100rpx;
  178. margin-left: -130rpx;
  179. width: 260rpx;
  180. height: 156rpx;
  181. .title-image {
  182. width: 260rpx;
  183. height: 156rpx;
  184. }
  185. }
  186. }
  187. .login_text {
  188. margin: -100rpx 0 0;
  189. position: relative;
  190. padding: 100rpx 102rpx;
  191. background-color: #ffffff;
  192. border-top-left-radius: 40rpx;
  193. border-top-right-radius: 40rpx;
  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-green {
  244. color: #ffffff;
  245. background-color: #db292b;
  246. margin: 40rpx 10rpx;
  247. border-radius: 50rpx;
  248. }
  249. .uni-button-green-plain {
  250. border: 1px solid #db292b;
  251. margin: 40rpx 10rpx;
  252. border-radius: 50rpx;
  253. color: #db292b;
  254. background-color: #ffffff;
  255. }
  256. .uni-button {
  257. height: 85rpx;
  258. line-height: 85rpx;
  259. }
  260. }
  261. .loginTitle {
  262. position: absolute;
  263. top: 270rpx;
  264. width: 100%;
  265. text-align: center;
  266. color: white;
  267. font-size: 40rpx;
  268. }
  269. .forget {
  270. width: 100rpx;
  271. font-size: 24rpx;
  272. color: #ffffff;
  273. margin: 0px auto;
  274. border-bottom: 1px solid #ffffff;
  275. }
  276. .width {
  277. width: 325rpx !important;
  278. }
  279. .code {
  280. color: #db292b;
  281. font-size: 23rpx;
  282. border-left: 1px solid #eeeeee;
  283. width: 150rpx;
  284. flex-shrink: 0;
  285. text-align: center;
  286. }
  287. uni-button {
  288. height: 80rpx !important;
  289. line-height: 80rpx !important;
  290. }
  291. </style>