register.vue 7.3 KB

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