register.vue 7.1 KB

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