register.vue 7.1 KB

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