login.vue 2.8 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()" style="width: 273px; height: 33px; background-color:rgba(42, 130, 228, 1); color: white;font-size: 15px; border-radius: 14px;">登录</button>
  22. </view>
  23. </view>
  24. </template>
  25. <script>
  26. export default {
  27. data() {
  28. return {
  29. phone:"",
  30. password:"",
  31. homeUrl:"https://jtishfw.ncjti.edu.cn/baoxiu/repairApi"
  32. };
  33. },
  34. methods: {
  35. bindLogin(){
  36. uni.request({
  37. url:`${this.homeUrl}/login/loginWork?phone=${this.phone}&password=${this.password}`,
  38. method:'POST',
  39. success: (res) => {
  40. console.log('======res.data.status)=======')
  41. console.log(res.data.status)
  42. console.log('======res=======')
  43. console.log(res)
  44. if(res.data.status==200){
  45. uni.setStorageSync('token',res.data.data);
  46. uni.showToast({
  47. title:'登录成'
  48. });
  49. uni.reLaunch({
  50. url:'../list-center/list-center'
  51. })
  52. }else{
  53. uni.showToast({
  54. icon:'none',
  55. title:'登录失败'
  56. });
  57. return;
  58. }
  59. },
  60. fail: () => {
  61. },
  62. complete: () => {
  63. }
  64. });
  65. }
  66. },
  67. }
  68. </script>
  69. <style>
  70. .head{
  71. position: relative;
  72. height: 149px;
  73. border-radius: 0px 0px 10px 10px;
  74. background-color: rgba(42, 130, 228, 1);
  75. }
  76. .content{
  77. position: absolute;
  78. top:59px;
  79. left: 7px;
  80. width:359px;
  81. height: 284px;
  82. background-color: white;
  83. border: 1px solid rgba(128, 128, 128, 0.45);
  84. }
  85. .logo{
  86. font-size: 18px;
  87. font-weight: 700;
  88. margin-top: 9px;
  89. text-align: center;
  90. }
  91. .uni-list-cell-left-2{
  92. float: left;
  93. margin-top: 40px;
  94. margin-left: 13px;
  95. }
  96. .uni-list-cell-db-2{
  97. float: right;
  98. margin-right: 17px;
  99. margin-top: 35px;
  100. width: 270px;
  101. height: 35px;
  102. border-radius: 14px;
  103. background-color: rgba(166, 166, 166, 0.18);
  104. }
  105. .uni-input-2{
  106. margin-left: 10px;
  107. margin-top: 5px;
  108. font-size: 12px;
  109. cursor: not-allowed;
  110. }
  111. .uni-input-placeholder{
  112. margin-top: 6px;
  113. text-align: center;
  114. }
  115. button{
  116. position: absolute;
  117. bottom: 36px;
  118. left: 69px;
  119. line-height: 33px;
  120. }
  121. </style>