login.vue 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129
  1. <template>
  2. <view>
  3. <view class="head">
  4. </view>
  5. <view class="content">
  6. <view class="logo">
  7. 账号登录
  8. </view>
  9. <view class="headline-2">
  10. <text class="uni-list-cell-left-2">账号:</text>
  11. <view class="uni-list-cell-db-2">
  12. <input class="uni-input-2" placeholder="请输入手机号" v-model="phone" required />
  13. </view>
  14. </view>
  15. <view class="headline-2">
  16. <text class="uni-list-cell-left-2">密码:</text>
  17. <view class="uni-list-cell-db-2">
  18. <input class="uni-input-2" placeholder="请输入密码" v-model="password" required />
  19. </view>
  20. </view>
  21. <button type="default" @click="bindLogin"
  22. style="width: 273px; height: 33px; background-color:rgba(42, 130, 228, 1); color: white;font-size: 15px; border-radius: 14px;">登录</button>
  23. </view>
  24. </view>
  25. </template>
  26. <script>
  27. export default {
  28. data() {
  29. return {
  30. phone: "",
  31. password: "",
  32. };
  33. },
  34. methods: {
  35. async bindLogin() {
  36. if (this.phone && this.password) {
  37. uni.showLoading({
  38. title: "登录中"
  39. })
  40. let res = await this.$myRequest({
  41. method: "post",
  42. url: `/login/loginWork?phone=${this.phone}&password=${this.password}`,
  43. })
  44. // console.log(res)
  45. if (res.status == 200) {
  46. uni.setStorageSync('token', res.data);
  47. uni.setStorageSync('identity', JSON.stringify(1)); //身份标识
  48. uni.reLaunch({
  49. url: '../list-center/list-center'
  50. })
  51. } else {
  52. uni.showToast({
  53. icon: 'error',
  54. title: '登录失败'
  55. });
  56. }
  57. } else {
  58. uni.showToast({
  59. title: "请输入账号密码",
  60. icon: "none"
  61. })
  62. }
  63. }
  64. },
  65. }
  66. </script>
  67. <style>
  68. .head {
  69. position: relative;
  70. height: 300rpx;
  71. border-radius: 0px 0px 10px 10px;
  72. background-color: rgba(42, 130, 228, 1);
  73. }
  74. .content {
  75. position: absolute;
  76. top: 120rpx;
  77. left: 14rpx;
  78. width: 720rpx;
  79. height: 568rpx;
  80. background-color: white;
  81. border: 1px solid rgba(128, 128, 128, 0.45);
  82. }
  83. .logo {
  84. font-size: 36rpx;
  85. font-weight: 700;
  86. margin-top: 18rpx;
  87. text-align: center;
  88. }
  89. .uni-list-cell-left-2 {
  90. float: left;
  91. margin-top: 80rpx;
  92. margin-left: 26rpx;
  93. }
  94. .uni-list-cell-db-2 {
  95. float: right;
  96. margin-right: 34rpx;
  97. margin-top: 70rpx;
  98. width: 540rpx;
  99. height: 70rpx;
  100. border-radius: 28rpx;
  101. background-color: rgba(166, 166, 166, 0.18);
  102. }
  103. .uni-input-2 {
  104. margin-left: 20rpx;
  105. margin-top: 20rpx;
  106. font-size: 24rpx;
  107. cursor: not-allowed;
  108. }
  109. .uni-input-placeholder {
  110. text-align: center;
  111. }
  112. button {
  113. position: absolute;
  114. bottom: 72rpx;
  115. left: 140rpx;
  116. line-height: 66rpx;
  117. }
  118. </style>