Files
ClassContent/历届学生/逯帅帅/项目开发/上课项目/医点医滴/pages/login/login.vue
2024-09-27 02:06:13 +08:00

320 lines
8.1 KiB
Vue

<template>
<view class="content h-100">
<view class="imgaaa">
<!-- <image src="/static/login/login.png"></image> -->
<view v-if="login_flag" class="L_left">登录</view>
<view v-if="!login_flag" class="L_left">注册</view>
</view>
<view class="L_Z">
<view class="L_Z_A">
<view class="menu_items" @click="chooseMenu(index)" :class="{menu_active: menu_index==index}" v-for="(item,index) of form_menu" :key='index'>{{item.name}}</view>
</view>
</view>
<!-- 登录 -->
<view class="my_L_Z" v-if="menu_index==0">
<view class="my_phone">
<image src="/static/login/phone.png" mode="" class="phone"></image>
<input class="inputtt" type="text" cursor-spacing="20" focus placeholder="请输入手机号" v-model="phone"/>
</view>
<view class="my_key">
<image src="/static/login/suo.png" mode="" class="phone"></image>
<input class="inputtt" cursor-spacing="20" :type="is_type" placeholder="请输入密码" v-model="password"/>
<image src="/static/login/bukan.png" mode="" class="is_seen" v-if="seen==false" @tap='change_seen()'></image>
<image src="/static/login/kan.png" mode="" class="is_seen1" v-if="seen==true" @tap='change_seen()'></image>
</view>
<button class="my_login" @tap="UserLogin">登录</button>
<text class="my_forget">忘记密码?</text>
</view>
<!-- 注册 -->
<view class="my_L_Z" v-if="menu_index==1">
<view class="my_phone">
<image src="/static/login/phone.png" mode="" class="phone"></image>
<input class="inputtt" type="text" cursor-spacing="20" focus placeholder="请输入手机号" v-model="phone"/>
</view>
<view class="my_key">
<image src="/static/login/loginadd.png" mode="" class="phone" style="height: 21px;width: 27px;"></image>
<input class="inputtt" type="number" placeholder="验证码">
<view class="yanzheng" v-if="get_code==false" @click="getCode()">获取验证码</view>
<view class="yanzheng" v-else>{{count_time}}s后再次获取验证码</view>
</view>
<view class="my_key">
<image src="/static/login/suo.png" mode="" class="phone"></image>
<input class="inputtt" cursor-spacing="20" :type="is_RseenType" placeholder="请设置密码" v-model="new_password"/>
<image src="/static/login/bukan.png" mode="" class="is_seen" v-if="Rseen==false" @tap='change_Rseen()'></image>
<image src="/static/login/kan.png" mode="" class="is_seen1" v-if="Rseen==true" @tap='change_Rseen()'></image>
</view>
<view class="my_key">
<image src="/static/login/suo.png" mode="" class="phone"></image>
<input class="inputtt" cursor-spacing="20" :type="is_rseenType" placeholder="确认密码" v-model="sure_password"/>
<image src="/static/login/bukan.png" mode="" class="is_seen" v-if="rseen==false" @tap='change_rseen()'></image>
<image src="/static/login/kan.png" mode="" class="is_seen1" v-if="rseen==true" @tap='change_rseen()'></image>
</view>
<button class="my_login" @tap='UserReg'>注册</button>
<view class="agree">
<view>点击“注册”即表示您已阅读并同意</view>
<view style="color: #D82008;">《医点医滴会员服务协议》</view>
</view>
</view>
</view>
</template>
<script>
import md5 from "../../utils/md5.min.js";
export default{
data() {
return {
seen:false,
Rseen:false,
rseen:false,
login_flag:true,
is_type:'password',
is_RseenType:'password',
is_rseenType:'password',
form_menu:[{
name:'登录',
id:0
},{
name:'注册',
id:1
}],
menu_index:0,
get_code:false,
phone:'',
password:'',
new_password: '',
sure_password: '',
};
},
methods:{
// jinru(){
// uni.switchTab({
// url: '/pages/index/index'
// });
// },
// 密码内容是否可见
change_seen(){
this.seen = !this.seen
if(this.seen == true){
this.is_type = 'text'
}else{
this.is_type = 'password'
}
},
change_rseen(){
this.rseen = !this.rseen
if(this.rseen == true){
this.is_rseenType = 'text'
}else{
this.is_rseenType = 'password'
}
},
change_Rseen(){
this.Rseen = !this.Rseen
if(this.Rseen == true){
this.is_RseenType = 'text'
}else{
this.is_RseenType = 'password'
}
},
// 选择菜单(登录或者注册)
chooseMenu(index){
// 解决登录 或 注册 重复点击标题切换
if (this.menu_index != index){
this.menu_index = index;
this.login_flag = !this.login_flag
}
},
// 注册
async UserReg() {
if (!this.$util.checkPhone(this.phone)) {
this.$toast.fail("手机号必须正确");
return false;
}
if (this.new_password.length == 0) {
this.$toast.fail("密码必填");
return false;
}
if (this.sure_password.length == 0) {
this.$toast.fail("密码必填");
return false;
}
let res = await this.$http.index.reg(this.phone,this.new_password,this.sure_password);
// this.currentPage = true;
},
//登录
async UserLogin() {
if (this.phone.length == 0) {
uni.showToast({
title: '号码必填',
duration: 2000
})
return false;
}
if (this.password.length == 0) {
uni.showToast({
title: '密码必填',
duration: 2000
})
return false;
}
var now_time = (Date.parse(new Date()))/1000;
var is_sign = md5('123456' + 'test' + this.phone + md5(this.password) + now_time)
let res = await this.$http.index.login({
phone: this.phone,
password: this.password,
appid: "test",
timestamp: now_time,
sign: is_sign
});
localStorage.setItem("token", res.access_token);
setTimeout(function() {
uni.switchTab({
url: '/pages/index/index'
})
}, 500);
},
}
}
</script>
<style scoped lang="less">
.content {
line-height: 1.8;
.imgaaa{
height: 202px;
padding-top: 30px;
position: relative;
background-image: url(/static/login/login.png);
background-position: 100% 100%;
background-size: cover;
border:none;
outline: none;
-webkit-box-sizing: border-box;
.L_left{
font-size: 16px;
// margin-top:30px;
text-align: center;
color: #FFFFFF;
}
}
.L_Z{
padding: 0 32px;
font-size: 13px;
line-height: 1.8;
.L_Z_A{
display: flex;
font-size: 13px;
line-height: 1.8;
.menu_items{
margin-right:22px;
}
}
.menu_active{
color: #282828;
font-size: 16px;
border-bottom:3px solid #6B68DC;
font-weight: bold;
}
}
.my_L_Z{
padding: 50px 32px;
.my_phone{
border-bottom: 3px solid #F2F2F2;
height: 50px;
display: flex;
align-items: center;
.phone{
height: 20px;
width: 18px;
}
.inputtt{
height:20upx;
width:47upx;
border: none;
outline: none;
padding-left: 10px;
height: 100%;
width: 100%;
}
}
.my_key{
border-bottom: 3px solid #F2F2F2;
height: 50px;
display: flex;
align-items: center;
.phone{
height: 20px;
width: 18px;
}
.inputtt{
height:20upx;
width:47upx;
border: none;
outline: none;
padding-left: 10px;
height: 100%;
width: 100%;
}
.is_seen{
height: 10px;
width: 23px;
}
.is_seen1{
height:30upx;
width:47upx;
}
}
.my_login{
margin-top: 30px;
height: 34px;
color: #FFFFFF;
text-align: center;
line-height: 34px;
font-size: 15px;
background: linear-gradient(to left,#6B68DC,#008BE6);
}
.my_forget{
display: inline-block;
margin: 7px 0;
color: #6B6AD5;
border-bottom: 0.5px solid #6B6AD5;
font-size: 13px;
// line-height: 1.8;
}
.yanzheng{
color: #D82008;
font-size: 12px;
width: 50%;
text-align: right;
}
.agree {
font-size: 13px;
display: -webkit-box;
overflow: hidden;
white-space: normal !important;
text-overflow: ellipsis;
word-wrap: break-word;
-webkit-line-clamp: 3;
-webkit-box-orient: vertical
}
}
}
</style>