You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

247 lines
4.9 KiB

  1. <template>
  2. <view class="container">
  3. <view class="back-btn yticon icon-zuojiantou-up" @click="navBack"></view>
  4. <!-- 设置白色背景防止软键盘把下部绝对定位元素顶上来盖住输入框等 -->
  5. <view class="wrapper">
  6. <view class="left-top-sign">LOGIN</view>
  7. <view class="welcome">
  8. Welcome Back !
  9. </view>
  10. <view class="input-content">
  11. <view class="input-item">
  12. <text class="tit">Account</text>
  13. <input type="text" :value="mobile" placeholder="" data-key="mobile" @input="inputChange" />
  14. </view>
  15. <view class="input-item">
  16. <text class="tit">Password</text>
  17. <input type="mobile" value="" placeholder="" placeholder-class="input-empty" maxlength="20"
  18. password data-key="password" @input="inputChange" @confirm="toLogin" />
  19. </view>
  20. </view>
  21. <button class="confirm-btn" @click="toLogin" :disabled="logining">Login</button>
  22. <!-- #ifdef MP-WEIXIN -->
  23. <!-- <button class="confirm-btn" open-type="getPhoneNumber" @getphonenumber="loginForWechatMini">授权微信绑定电话号码一键登录</button> -->
  24. <!-- #endif -->
  25. <!-- <view class="forget-section"> -->
  26. <!-- <view><label @click="register('resetpwd')">忘记密码</label> -->
  27. <!-- - <label @click="register('register')">立马注册</label></view> -->
  28. <!-- </view> -->
  29. </view>
  30. </view>
  31. </view>
  32. </template>
  33. <script>
  34. import {
  35. mapMutations
  36. } from 'vuex';
  37. export default {
  38. data() {
  39. return {
  40. mobile: '',
  41. password: '',
  42. logining: false
  43. }
  44. },
  45. onLoad() {
  46. },
  47. methods: {
  48. ...mapMutations(['login']),
  49. inputChange(e) {
  50. const key = e.currentTarget.dataset.key;
  51. this[key] = e.detail.value;
  52. },
  53. navBack() {
  54. uni.navigateBack();
  55. },
  56. async toLogin() {
  57. this.logining = true;
  58. let data = await this.$api.request('/user/login', 'POST', {
  59. mobile: this.mobile,
  60. password: this.password
  61. })
  62. if (data) {
  63. this.$store.commit('login', data)
  64. this.logining = true;
  65. setTimeout(function() {
  66. let pages = getCurrentPages(); //当前页
  67. if(pages.length==1&&pages[0].route=='pages/public/login'){
  68. uni.switchTab({
  69. url: '/pages/index/index'
  70. })
  71. }else{
  72. uni.navigateBack();
  73. }
  74. }, 2000)
  75. } else {
  76. this.logining = false;
  77. }
  78. },
  79. register(event) {
  80. uni.navigateTo({
  81. url: './register?event=' + event
  82. })
  83. },
  84. // #ifdef MP-WEIXIN
  85. async loginForWechatMini(e) {
  86. if (e.hasOwnProperty('detail')) {
  87. let data = await this.$api.request('/user/loginForWechatMini', 'POST', {
  88. encryptedData: e.detail.encryptedData,
  89. iv: e.detail.iv
  90. });
  91. if (data) {
  92. this.$store.commit('login', data);
  93. this.$api.msg('登录成功');
  94. setTimeout(function() {
  95. let pages = getCurrentPages(); //当前页
  96. if(pages.length==1&&pages[0].route=='pages/public/login'){
  97. uni.switchTab({
  98. url: `pages/index/index`
  99. });
  100. }else{
  101. uni.navigateBack();
  102. }
  103. }, 2000);
  104. }
  105. }
  106. },
  107. // #endif
  108. },
  109. }
  110. </script>
  111. <style lang='scss'>
  112. page {
  113. background: #fff;
  114. }
  115. .container {
  116. padding-top: 160rpx;
  117. position: relative;
  118. width: 100vw;
  119. height: 100vh;
  120. overflow: hidden;
  121. background: #fff;
  122. }
  123. .wrapper {
  124. position: relative;
  125. z-index: 90;
  126. background: #fff;
  127. padding-bottom: 40upx;
  128. }
  129. .back-btn {
  130. position: absolute;
  131. left: 40upx;
  132. z-index: 9999;
  133. padding-top: var(--status-bar-height);
  134. top: 40upx;
  135. font-size: 40upx;
  136. color: $font-color-dark;
  137. }
  138. .left-top-sign {
  139. font-size: 120upx;
  140. color: $page-color-base;
  141. position: relative;
  142. left: -16upx;
  143. }
  144. .welcome {
  145. position: relative;
  146. left: 50upx;
  147. top: -90upx;
  148. font-size: 46upx;
  149. color: #555;
  150. text-shadow: 1px 0px 1px rgba(0, 0, 0, .3);
  151. }
  152. .input-content {
  153. padding: 0 60upx;
  154. }
  155. .input-item {
  156. display: flex;
  157. flex-direction: column;
  158. align-items: flex-start;
  159. justify-content: center;
  160. padding: 0 30upx;
  161. background: $page-color-light;
  162. height: 120upx;
  163. border-radius: 4px;
  164. margin-bottom: 50upx;
  165. &:last-child {
  166. margin-bottom: 0;
  167. }
  168. .tit {
  169. height: 50upx;
  170. line-height: 56upx;
  171. font-size: $font-sm+2upx;
  172. color: $font-color-base;
  173. }
  174. input {
  175. height: 60upx;
  176. font-size: $font-base + 2upx;
  177. color: $font-color-dark;
  178. width: 100%;
  179. }
  180. }
  181. .confirm-btn {
  182. width: 630upx;
  183. height: 76upx;
  184. line-height: 76upx;
  185. border-radius: 50px;
  186. margin-top: 70upx;
  187. background: $uni-color-primary;
  188. color: #fff;
  189. font-size: $font-lg;
  190. &:after {
  191. border-radius: 100px;
  192. }
  193. }
  194. .forget-section {
  195. font-size: $font-sm+10upx;
  196. color: $font-color-spec;
  197. text-align: center;
  198. margin-top: 100upx;
  199. label {
  200. margin: 10upx 60upx;
  201. }
  202. }
  203. .register-section {
  204. position: absolute;
  205. left: 0;
  206. bottom: 50upx;
  207. width: 100%;
  208. font-size: $font-sm+2upx;
  209. color: $font-color-base;
  210. text-align: center;
  211. text {
  212. color: $font-color-spec;
  213. margin-left: 10upx;
  214. }
  215. }
  216. </style>