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.
 
 
 
 
 
 

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