login.vue 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161
  1. <template>
  2. <view class="login_container">
  3. <navback />
  4. <view class="kuang">
  5. <view class="loginText">欢迎登录</view>
  6. <input class="phone_input"
  7. type="text" v-model="phone_value" placeholder="手机号">
  8. <view class="passwordcontent">
  9. <input v-if="hidden_password" class="password_input phone_input"
  10. type="password" v-model="password_value" placeholder="密码">
  11. <input v-else="hidden_password" class="password_input phone_input"
  12. type="text" v-model="password_value" placeholder="密码">
  13. <view :class="hidden_password ?'passwordcontent_hidden':'passwordcontent_show passwordcontent_hidden'" @click="clickToPasswordIsHidden">
  14. <image src="../../static/password_hidden.png" mode="aspectFit"></image>
  15. </view>
  16. </view>
  17. <view class="loginButton" @click="clickToLogin">登录</view>
  18. </view>
  19. </view>
  20. </template>
  21. <script>
  22. import navback from '../../components/navigator-back/navigator-back.vue'
  23. export default {
  24. data() {
  25. return {
  26. hidden_password: true,
  27. phone_value: '',
  28. password_value: '',
  29. login_success_goback_after_switch_index: -1,
  30. }
  31. },
  32. onLoad(option) {
  33. this.login_success_goback_after_switch_index = option.index
  34. // console.log('login_success_goback_after_switch_index:', this.login_success_goback_after_switch_index)
  35. },
  36. methods: {
  37. clickToPasswordIsHidden() {
  38. this.hidden_password = !this.hidden_password
  39. },
  40. clickToLogin() {
  41. // console.log('phone_value', this.phone_value)
  42. // console.log('password_value', this.password_value)
  43. if(this.tools.isNull(this.phone_value)) {
  44. uni.showModal({
  45. title:'请输入手机号',
  46. showCancel:false
  47. })
  48. return
  49. }
  50. // if(tools.isNull(this.password_value)) {
  51. // uni.showModal({
  52. // title:'请输入密码',
  53. // showCancel:false
  54. // })
  55. // return
  56. // }
  57. let self = this
  58. this.tools.request_login(self, this.phone_value, this.password_value, (success)=>{
  59. if(success === true) {
  60. uni.navigateBack()
  61. let index = self.login_success_goback_after_switch_index
  62. if(index > -1) {
  63. uni.$emit(self.config.notification.switch_page_index, parseInt(index))
  64. }
  65. setTimeout(function() {
  66. uni.showToast({
  67. title:'登录成功',
  68. duration:1000
  69. })
  70. }, 100);
  71. }
  72. })
  73. }
  74. },
  75. components: {
  76. navback
  77. }
  78. }
  79. </script>
  80. <style>
  81. page{
  82. background-color: #2A2832;
  83. }
  84. </style>
  85. <style lang="scss">
  86. .login_container{
  87. display: flex;
  88. box-sizing: border-box;
  89. flex-direction: column;
  90. width: 100%;
  91. align-items: center;
  92. .kuang{
  93. display: flex;
  94. box-sizing: border-box;
  95. flex-direction: column;
  96. width: 50%; //497px;
  97. border-radius: 2vw; //10px;
  98. border: 1px solid #32B3AA;
  99. box-shadow: 0 0 15px #000000;
  100. padding: 50px 37px;
  101. align-items: center;
  102. .loginText{
  103. display: flex;
  104. font-size: 3vw; //24px;
  105. font-weight: 500;
  106. color: #C2C2C2;
  107. justify-content: center;
  108. }
  109. .phone_input{
  110. margin-top: 2vw;//30px;
  111. width: 100%;
  112. height: 8vw; //70px;
  113. font-size: 2vw; //22px;
  114. color: #ffffff;
  115. border-bottom: 1px solid #32B3AA;
  116. }
  117. .passwordcontent{
  118. position: relative;
  119. display: flex;
  120. width: 100%;
  121. .password_input{
  122. margin-top: 3vw; //40px;
  123. background-color: transparent;
  124. }
  125. .passwordcontent_hidden{
  126. position: absolute;
  127. display: flex;
  128. bottom: 10px;
  129. right: 10px;
  130. width: 3vw; //30px;
  131. height: 3vw; //30px;
  132. transition: all 0.5s;
  133. image{
  134. width: 100%;
  135. height: 100%;
  136. }
  137. }
  138. .passwordcontent_show {
  139. transform: rotate(-180deg);
  140. transition: all 0.5s;
  141. }
  142. }
  143. .loginButton{
  144. display: flex;
  145. margin-top: 8vw; //80px;
  146. width: 27vw; //260px;
  147. height: 5vw; //60px;
  148. border-radius: 10px;
  149. font-size: 2.5vw; //22px;
  150. color: #ffffff;
  151. background-color: #32B3AA;
  152. justify-content: center;
  153. align-items: center;
  154. }
  155. }
  156. }
  157. </style>