register.vue 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. <template>
  2. <view class="login">
  3. <image src="../../static/logo.png" mode="" class="pictures"></image>
  4. <view class="form">
  5. <van-field label="用户名" :value="userName" placeholder="请输入用户名" @change="getName" />
  6. <van-field label="密码" type="password" :value="passWord" placeholder="请输入密码" @change="getWord" />
  7. <view class="btn">
  8. <van-button type="danger" @click.native="goHome">注册用户</van-button>
  9. </view>
  10. </view>
  11. </view>
  12. </template>
  13. <script>
  14. import {
  15. toRegister
  16. } from '@/api/user.js';
  17. import {
  18. encrypto
  19. } from '@/utils/cryptojs.js';
  20. export default {
  21. data() {
  22. return {
  23. userName: '',
  24. passWord: ''
  25. }
  26. },
  27. methods: {
  28. getName(event) {
  29. this.userName = event.detail;
  30. },
  31. getWord(event) {
  32. this.passWord = event.detail;
  33. },
  34. goHome() {
  35. console.log(this.userName, this.passWord)
  36. toRegister({
  37. userName: this.userName,
  38. passWord: encrypto(this.passWord)
  39. }).then(res => {
  40. if(res.code = '00000') {
  41. uni.navigateTo({
  42. url:"/pages/login/login"
  43. })
  44. }
  45. }).catch(err => {
  46. console.log(err, '失败')
  47. })
  48. }
  49. }
  50. }
  51. </script>
  52. <style scoped lang="scss">
  53. .login {
  54. width: 100%;
  55. display: flex;
  56. justify-content: center;
  57. flex-direction: column;
  58. align-items: center;
  59. .pictures {
  60. width: 300rpx;
  61. height: 300rpx;
  62. margin: 200rpx 0 100rpx;
  63. }
  64. ::v-deep .van-button--normal {
  65. width: 100%;
  66. margin: 50rpx 0;
  67. }
  68. }
  69. </style>