123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235 |
- <!-- 密码登录 -->
- <template>
- <view class="login-main as-gravity-center as-layout-vertical">
- <image :src="`${$imgUrl}login/logo.png`" class="logo"></image>
- <view class="form">
- <view class="form-input">
- <view> +86</view>
- <image :src="`${$imgUrl}common/arror_down_black.png`" class="arror" />
- <input class="input" v-model="state.username" focus placeholder="请输入手机号"
- placeholder-class="form-placeholder" type="number" maxlength="11" />
- </view>
- <view class="form-input" v-if="state.loginType === 'pwd'">
- <input class="input" v-model="state.password" type="text" placeholder="请输入密码"
- placeholder-class="form-placeholder" :password="state.isPwdType ? true : false" />
- <image :src="`${$imgUrl}login/${
- state.isPwdType ? 'icon_eye_close' : 'icon_eye_open'
- }.png`" class="eye" @click="state.isPwdType = !state.isPwdType"></image>
- </view>
- <view class="form-input" v-if="state.loginType === 'code'">
- <input class="input" v-model="state.code" placeholder="请输入验证码" placeholder-class="form-placeholder"
- maxlength="6" type="number" />
- <verification-code :bg="false" :mobile="state.username"></verification-code>
- </view>
- </view>
-
- <view class="btn">
- <submit-button title="登录" @submit="doLogin"></submit-button>
- </view>
- </view>
- </template>
-
- <script setup lang="ts">
- import {
- reactive
- } from "vue";
- import {
- checkStr,
- msg,
- navTo
- } from "@/utils/utils";
- import {
- onLoad,
- onUnload
- } from "@dcloudio/uni-app";
- import {
- login
- } from "@/utils/network/api.js";
- import {
- request
- } from "@/utils/network/request.js";
- import {
- stringToJson
- } from "@/utils/network/encryption";
- const tools = require("../static/etcUtil/tools.js");
- import {
- setItem
- } from "@/utils/storage";
-
-
- const state = reactive({
- checked: false, //是否勾选协议
- isPwdType: true, //是不是密码类型
- loginType: "pwd", //pwd-密码登录 code-验证码登录
- username: "", //用户名
- password: "", //密码
- code: "", //验证码
- });
-
- onLoad(() => {
-
- });
-
- onUnload(() => {
-
- });
-
-
- /* 登录 */
- const doLogin = () => {
- if (!state.username) {
- msg("请输入手机号!");
- return;
- }
- if (state.loginType === "pwd" && !state.password) {
- msg("请输入密码!");
- return;
- }
- if (!checkStr(state.username, "mobile")) {
- msg("请输入正确的手机号!");
- return;
- }
-
- let reg = /^(?![0-9]+$)(?![a-zA-Z]+$)[0-9A-Za-z]{8,}$/;
- if (!reg.test(state.password)) {
- msg("密码长度至少为8位,由数字和字母组成");
- return;
- }
- console.log(state);
-
- const options = {
- type: 2,
- data: {
- mobile: state.username,
- password: tools.md5Str(state.password),
- },
- method: "POST",
- showLoading: true,
- };
- request(login, options).then((res) => {
- console.log(res);
- let result = stringToJson(res.bizcontnent)
-
- })
- };
- </script>
-
- <style lang="scss" scoped>
- .login-main {
- border-top: 1rpx solid #dcdcdc;
- padding: 22rpx 30rpx 140rpx;
-
- .logo {
- width: 260rpx;
- height: 160rpx;
- }
-
- .title {
- font-size: 46rpx;
- color: #333333;
- margin-top: 30rpx;
- font-weight: 600;
- }
-
- .form {
- width: 100%;
- margin-top: 100rpx;
-
- .form-input {
- display: flex;
- flex-direction: row;
- align-items: center;
- height: 90rpx;
- border-bottom: 1rpx solid #dcdcdc;
- padding: 0rpx 12rpx;
- color: #333333;
-
- &:last-child {
- margin-top: 50rpx;
- }
-
- .input {
- flex: 1;
- padding-right: 48rpx;
- font-size: 28rpx;
- font-family: Microsoft YaHei;
- }
-
- .arror {
- width: 28rpx;
- height: 25rpx;
- margin-left: 16rpx;
- margin-right: 40rpx;
- }
-
- .eye {
- width: 48rpx;
- height: 48rpx;
- }
- }
-
- .form-placeholder {
- color: #999999;
- }
- }
-
- .btn {
- width: 100%;
- margin: 120rpx 40rpx 50rpx;
- }
-
- .agreement {
- font-size: 24rpx;
- display: flex;
- align-items: center;
-
- .txt-grey {
- color: #666666;
- }
-
- .txt-green {
- color: #00b38b;
- }
-
- :deep(.u-checkbox) {
- margin-right: -20rpx;
- }
- }
-
- .btns {
- width: 100%;
- margin-top: 125rpx;
- justify-content: space-around;
- padding: 0px 8rpx;
-
- .bg {
- width: 80rpx;
- height: 80rpx;
- border-radius: 50%;
-
- .img {
- width: 48rpx;
- height: 48rpx;
- }
- }
-
- .blue {
- background-color: #1d9cff;
- }
-
- .orange {
- background-color: #feb654;
- }
-
- .purple {
- background-color: #8060ff;
- }
-
- .label {
- font-size: 26rpx;
- color: #333333;
- margin-top: 30rpx;
- }
- }
- }
- </style>
|