register.vue 6.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292
  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>
  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/img04.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="/static/icon/img04.png"></image></view>
  18. <view class="login_name"><input class="uni-input" type="password" v-model="repassword" 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="payment_pas" focus placeholder="请输入支付密码" /></view>
  23. </view>
  24. <view class="login_input flex">
  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. phone: '', //用户
  46. password: '', //密码
  47. repassword: '',
  48. invitation: '', //邀请码
  49. code: '', //验证码
  50. time: '', //保存倒计时对象
  51. countDown: 0 ,//倒计时
  52. payment_pas: ''//交易密码
  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.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.payment_pas == '') {
  92. obj.$api.msg('请输入支付密码');
  93. return;
  94. }
  95. if (obj.invitation == '') {
  96. obj.$api.msg('请输入邀请码');
  97. return;
  98. }
  99. // if (obj.code == '') {
  100. // obj.$api.msg('请输入验证码');
  101. // return;
  102. // }
  103. register({
  104. account: obj.phone, //账号
  105. captcha: obj.code, //验证码
  106. password: obj.password ,//密码
  107. spread: obj.invitation,//上级推广人
  108. payment_pas: obj.payment_pas
  109. // pas: obj.payment_pas
  110. }).then(function(e) {
  111. uni.showToast({
  112. title:'注册成功',
  113. duration:2000,
  114. position:'top'
  115. });
  116. setTimeout(function () {
  117. uni.navigateTo({
  118. url: '/pages/public/login'
  119. });
  120. },1000)
  121. });
  122. //调用注册接口,成功跳转登录页
  123. },
  124. //发送验证码
  125. verification() {
  126. let obj = this;
  127. if (this.phone == '') {
  128. this.$api.msg('请输入电话号码');
  129. return;
  130. }
  131. if (this.phone.length < 11) {
  132. this.$api.msg('请输入正确的手机号');
  133. return;
  134. }
  135. // 判断是否在倒计时
  136. if (obj.countDown > 0) {
  137. return false;
  138. } else {
  139. obj.countDown = 60;
  140. obj.time = setInterval(() => {
  141. obj.countDown--;
  142. }, 1000);
  143. //调用验证码接口
  144. verify({
  145. phone: obj.phone,
  146. type: 'register'
  147. })
  148. .then(({ data }) => {})
  149. .catch(err => {
  150. console.log(err);
  151. });
  152. }
  153. },
  154. login() {
  155. //返回登录
  156. uni.navigateTo({
  157. url: '/pages/public/login'
  158. });
  159. }
  160. }
  161. };
  162. </script>
  163. <style lang="scss">
  164. page {
  165. height: 100%;
  166. }
  167. .container {
  168. width: 100%;
  169. height: 100%;
  170. background-size: 100%;
  171. }
  172. .container_text {
  173. width: 100%;
  174. height: 500rpx;
  175. top: 0rpx;
  176. .banner-img {
  177. width: 100%;
  178. height: 100%;
  179. }
  180. }
  181. .login_text {
  182. margin: auto 30rpx;
  183. position: relative;
  184. padding: 100rpx 102rpx;
  185. background-color: #ffffff;
  186. margin-top: -180rpx;
  187. border-radius: 20rpx;
  188. .login_input {
  189. border-bottom: 1px solid #f0f0f0;
  190. margin-bottom: 65rpx;
  191. .login_img image {
  192. height: 35rpx;
  193. width: 29rpx;
  194. margin-right: 20rpx;
  195. }
  196. .uni-input {
  197. text-align: left;
  198. width: 470rpx;
  199. font-size: 28rpx !important;
  200. }
  201. .login_name {
  202. color: #333333;
  203. }
  204. }
  205. .other {
  206. margin-top: 60rpx;
  207. .fenge {
  208. width: 30%;
  209. height: 2rpx;
  210. background-color: #eeeeee;
  211. }
  212. .qita {
  213. font-size: 28rpx;
  214. color: #999999;
  215. }
  216. }
  217. .weixin {
  218. width: 75rpx;
  219. height: 75rpx;
  220. margin: 25rpx auto;
  221. }
  222. .weixin image {
  223. width: 100%;
  224. height: 100%;
  225. }
  226. .weixin_text {
  227. text-align: center;
  228. font-size: 28rpx;
  229. color: #999999;
  230. }
  231. .forget {
  232. font-size: 28rpx;
  233. width: 100%;
  234. text-align: right;
  235. color: #999999;
  236. }
  237. .uni-button-green {
  238. color: #ffffff;
  239. background-color: #5dbc7c;
  240. margin: 40rpx 10rpx;
  241. border-radius: 50rpx;
  242. }
  243. .uni-button-green-plain {
  244. border: 1px solid #5dbc7c;
  245. margin: 40rpx 10rpx;
  246. border-radius: 50rpx;
  247. color: #5dbc7c;
  248. background-color: #ffffff;
  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: #5dbc7c;
  275. font-size: 23rpx;
  276. border-left: 1px solid #eeeeee;
  277. width: 150rpx;
  278. flex-shrink: 0;
  279. text-align: center;
  280. }
  281. uni-button {
  282. height: 80rpx !important;
  283. line-height: 80rpx !important;
  284. }
  285. </style>