金诚优选前端代码
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.

172 lines
4.0 KiB

4 years ago
4 years ago
4 years ago
  1. <template>
  2. <view>
  3. <lf-nav title="商家登录" :showIcon="true" bgColor="#fff"></lf-nav>
  4. <view class="head">
  5. <view class="head-content">
  6. <image class="logo" :src="avatar" v-if="avatar"></image>
  7. <image class="logo" src="../../../static/images/login.png" v-else></image>
  8. <view class="title">欢迎来到金诚优选</view>
  9. </view>
  10. </view>
  11. <view class="content">
  12. <view class="list">
  13. <view class="lf-flex">
  14. <view class="lf-font-28 lf-color-black" style="width: 140rpx;">手机号</view>
  15. <input class="input" placeholder="请输入手机号码" v-model="phone" maxlength="11" />
  16. </view>
  17. <view class="clear" v-if="phone.length" @click="phone = ''">
  18. <text class="lf-iconfont icon-status-error"></text>
  19. </view>
  20. </view>
  21. <view class="list">
  22. <view class="lf-flex">
  23. <view class="lf-font-28 lf-color-black" style="width: 140rpx;">密码</view>
  24. <input class="input" placeholder="请输入密码" v-model="password" />
  25. </view>
  26. <view class="clear" v-if="password.length" @click="password = ''">
  27. <text class="lf-iconfont icon-status-error"></text>
  28. </view>
  29. </view>
  30. </view>
  31. <button class="next-btn" hover-class="lf-opacity" @click="next">登录</button>
  32. </view>
  33. </template>
  34. <script>
  35. export default {
  36. data(){
  37. return {
  38. phone: '',
  39. password: '',
  40. avatar: ''
  41. }
  42. },
  43. onLoad(){
  44. let userInfo = this.$cookieStorage.get('user_info');
  45. if(this.$isRight(userInfo)){
  46. this.avatar = userInfo.avatar;
  47. }
  48. },
  49. methods: {
  50. next(){
  51. if(!this.phone) return this.$msg('请输入登录手机号');
  52. if(!this.$check(this.phone, 'mobile')) return this.$msg('请输入正确的手机号');
  53. if(!this.password) return this.$msg('请输入密码');
  54. uni.showLoading({
  55. title: '正在登录'
  56. })
  57. this.$http.post({
  58. api: 'api/supplier/login',
  59. data: {
  60. username: this.phone,
  61. password: this.password
  62. }
  63. }).then(res => {
  64. console.log("login", res);
  65. uni.hideLoading();
  66. if(res.data.code != 200){
  67. this.$msg(res.data.data);
  68. }else{
  69. let token = res.data.data.token;
  70. // let expires_in = res.data.data.expires_in || 315360000; // 登录超时时效
  71. // this.$cookieStorage.set('store_token', token, expires_in);
  72. this.$cookieStorage.set('store_token', token);
  73. this.$url('/pages/business/center/center', {type: 'redirect'});
  74. }
  75. }).catch(err => uni.hideLoading())
  76. }
  77. }
  78. }
  79. </script>
  80. <style lang="scss" scoped>
  81. .head{
  82. height: 400rpx;
  83. width: 750rpx;
  84. display: flex;
  85. flex-direction: column;
  86. align-items: center;
  87. justify-content: center;
  88. .head-content{
  89. display: flex;
  90. flex-direction: column;
  91. align-items: center;
  92. .logo{
  93. width: 182rpx;
  94. height: 182rpx;
  95. border-radius: 50%;
  96. background-color: #EEEEEE;
  97. }
  98. .title{
  99. font-size: 32rpx;
  100. color: #222222;
  101. font-weight: bold;
  102. font-family: '楷体';
  103. margin-top: 20rpx;
  104. }
  105. }
  106. }
  107. .content{
  108. padding: 0 32rpx;
  109. }
  110. .next-btn{
  111. width: 550rpx;
  112. height: 100rpx;
  113. background: #0D2E9A;
  114. border-radius: 50rpx;
  115. line-height: 100rpx;
  116. color: #FFFFFF;
  117. margin-top: 100rpx;
  118. }
  119. .list{
  120. height: 120rpx;
  121. width: 100%;
  122. border-bottom: 1rpx solid #e5e5e5;
  123. display: flex;
  124. justify-content: space-between;
  125. align-items: center;
  126. .input{
  127. width: 430rpx;
  128. height: 80rpx;
  129. font-size: 28rpx;
  130. }
  131. .input-code{
  132. width: 340rpx;
  133. }
  134. .clear{
  135. padding: 20rpx;
  136. }
  137. .code{
  138. min-width: 180rpx;
  139. max-width: 220rpx;
  140. height: 64rpx;
  141. padding: 0 4rpx;
  142. font-size: 24rpx;
  143. color: #0D2E9A;
  144. display: flex;
  145. justify-content: center;
  146. align-items: center;
  147. border-radius: 32rpx;
  148. border: 2rpx solid #0D2E9A;
  149. }
  150. .active-bg{
  151. background: #efefef;
  152. }
  153. }
  154. .fixed-desc{
  155. position: fixed;
  156. bottom: 50rpx;
  157. left: calc(50% - 343rpx);
  158. width: 686rpx;
  159. padding-bottom: constant(safe-area-inset-bottom);
  160. padding-bottom: env(safe-area-inset-bottom);
  161. font-size: 28rpx;
  162. color: #777777;
  163. &>text:nth-child(2){
  164. color: #FF9D9D;
  165. }
  166. }
  167. </style>