Nie możesz wybrać więcej, niż 25 tematów Tematy muszą się zaczynać od litery lub cyfry, mogą zawierać myślniki ('-') i mogą mieć do 35 znaków.
 
 
 
 
 
 

258 wiersze
5.1 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. setTimeout(()=>{
  77. location.reload()
  78. })
  79. }, 2000)
  80. } else {
  81. this.logining = false;
  82. }
  83. },
  84. register(event) {
  85. uni.navigateTo({
  86. url: './register?event=' + event
  87. })
  88. },
  89. // #ifdef MP-WEIXIN
  90. async loginForWechatMini(e) {
  91. if (e.hasOwnProperty('detail')) {
  92. let data = await this.$api.request('/user/loginForWechatMini', 'POST', {
  93. encryptedData: e.detail.encryptedData,
  94. iv: e.detail.iv
  95. });
  96. if (data) {
  97. this.$store.commit('login', data);
  98. this.$api.msg('登录成功');
  99. setTimeout(function() {
  100. let pages = getCurrentPages(); //当前页
  101. if(pages.length==1&&pages[0].route=='pages/public/login'){
  102. uni.switchTab({
  103. url: `pages/index/index`
  104. });
  105. }else{
  106. uni.navigateBack();
  107. }
  108. }, 2000);
  109. }
  110. }
  111. },
  112. // #endif
  113. },
  114. }
  115. </script>
  116. <style lang='scss'>
  117. page {
  118. background: #fff;
  119. }
  120. .container {
  121. padding-top: 160rpx;
  122. position: relative;
  123. display: flex;
  124. justify-content: center;
  125. height: 100vh;
  126. overflow: hidden;
  127. background: #fff;
  128. }
  129. .wrapper {
  130. position: relative;
  131. z-index: 90;
  132. background: #fff;
  133. padding-bottom: 40upx;
  134. max-width: 1000upx;
  135. }
  136. .back-btn {
  137. position: absolute;
  138. left: 40upx;
  139. z-index: 9999;
  140. padding-top: var(--status-bar-height);
  141. top: 40upx;
  142. font-size: 40upx;
  143. color: $font-color-dark;
  144. }
  145. .left-top-sign {
  146. font-size: 120upx;
  147. color: $page-color-base;
  148. position: relative;
  149. left: -16upx;
  150. }
  151. .welcome {
  152. position: relative;
  153. left: 50upx;
  154. top: -90upx;
  155. font-size: 46upx;
  156. color: #555;
  157. text-shadow: 1px 0px 1px rgba(0, 0, 0, .3);
  158. }
  159. .input-content {
  160. padding: 0 60upx;
  161. }
  162. .input-item {
  163. display: flex;
  164. flex-direction: column;
  165. align-items: flex-start;
  166. justify-content: center;
  167. padding: 0 30upx;
  168. background: $page-color-light;
  169. height: 120upx;
  170. border-radius: 4px;
  171. margin-bottom: 50upx;
  172. word-break: break-all;
  173. &:last-child {
  174. margin-bottom: 0;
  175. }
  176. .tit {
  177. height: 50upx;
  178. line-height: 56upx;
  179. font-size: $font-sm+2upx;
  180. color: $font-color-base;
  181. }
  182. input {
  183. height: 60upx;
  184. font-size: $font-base + 2upx;
  185. color: $font-color-dark;
  186. width: 100%;
  187. }
  188. }
  189. .confirm-btn {
  190. width: 630upx;
  191. height: 76upx;
  192. line-height: 76upx;
  193. border-radius: 50px;
  194. margin-top: 70upx;
  195. background: $uni-color-primary;
  196. color: #fff;
  197. font-size: $font-lg;
  198. &:after {
  199. border-radius: 100px;
  200. }
  201. }
  202. .forget-section {
  203. font-size: $font-sm+10upx;
  204. color: $font-color-spec;
  205. text-align: center;
  206. margin-top: 100upx;
  207. label {
  208. margin: 10upx 60upx;
  209. }
  210. }
  211. .register-section {
  212. position: absolute;
  213. left: 0;
  214. bottom: 50upx;
  215. width: 100%;
  216. font-size: $font-sm+2upx;
  217. color: $font-color-base;
  218. text-align: center;
  219. text {
  220. color: $font-color-spec;
  221. margin-left: 10upx;
  222. }
  223. }
  224. </style>