register.vue 6.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291
  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" 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. 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. }).then(function(e) {
  110. uni.showToast({
  111. title:'注册成功',
  112. duration:2000,
  113. position:'top'
  114. });
  115. setTimeout(function () {
  116. uni.navigateTo({
  117. url: '/pages/public/login'
  118. });
  119. },1000)
  120. });
  121. //调用注册接口,成功跳转登录页
  122. },
  123. //发送验证码
  124. verification() {
  125. let obj = this;
  126. if (this.phone == '') {
  127. this.$api.msg('请输入电话号码');
  128. return;
  129. }
  130. if (this.phone.length < 11) {
  131. this.$api.msg('请输入正确的手机号');
  132. return;
  133. }
  134. // 判断是否在倒计时
  135. if (obj.countDown > 0) {
  136. return false;
  137. } else {
  138. obj.countDown = 60;
  139. obj.time = setInterval(() => {
  140. obj.countDown--;
  141. }, 1000);
  142. //调用验证码接口
  143. verify({
  144. phone: obj.phone,
  145. type: 'register'
  146. })
  147. .then(({ data }) => {})
  148. .catch(err => {
  149. console.log(err);
  150. });
  151. }
  152. },
  153. login() {
  154. //返回登录
  155. uni.navigateTo({
  156. url: '/pages/public/login'
  157. });
  158. }
  159. }
  160. };
  161. </script>
  162. <style lang="scss">
  163. page {
  164. height: 100%;
  165. }
  166. .container {
  167. width: 100%;
  168. height: 100%;
  169. background-size: 100%;
  170. }
  171. .container_text {
  172. width: 100%;
  173. height: 500rpx;
  174. top: 0rpx;
  175. .banner-img {
  176. width: 100%;
  177. height: 100%;
  178. }
  179. }
  180. .login_text {
  181. margin: auto 30rpx;
  182. position: relative;
  183. padding: 100rpx 102rpx;
  184. background-color: #ffffff;
  185. margin-top: -180rpx;
  186. border-radius: 20rpx;
  187. .login_input {
  188. border-bottom: 1px solid #f0f0f0;
  189. margin-bottom: 65rpx;
  190. .login_img image {
  191. height: 35rpx;
  192. width: 29rpx;
  193. margin-right: 20rpx;
  194. }
  195. .uni-input {
  196. text-align: left;
  197. width: 470rpx;
  198. font-size: 28rpx !important;
  199. }
  200. .login_name {
  201. color: #333333;
  202. }
  203. }
  204. .other {
  205. margin-top: 60rpx;
  206. .fenge {
  207. width: 30%;
  208. height: 2rpx;
  209. background-color: #eeeeee;
  210. }
  211. .qita {
  212. font-size: 28rpx;
  213. color: #999999;
  214. }
  215. }
  216. .weixin {
  217. width: 75rpx;
  218. height: 75rpx;
  219. margin: 25rpx auto;
  220. }
  221. .weixin image {
  222. width: 100%;
  223. height: 100%;
  224. }
  225. .weixin_text {
  226. text-align: center;
  227. font-size: 28rpx;
  228. color: #999999;
  229. }
  230. .forget {
  231. font-size: 28rpx;
  232. width: 100%;
  233. text-align: right;
  234. color: #999999;
  235. }
  236. .uni-button-green {
  237. color: #ffffff;
  238. background-color: #5dbc7c;
  239. margin: 40rpx 10rpx;
  240. border-radius: 50rpx;
  241. }
  242. .uni-button-green-plain {
  243. border: 1px solid #5dbc7c;
  244. margin: 40rpx 10rpx;
  245. border-radius: 50rpx;
  246. color: #5dbc7c;
  247. background-color: #ffffff;
  248. }
  249. .uni-button {
  250. height: 85rpx;
  251. line-height: 85rpx;
  252. }
  253. }
  254. .loginTitle {
  255. position: absolute;
  256. top: 250rpx;
  257. width: 100%;
  258. text-align: center;
  259. color: white;
  260. font-size: 40rpx;
  261. }
  262. .forget {
  263. width: 100rpx;
  264. font-size: 24rpx;
  265. color: #ffffff;
  266. margin: 0px auto;
  267. border-bottom: 1px solid #ffffff;
  268. }
  269. .width {
  270. width: 325rpx !important;
  271. }
  272. .code {
  273. color: #5dbc7c;
  274. font-size: 23rpx;
  275. border-left: 1px solid #eeeeee;
  276. width: 150rpx;
  277. flex-shrink: 0;
  278. text-align: center;
  279. }
  280. uni-button {
  281. height: 80rpx !important;
  282. line-height: 80rpx !important;
  283. }
  284. </style>