register.vue 7.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322
  1. <template>
  2. <view class="container">
  3. <view class="container_text" >
  4. <image src="../../static/icon/logo.png" mode="" class="logo"></image>
  5. <view class="logo-tit"><text>博·赢</text></view>
  6. <!-- <image class="banner-img" src="/static/img/img01.png" mode="scaleToFill"></image> -->
  7. </view>
  8. <view class="login_text">
  9. <view class="login_input flex">
  10. <view class="login_img"><image src="../../static/icon/icon-phone.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/icon-code.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/icon-code.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/icon-yzm.png"></image></view>
  23. <view class="login_name flex">
  24. <input class="uni-input width" v-model="code" focus placeholder="请输入验证码" />
  25. <view class="code" @click="verification">{{ countDown == 0 ? '验证码' : countDown }}</view>
  26. </view>
  27. </view>
  28. <view><button type="green" @click="register" class="uni-button uni-button-green">注册</button></view>
  29. <!-- <view><button class="uni-button uni-button-green uni-button-green-plain" type="green" plain="true" hover-class="none" @click="login">返回登录</button></view> -->
  30. <view class=" flex bombtn">
  31. <navigator url="./forget">
  32. <view class="bbtn">忘记密码</view>
  33. </navigator>
  34. <view class="jg">
  35. </view>
  36. <view class="bbtn" @click="login">账号登录</view>
  37. </view>
  38. </view>
  39. </view>
  40. </template>
  41. <script>
  42. import { register, verify } from '@/api/login.js';
  43. export default {
  44. data() {
  45. return {
  46. phone: '', //用户
  47. password: '', //密码
  48. repassword: '',
  49. invitation: '', //邀请码
  50. code: '', //验证码
  51. time: '', //保存倒计时对象
  52. countDown: 0 ,//倒计时
  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[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. mobile: obj.phone, //账号
  101. code: obj.code, //验证码
  102. password: obj.password ,//密码
  103. spread:this.invitation//上级推广人
  104. }).then(function(e) {
  105. uni.showToast({
  106. title:'注册成功',
  107. duration:2000,
  108. position:'top'
  109. });
  110. setTimeout(function () {
  111. uni.navigateTo({
  112. url: '/pages/public/login'
  113. });
  114. },1000)
  115. });
  116. //调用注册接口,成功跳转登录页
  117. },
  118. //发送验证码
  119. verification() {
  120. let obj = this;
  121. if (this.phone == '') {
  122. this.$api.msg('请输入电话号码');
  123. return;
  124. }
  125. if (this.phone.length < 11) {
  126. this.$api.msg('请输入正确的手机号');
  127. return;
  128. }
  129. // 判断是否在倒计时
  130. if (obj.countDown > 0) {
  131. return false;
  132. } else {
  133. obj.countDown = 60;
  134. obj.time = setInterval(() => {
  135. obj.countDown--;
  136. }, 1000);
  137. //调用验证码接口
  138. verify({
  139. mobile: obj.phone,
  140. event: 'register'
  141. })
  142. .then(({ data }) => {})
  143. .catch(err => {
  144. console.log(err);
  145. });
  146. }
  147. },
  148. login() {
  149. //返回登录
  150. uni.navigateTo({
  151. url: '/pages/public/login'
  152. });
  153. }
  154. }
  155. };
  156. </script>
  157. <style lang="scss">
  158. page {
  159. height: 100%;
  160. }
  161. .container {
  162. width: 100%;
  163. height: 100%;
  164. background-size: 100%;
  165. }
  166. .container_text {
  167. width: 100%;
  168. height: 500rpx;
  169. top: 0rpx;
  170. display: flex;
  171. flex-direction: column;
  172. justify-content: center;
  173. align-items: center;
  174. .banner-img {
  175. width: 100%;
  176. height: 100%;
  177. }
  178. .logo {
  179. width: 186rpx;
  180. height: 196rpx;
  181. }
  182. .logo-tit {
  183. text-align: center;
  184. font-size: 36rpx;
  185. font-family: PingFang SC;
  186. font-weight: 400;
  187. color: #FAD6B0;
  188. }
  189. }
  190. .login_text {
  191. margin: auto 30rpx;
  192. position: relative;
  193. padding: 20rpx 102rpx 100rpx;
  194. background-color: #000;
  195. // margin-top: -180rpx;
  196. border-radius: 20rpx;
  197. .login_input {
  198. padding-bottom: 20rpx;
  199. border-bottom: 1px solid #f0f0f0;
  200. margin-bottom: 65rpx;
  201. .login_img image {
  202. height: 35rpx;
  203. width: 29rpx;
  204. margin-right: 20rpx;
  205. }
  206. .uni-input {
  207. text-align: left;
  208. width: 470rpx;
  209. font-size: 28rpx !important;
  210. }
  211. .login_name {
  212. color: #fff;
  213. }
  214. }
  215. .other {
  216. margin-top: 60rpx;
  217. .fenge {
  218. width: 30%;
  219. height: 2rpx;
  220. background-color: #eeeeee;
  221. }
  222. .qita {
  223. font-size: 28rpx;
  224. color: #999999;
  225. }
  226. }
  227. .weixin {
  228. width: 75rpx;
  229. height: 75rpx;
  230. margin: 25rpx auto;
  231. }
  232. .weixin image {
  233. width: 100%;
  234. height: 100%;
  235. }
  236. .weixin_text {
  237. text-align: center;
  238. font-size: 28rpx;
  239. color: #999999;
  240. }
  241. .forget {
  242. font-size: 28rpx;
  243. width: 100%;
  244. text-align: right;
  245. color: #999999;
  246. }
  247. .uni-button-green {
  248. background: linear-gradient(-74deg, #CE9C6D, #FFECD6);
  249. // border: 1px solid;
  250. border-image: linear-gradient(115deg, #FEEBD5, #FFFFFF, #E1AD7D) 1 1;
  251. box-shadow: 3rpx 4rpx 5rpx 0rpx rgba(151, 118, 74, 0.5);
  252. border-radius: 10rpx;
  253. font-size: 34rpx;
  254. font-family: PingFang SC;
  255. font-weight: 500;
  256. color: #874B19;
  257. }
  258. .uni-button-green-plain {
  259. border: 1px solid #5dbc7c;
  260. margin: 40rpx 10rpx;
  261. border-radius: 50rpx;
  262. color: #5dbc7c;
  263. background-color: #ffffff;
  264. }
  265. .uni-button {
  266. height: 85rpx;
  267. line-height: 85rpx;
  268. }
  269. }
  270. .loginTitle {
  271. position: absolute;
  272. top: 250rpx;
  273. width: 100%;
  274. text-align: center;
  275. color: white;
  276. font-size: 40rpx;
  277. }
  278. .forget {
  279. width: 100rpx;
  280. font-size: 24rpx;
  281. color: #ffffff;
  282. margin: 0px auto;
  283. border-bottom: 1px solid #ffffff;
  284. }
  285. .width {
  286. width: 325rpx !important;
  287. }
  288. .code {
  289. color: #dbb189;
  290. font-size: 23rpx;
  291. border-left: 1px solid #eeeeee;
  292. width: 150rpx;
  293. flex-shrink: 0;
  294. text-align: center;
  295. }
  296. uni-button {
  297. height: 80rpx !important;
  298. line-height: 80rpx !important;
  299. }
  300. .bombtn {
  301. margin-top: 36rpx;
  302. justify-content: center;
  303. font-size: 28rpx;
  304. font-family: PingFang SC;
  305. font-weight: 500;
  306. color: #FFFFFF;
  307. .jg {
  308. height: 28rpx;
  309. width: 2rpx;
  310. background-color: #fff;
  311. margin: 0 10rpx;
  312. }
  313. }
  314. </style>