register.vue 6.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308
  1. <template>
  2. <view class="container">
  3. <view class="title-img">
  4. <!-- <image class="title-image" src="../../static/img/hlogo.png" mode="widthFix"></image> -->
  5. </view>
  6. <view class="title-font">
  7. 芊扦龙虾
  8. </view>
  9. <view class="login_text">
  10. <view class="login_input flex">
  11. <image class="login_img" src="../../static/img/user.png" mode="widthFix"></image>
  12. <view class="login_name"><input class="uni-input" v-model="phone" focus placeholder="请输入手机号" /></view>
  13. </view>
  14. <view class="login_input flex">
  15. <image class="login_img" src="../../static/img/pwd.png" mode="widthFix"></image>
  16. <view class="login_name"><input class="uni-input" type="password" v-model="password" focus
  17. placeholder="请输入密码" /></view>
  18. </view>
  19. <view class="login_input flex">
  20. <image class="login_img" src="../../static/img/pwd.png" mode="widthFix"></image>
  21. <view class="login_name"><input class="uni-input" type="password" v-model="repassword" focus
  22. placeholder="请重复输入密码" /></view>
  23. </view>
  24. <view class="login_input flex">
  25. <image class="login_img" src="../../static/img/send.png" mode="widthFix"></image>
  26. <view class="login_name"><input class="uni-input" type="text" v-model="invitation" focus
  27. placeholder="请输入邀请人手机号" /></view>
  28. </view>
  29. <!-- <view class="login_input flex">
  30. <image class="login_img" src="../../static/img/send.png" mode="widthFix"></image>
  31. <view class="login_name flex">
  32. <input class="uni-input width" v-model="code" focus placeholder="请输入验证码" />
  33. <view class="code" @click="verification">{{ countDown == 0 ? '验证码' : countDown }}</view>
  34. </view>
  35. </view> -->
  36. <view><button type="green" @click="register" class="uni-button uni-button-green">注册账号</button></view>
  37. <view><button class="uni-button uni-button-green-plain" type="green" plain="true" hover-class="none"
  38. @click="login">返回登录</button></view>
  39. </view>
  40. </view>
  41. </template>
  42. <script>
  43. import {
  44. register,
  45. verify
  46. } from '@/api/login.js';
  47. export default {
  48. data() {
  49. return {
  50. phone: '', //用户
  51. password: '', //密码
  52. repassword: '',
  53. invitation: '', //邀请码
  54. code: '', //验证码
  55. time: '', //保存倒计时对象
  56. countDown: 0 //倒计时
  57. };
  58. },
  59. onLoad(options) {
  60. // 获取扫码邀请人id
  61. this.invitation = uni.getStorageSync('spread') || '';
  62. if (options.spread) {
  63. this.invitation = options.spread;
  64. }
  65. },
  66. watch: {
  67. // 监听倒计时
  68. countDown(i) {
  69. if (i == 0) {
  70. clearInterval(this.time);
  71. }
  72. }
  73. },
  74. methods: {
  75. // 注册
  76. register() {
  77. let obj = this;
  78. if (obj.phone == '') {
  79. obj.$api.msg('请输入电话号码');
  80. return;
  81. }
  82. if (!/(^1[2|3|4|5|6|7|8|9][0-9]{9}$)/.test(this.phone)) {
  83. obj.$api.msg('请输入正确的手机号');
  84. return;
  85. }
  86. if (obj.password == '') {
  87. obj.$api.msg('请输入密码');
  88. return;
  89. }
  90. if (obj.repassword == '') {
  91. obj.$api.msg('请再次输入密码');
  92. return;
  93. }
  94. if (obj.repassword != obj.password) {
  95. obj.$api.msg('两次密码不正确');
  96. return;
  97. }
  98. // if ((obj.invitation = '')) {
  99. // obj.$api.msg('请输入邀请码');
  100. // return;
  101. // }
  102. // if (obj.code == '') {
  103. // obj.$api.msg('请输入验证码');
  104. // return;
  105. // }
  106. register({
  107. account: obj.phone, //账号
  108. captcha: '123456', //验证码
  109. password: obj.password, //密码
  110. spread: this.invitation //上级推广人
  111. }).then(function(e) {
  112. uni.showToast({
  113. title: '注册成功',
  114. duration: 2000,
  115. position: 'top'
  116. });
  117. setTimeout(function() {
  118. uni.navigateTo({
  119. url: '/pages/public/login'
  120. });
  121. }, 1000);
  122. });
  123. //调用注册接口,成功跳转登录页
  124. },
  125. //发送验证码
  126. verification() {
  127. let obj = this;
  128. if (this.phone == '') {
  129. this.$api.msg('请输入电话号码');
  130. return;
  131. }
  132. if (this.phone.length < 11) {
  133. this.$api.msg('请输入正确的手机号');
  134. return;
  135. }
  136. // 判断是否在倒计时
  137. if (obj.countDown > 0) {
  138. return false;
  139. } else {
  140. obj.countDown = 60;
  141. obj.time = setInterval(() => {
  142. obj.countDown--;
  143. }, 1000);
  144. //调用验证码接口
  145. verify({
  146. phone: obj.phone,
  147. type: 'register'
  148. })
  149. .then(({
  150. data
  151. }) => {})
  152. .catch(err => {
  153. console.log(err);
  154. });
  155. }
  156. },
  157. login() {
  158. //返回登录
  159. uni.navigateTo({
  160. url: '/pages/public/login'
  161. });
  162. }
  163. }
  164. };
  165. </script>
  166. <style lang="scss">
  167. page {
  168. height: 100%;
  169. background: #ffffff;
  170. }
  171. .title-img {
  172. margin: 100rpx auto 0;
  173. width: 160rpx;
  174. .title-image {
  175. width: 160rpx;
  176. }
  177. }
  178. .title-font {
  179. margin-top: 10rpx;
  180. text-align: center;
  181. font-size: 32rpx;
  182. font-family: Source Han Sans CN;
  183. font-weight: bold;
  184. color: #333333;
  185. }
  186. .login_text {
  187. position: relative;
  188. padding: 100rpx 102rpx;
  189. background-color: #ffffff;
  190. .login_input {
  191. margin-top: 20rpx;
  192. padding: 26rpx;
  193. border-radius: 21rpx;
  194. border-bottom: 1px solid #eeeeee;
  195. .login_img {
  196. width: 30rpx;
  197. flex-shrink: 0;
  198. }
  199. .uni-input {
  200. text-align: left;
  201. width: 470rpx;
  202. font-size: 28rpx !important;
  203. }
  204. .login_name {
  205. margin-left: 20rpx;
  206. color: #333333;
  207. }
  208. }
  209. .other {
  210. margin-top: 60rpx;
  211. .fenge {
  212. width: 30%;
  213. height: 2rpx;
  214. background-color: #eeeeee;
  215. }
  216. .qita {
  217. font-size: 28rpx;
  218. color: #999999;
  219. }
  220. }
  221. .weixin {
  222. width: 75rpx;
  223. height: 75rpx;
  224. margin: 25rpx auto;
  225. }
  226. .weixin image {
  227. width: 100%;
  228. height: 100%;
  229. }
  230. .weixin_text {
  231. text-align: center;
  232. font-size: 28rpx;
  233. color: #999999;
  234. }
  235. .forget {
  236. font-size: 28rpx;
  237. width: 100%;
  238. text-align: right;
  239. color: #999999;
  240. }
  241. .uni-button-green {
  242. margin: 40rpx 10rpx;
  243. background: linear-gradient(90deg, #CA57DC, #65B2E9);
  244. border-radius: 10rpx;
  245. color: #ffffff;
  246. }
  247. .uni-button-green-plain {
  248. margin: 40rpx 10rpx;
  249. border-radius: 10rpx;
  250. color: #CA57DC;
  251. border: 1px solid #CA57DC;
  252. }
  253. .uni-button {
  254. height: 85rpx;
  255. line-height: 85rpx;
  256. }
  257. }
  258. .forget {
  259. width: 100rpx;
  260. font-size: 24rpx;
  261. color: #ffffff;
  262. margin: 0px auto;
  263. border-bottom: 1px solid #ffffff;
  264. }
  265. .width {
  266. width: 325rpx !important;
  267. }
  268. .code {
  269. padding-right: 30rpx;
  270. font-size: 23rpx;
  271. width: 150rpx;
  272. flex-shrink: 0;
  273. text-align: center;
  274. color: #2E58FF;
  275. background: linear-gradient(0deg, #CA57DC 0%, #65B2E9 100%);
  276. -webkit-background-clip: text;
  277. -webkit-text-fill-color: transparent;
  278. }
  279. uni-button {
  280. height: 80rpx !important;
  281. line-height: 80rpx !important;
  282. }
  283. </style>