login.vue 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207
  1. <template>
  2. <view class="login">
  3. <view class="logo">
  4. <image src="../../static/images/login/logo.png" style="width: 160upx;height: 160upx;" mode="scaleToFill"></image>
  5. </view>
  6. <view class="login-from">
  7. <view class="input-item">
  8. <label for="">
  9. <image src="../../static/images/login/phone.png" style="width: 30upx;height: 40upx;margin-top: 4upx;" mode=""></image>
  10. </label>
  11. <input type="text" placeholder="请输入账号" v-model="account">
  12. </view>
  13. <view class="input-item" style="margin-bottom: 20upx;">
  14. <label for="">
  15. <image src="../../static/images/login/lock.png" style="width: 30upx;height: 40upx;margin-top: 4upx;" mode=""></image>
  16. </label>
  17. <input type="password" placeholder="请输入密码" v-model="password">
  18. </view>
  19. <view class="forget">
  20. <navigator url="/pages/user/find-pass" open-type="navigate" style="display: inline;">
  21. <text>忘记密码</text>
  22. </navigator>
  23. </view>
  24. <view class="button-item">
  25. <button class="login-btn" @tap="login()">登录</button>
  26. </view>
  27. <view class="button-item">
  28. <navigator url="/pages/register/step1" open-type="navigate">
  29. <button class="reg-btn">注册</button>
  30. </navigator>
  31. </view>
  32. <view class="use-phone">
  33. <navigator url="/pages/user/vcode-login" open-type="navigate" style="display: inline;">
  34. <text>使用手机验证码登入</text>
  35. </navigator>
  36. </view>
  37. </view>
  38. <view class="third-party">
  39. <view class="title"><text>第三方登录</text></view>
  40. <view class="content">
  41. <image src="../../static/images/login/wx.png" style="width: 90upx;height: 90upx;" mode="scaleToFill"></image>
  42. </view>
  43. </view>
  44. </view>
  45. </template>
  46. <script>
  47. export default {
  48. data() {
  49. return {
  50. account: '',
  51. password: ''
  52. }
  53. },
  54. onBackPress() {
  55. return false;
  56. },
  57. methods: {
  58. login() {
  59. if (this.$verified.account(this.account) &&
  60. this.$verified.required(this.password, "请输入密码")) {
  61. this.$http.post({
  62. url: "/user/login",
  63. data: {
  64. account: this.account,
  65. password: this.password
  66. },
  67. success: (res) => {
  68. console.log(this.$store)
  69. this.$store.dispatch("user/save", res.data.data.userinfo)
  70. uni.$emit("login_succeeded");
  71. uni.navigateBack();
  72. }
  73. })
  74. }
  75. }
  76. }
  77. }
  78. </script>
  79. <style lang="scss" scoped>
  80. .login {
  81. background: $primary-color;
  82. height: 100vh;
  83. width: 750rpx;
  84. /* #ifdef APP-PLUS */
  85. padding-bottom: 60upx;
  86. /* #endif */
  87. }
  88. .logo {
  89. width: 160upx;
  90. height: 160upx;
  91. background: white;
  92. border-radius: 160upx;
  93. border: 10upx solid $primary-color;
  94. margin: auto;
  95. margin-top: -60upx;
  96. position: relative;
  97. top: 80upx;
  98. z-index: 999;
  99. }
  100. .login-from {
  101. margin: auto;
  102. width: 600upx;
  103. height: 740upx;
  104. background-color: white;
  105. border-radius: 20rpx;
  106. padding: 72upx;
  107. padding-top: 180upx;
  108. box-sizing: border-box;
  109. position: relative;
  110. z-index: 2;
  111. &::after {
  112. content: "";
  113. background: url(../../static/images/login/box-bottom.png) no-repeat;
  114. background-size: contain;
  115. width: 564upx;
  116. height: 30upx;
  117. display: block;
  118. position: absolute;
  119. bottom: -30upx;
  120. left: 18upx;
  121. z-index: -1;
  122. }
  123. }
  124. .input-item {
  125. display: flex;
  126. margin-bottom: 48upx;
  127. align-items: center;
  128. label {
  129. width: 50upx;
  130. }
  131. input {
  132. border-bottom: 2upx solid $primary-color;
  133. flex-grow: 1;
  134. padding: 5upx;
  135. font-size: 28upx;
  136. }
  137. }
  138. .forget {
  139. text-align: right;
  140. color: $primary-color;
  141. font-size: 28upx;
  142. }
  143. .login-btn,
  144. .reg-btn {
  145. height: 80upx;
  146. border: 2upx solid $primary-color;
  147. line-height: 80upx;
  148. margin: 30upx 0;
  149. font-size: 32upx;
  150. &::after {
  151. border: none;
  152. }
  153. }
  154. .login-btn {
  155. background: $primary-color;
  156. color: white;
  157. }
  158. .reg-btn {
  159. background-color: white;
  160. color: $primary-color;
  161. }
  162. .use-phone {
  163. font-size: 28upx;
  164. text-align: center;
  165. color: $primary-color;
  166. }
  167. .third-party {
  168. margin: auto;
  169. text-align: center;
  170. margin-top: 100upx;
  171. .title {
  172. font-size: 28upx;
  173. color: white;
  174. &::before,
  175. &::after {
  176. display: inline-block;
  177. width: 100upx;
  178. height: 0upx;
  179. border: 1upx solid #ff8ca8;
  180. transform: scaleY(0.5);
  181. content: "";
  182. margin: 8upx 20upx;
  183. }
  184. }
  185. .content {
  186. margin-top: 50upx;
  187. }
  188. }
  189. </style>