zj
2024-06-03 89d48809779ae41f8712539584798d5900b64b78
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
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
<template>
  <div class="wrapper">
    <div class="header">
      <!-- <a href="/homes" class="nav-left pull-left">
          <img :src="siteInfo.siteLogo" alt="">
      </a>-->
      <el-header>
          <home-header></home-header>
      </el-header>
      
    </div>
    <div class="loginbg-box">
      <!-- <img class="login-img" src="../../assets/image/login.jpeg" alt=""> -->
    </div>
    <div class="login-box">
      <div class="form-box top-box">
        <!-- <p class="animated fadeInDown">专线直连 机构版交易</p> -->
        <!-- <p class="prompt animated fadeInUp">为投资者量身定做机构版投资软件</p> -->
      </div>
      <div class="form-box">
        <h2 style="text-align:center">用户登录</h2>
        <el-form
          :hide-required-asterisk="true"
          :model="form"
          ref="ruleForm"
          :rules="rule"
          class="demo-form-inline"
        >
          <el-form-item label prop="phone">
            <el-input
              maxlength="11"
              max="11"
              type="text"
              class="user-phone"
              v-model="form.phone"
              placeholder="请输入手机号码"
            >
              <i slot="prepend" class="iconfont icon-user1" style="font-size:13px"></i>
            </el-input>
          </el-form-item>
          <el-form-item label prop="pwd">
            <el-input type="password"  class="user-phone" v-model="form.pwd" placeholder="请输入密码">
              <i slot="prepend" class="iconfont icon-zu" style="font-size: 15px;"></i>
            </el-input>
          </el-form-item>
        </el-form>
        <div slot="footer" class="dialog-footer">
          <el-button
            class="box-btn"
            type="primary"
            :loading="islogin"
            @click="checkPhone('ruleForm')"
          >立即登录</el-button>
        </div>
        <div class="text-right clearfix">
          <div class="pull-left">
            <a @click="toForget">忘记密码?</a>
          </div>
          <div class="pull-right">
            还没有账号?
            <a @click="toRegister">立即注册</a>
          </div>
        </div>
      </div>
    </div>
    <div></div>
    <newFooter></newFooter>
    <!-- <home-footer :siteInfo="siteInfo"></home-footer> -->
  </div>
</template>
 
<script>
import * as api from "../../axios/api";
import HomeFooter from "../../components/Footer";
import HomeHeader from "../../components/HeaderOrder";
import newFooter from '@/components/newFooter'
 
export default {
  components: {
    HomeFooter,
    HomeHeader,
    newFooter
  },
  props: {},
  data() {
    let validatePass = (rule, value, callback) => {
      if (value === "") {
        callback(new Error("请输入手机号码"));
      } else {
        // let myreg = /^[1][3,4,5,7,8][0-9]{9}$/  //手机号码验证
        let myreg = /^[0-9]{11}$/; // 手机号码验证
        if (!myreg.test(value)) {
          callback(new Error("请输入正确的手机号码"));
        }
        callback();
      }
    };
    // let validatePass2 = (rule, value, callback) => {
    //   if (value === '') {
    //     callback(new Error('请输入密码'))
    //   } else {
    //     let value = psd.replace(/\s*/g, '')
    //     let myreg = '/^[a-zA-Z0-9!@#$%^&*.]{6,12}$/' // 手机号码验证
    //     if (!myreg.test(value)) {
    //       callback(new Error('请输入正确的手机号码'))
    //     }
    //     callback()
    //   }
    // }
    return {
      islogin: false,
      siteInfo: {},
      form: {
        phone: "",
        pwd: "",
      },
      rule: {
        phone: [
          {
            required: true,
            validator: validatePass,
            message: "请输入手机号码",
            trigger: "blur",
          },
        ],
        pwd: [{ required: true, message: "请输入密码", trigger: "blur" }],
      },
    };
  },
  watch: {},
  computed: {},
  created() {},
  mounted() {
    this.getInfoSite();
  },
  methods: {
    async getInfoSite() {
      // 获取网站信息
      let result = await api.getInfoSite();
      if (result.status === 0) {
        this.siteInfo = result.data;
        this.$store.state.siteInfo = this.siteInfo;
      } else {
        this.$message.error(result.msg);
      }
    },
    async checkPhone(val) {
      // 先验证是否已经注册
      let data = await api.checkPhone({ phoneNum: this.form.phone });
      if (data.status === 0) {
        // 如果用户已存在返回 0
        this.submit(val);
      } else {
        this.$message.success("用户还未注册,请先注册");
        this.$router.push("/register");
      }
    },
    submit(formName) {
      // 提交
      this.$refs[formName].validate(async (valid) => {
        if (valid) {
          let opts = {
            phone: this.form.phone,
            userPwd: this.form.pwd,
          };
          this.islogin = true;
          let data = await api.login(opts);
          if (data.status === 0) {
            this.$store.state.userInfo.phone = this.phone;
            // window.localStorage.setItem('phone',this.form.phone)
            // setLocalstorage('phone',this.form.phone)
            this.$store.state.haslogin = true;
            this.$message.success(data.msg);
            // this.$router.push('/home')
            this.toTransform();
          } else {
            this.$message.error(data.msg);
          }
          this.islogin = false;
        } else {
          return false;
        }
      });
    },
    async toTransform() {
      let opt = {
        pageNum: 1,
        pageSize: 1,
      };
      this.loading = true;
      let data = await api.getStock(opt);
      if (data.status === 0) {
        this.$router.push({
          path: "/transaction",
          query: {
            code: data.data.list[0].code,
          },
        });
      } else {
        this.$message.error(data.msg);
      }
    },
    toRegister() {
      // 去注册
      this.$store.state.loginIsShow = false;
      this.$router.push("/register");
    },
    toForget() {
      this.$router.push("/forget");
    },
  },
};
</script>
<style lang="less" scoped>
.login-box .text-right[data-v-23b3be22]{
      margin: 25px 0 22px;
}
.login-box .form-box[data-v-23b3be22]{
  
    height: 400px;
    border-radius: 5px;
}
.black-bg {
  .user-phone {
    background-color: #2f2f2f;
    border-radius: 50px;
  }
  .el-button--primary{
    background-color: rgb(2, 77, 161) !important;
    border: none;
    border-radius: 50px;
  }
}
.red-bg {
  .user-phone {
 
    border: 1px solid rgb(150, 150, 150);
    border-radius: 50px;
  }
  .el-button--primary{
    border: none;
    border-radius: 50px;
  }
}
/deep/ .user-phone input {
  border: none;
}
/deep/ .login-box .el-input-group__prepend {
  left: 12px;
}
.header {
  height: 60px;
  // background: #fff;
  img {
    height: 58px;
    line-height: 58px;
  }
}
 
.el-form-item {
  margin-bottom: 40px;
}
 
.login-box {
  width: 80%;
  margin: 0 auto;
  height: 540px;
  position: relative;
 
  .form-box {
    width: 320px;
    height: 480px;
    text-align: center;
    position: absolute;
    right: 0;
    top: 32px;
    // background: #fff;
    color: #fff;
    background: rgba(3, 3, 3, 0.6);
    z-index: 2;
    padding: 0 40px;
    border-radius: 4px;
 
    h2 {
      height: 30px;
      line-height: 30px;
      text-align: left;
      font-size: 26px;
      padding-top: 30px;
    }
 
    .el-form {
      padding-top: 50px;
    }
  }
 
  .dialog-footer {
    margin-top: 20px;
  }
 
  .text-right {
    margin: 50px 0 25px;
  }
 
  /deep/ .el-input__inner {
    height: 40px;
    line-height: 40px;
    text-indent: 30px;
  }
 
  .login-box .iconfont {
    font-size: 28px;
  }
 
  /deep/ .el-form-item__error {
    padding-top: 12px;
  }
}
 
.header {
  // padding: 0 20px;
}
 
.login-box .top-box {
  position: absolute;
  top: 34%;
  width: 50%;
  height: 150px;
  left: 0;
  right: auto;
  background: none;
 
  .prompt {
    color: #b6b6b6;
    font-size: 18px;
  }
 
  p {
    color: #efbb53;
    font-size: 34px;
    margin-bottom: 40px;
  }
}
</style>