k94314517
2024-10-16 17efddc6a667670dca682bf36b51a43e99615e6d
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
<template>
  <view class="login">
    <!-- 头部背景图片 -->
    <view
      class="login_head"
      :style="{
        height: 'calc(' + height + ' + ' + '388rpx)',
        backgroundImage: 'url(' + backgroundImage + ')',
      }"
    ></view>
 
    <!-- 登录框 -->
    <view class="login_box">
      <view class="login_box_input">
        <input
          type="text"
          v-model="from.account"
          placeholder="请输入账号名称"
          placeholder-class="placeholder"
        />
      </view>
      <view class="login_box_input">
        <input
          type="password"
          v-if="!isOpen"
          v-model="from.password"
          placeholder="请输入密码"
          placeholder-class="placeholder"
        />
        <input
          type="text"
          v-else
          v-model="from.password"
          placeholder="请输入密码"
          placeholder-class="placeholder"
        />
        <u-icon
          name="eye-fill"
          color="#999999"
          size="20"
          v-if="!isOpen"
          @click="isOpen = true"
        ></u-icon>
        <u-icon
          name="eye-off"
          color="#999999"
          size="20"
          v-else
          @click="isOpen = false"
        ></u-icon>
      </view>
      <view class="login_box_sub" @click="login">登录</view>
    </view>
 
    <u-toast ref="uToast"></u-toast>
  </view>
</template>
 
<script>
import { mapState, mapMutations } from 'vuex'
 
export default {
  data() {
    return {
      backgroundImage: 'https://dmtest.ahapp.net/file/projects/20230511/13f256b832db4a4fadc5e6770f5727bf.png',
      from: {
        account: '',
        password: ''
      },
      isOpen: false
    }
  },
  computed: {
    ...mapState(['statusbarHeight', 'navHeight']),
 
    height() {
      return `${this.statusbarHeight + this.navHeight}px`
    }
  },
  methods: {
    ...mapMutations(["setToken", "setUserInfo"]),
 
    login() {
      if (!this.from.account) return this.$refs.uToast.show({ message: '账号不能为空' })
      if (!this.from.password) return this.$refs.uToast.show({ message: '密码不能为空' })
      var that = this
      that.$u.api.ordinaryLogin(that.from)
        .then(res => {
          if (res.code === 200) {
            that.setToken(res.data.token)
            that.setUserInfo(res.data.userResponse)
            uni.login({
              provider: 'MP-WEIXIN',
              success: function (loginRes) {
                that.$u.api.wxEmpower({ code: loginRes.code })
                  .then(resa => {
                    uni.switchTab({
                      url: '/pages/index/index'
                    })
                  })
              }
            })
          }
        })
    }
  }
}
</script>
 
<style>
page {
  background-color: #fff !important;
}
</style>
 
<style lang="scss">
.login {
  width: 100%;
  .login_head {
    width: 100%;
    background-repeat: no-repeat;
    background-size: 100%;
  }
  .login_box {
    width: 100%;
    position: relative;
    top: -114rpx;
    padding: 80rpx 60rpx;
    box-sizing: border-box;
    background-color: #ffffff;
    border-radius: 48rpx 48rpx 0rpx 0rpx;
    .login_box_input {
      width: 100%;
      height: 100rpx;
      display: flex;
      align-items: center;
      background: #f7f7f7;
      border-radius: 4rpx;
      margin-bottom: 40rpx;
      padding: 0 40rpx;
      box-sizing: border-box;
      .placeholder {
        font-size: 30rpx;
        font-family: PingFangSC-Regular, PingFang SC;
        font-weight: 400;
        color: #999999;
      }
      input {
        width: 100%;
        height: 100%;
        font-size: 30rpx;
        font-family: PingFangSC-Regular, PingFang SC;
        font-weight: 400;
        color: #000000;
        margin-right: 20rpx;
      }
    }
    .login_box_sub {
      width: 100%;
      height: 100rpx;
      line-height: 100rpx;
      text-align: center;
      background: #0055ff;
      border-radius: 4rpx;
      font-size: 32rpx;
      font-family: PingFangSC-Medium, PingFang SC;
      font-weight: 600;
      color: #ffffff;
      margin-top: 60rpx;
    }
  }
}
</style>