Files
crm-uni/pages/login/index.vue
T

331 lines
7.2 KiB
Vue
Raw Normal View History

2025-03-14 16:55:12 +08:00
<template>
<view class="page">
<view class="title">
2025-03-20 10:58:04 +08:00
<image src="/static/image/lingke.png" mode=""></image>
</view>
<view class="changeyy" @click="showlang = true">
<image src="/static/image/change1.png" mode=""></image>{{$t('home.langbtn')}}
2025-03-14 16:55:12 +08:00
</view>
<view class="form">
<view class="inputs_button">
<view class="inputs">
<view class="account">
2025-03-21 17:57:32 +08:00
<u--input
type="text"
:placeholder="$t('account')"
v-model="email"
border="none"
></u--input>
<!-- <input type="text" v-model="email" :placeholder="$t('account')" /> -->
2025-03-14 16:55:12 +08:00
</view>
2025-03-15 15:46:16 +08:00
<view class="password">
2025-03-14 16:55:12 +08:00
<u--input
type="password"
2025-03-19 15:39:21 +08:00
:placeholder="$t('password')"
2025-03-17 17:43:41 +08:00
v-model="password"
2025-03-14 16:55:12 +08:00
border="none"
></u--input>
</view>
</view>
2025-03-15 15:46:16 +08:00
<view class="forgot-password">
2025-03-19 15:39:21 +08:00
<view @click="regin">{{$t('reg')}}</view>
<view @click="forgotPassword">{{$t('fgpassword')}}?</view>
2025-03-15 15:46:16 +08:00
</view>
2025-03-14 16:55:12 +08:00
<view class="button">
<view @click="login">
2025-03-19 15:39:21 +08:00
{{$t('login')}}
2025-03-14 16:55:12 +08:00
</view>
</view>
</view>
<!-- <view class="three">
2025-03-19 15:39:21 +08:00
<u-divider :text="$t('threelogin')" style="padding: 0px 40px;"></u-divider>
2025-03-15 15:46:16 +08:00
<u-grid :border="false" @click="click" align="center">
<u-grid-item>
<image src="/static/image/login/fenshu.png" mode=""></image>
2025-03-19 15:39:21 +08:00
<text class="grid-text">{{$t('Facebook')}}</text>
2025-03-15 15:46:16 +08:00
</u-grid-item>
<u-grid-item>
<image src="/static/image/login/emali.png" mode=""></image>
2025-03-19 15:39:21 +08:00
<text class="grid-text">{{$t('email')}}</text>
2025-03-15 15:46:16 +08:00
</u-grid-item>
<u-grid-item>
<image src="/static/image/login/phone.png" mode=""></image>
2025-03-19 15:39:21 +08:00
<text class="grid-text">{{$t('phone')}}</text>
2025-03-15 15:46:16 +08:00
</u-grid-item>
</u-grid>
</view> -->
2025-03-19 15:39:21 +08:00
</view>
<view class="pact">
<radio :checked="pactChecked" activeBackgroundColor="#3264ed" activeBorderColor="#3264ed"
borderColor="#3264ed" color="#fff" @click="pactChange" />
2025-03-20 17:35:53 +08:00
<view>{{$t('agreeMsg')}}<text @click="navigateToAgreement">{{$t('UserAgreement')}}</text>{{$t('and')}}<text @click="navigateToPrivacy">{{$t('Privacy')}}</text></view>
2025-03-14 16:55:12 +08:00
</view>
2025-03-20 10:58:04 +08:00
<u-picker closeOnClickOverlay :cancel-text="$t('cancel')" :confirm-text="$t('confirm')" @close="close" :show="showlang" :columns="columns"
@cancel="cancellang" @confirm="confirmlang" :title="$t('home.langbtn')" keyName="label"></u-picker>
2025-03-14 16:55:12 +08:00
</view>
</template>
<script>
2025-03-15 15:46:16 +08:00
import { request,showToast } from '@/api/apiT.js'
2025-03-14 16:55:12 +08:00
export default {
data() {
return {
2025-03-20 18:07:52 +08:00
email: "",
password: "",
2025-03-14 16:55:12 +08:00
pactChecked: false,
2025-03-20 10:58:04 +08:00
showlang: false,
columns: [
[{
2025-03-20 17:35:53 +08:00
label: this.$t('zh'),
id: 'zh-Hans'
2025-03-20 10:58:04 +08:00
}, {
2025-03-20 17:35:53 +08:00
label: this.$t('en'),
2025-03-20 10:58:04 +08:00
id: 'en'
}]
],
2025-03-21 17:57:32 +08:00
language:'zh-Hans'
2025-03-14 16:55:12 +08:00
}
},
onLoad() {
2025-03-21 17:57:32 +08:00
if(uni.getStorageSync('token')){
uni.reLaunch({
url: '/pages/index/index',// 替换为你要跳转的页面路径
});
}
2025-03-14 16:55:12 +08:00
},
methods: {
2025-03-20 10:58:04 +08:00
close(){
this.showlang = false
},
cancellang() {
this.showlang = false
},
//语言切换事件
confirmlang(e) {
2025-03-22 09:36:48 +08:00
uni.setLocale(e.value[0].id)
2025-03-20 10:58:04 +08:00
this.$i18n.locale = e.value[0].id
2025-03-22 09:36:48 +08:00
// uni.setStorageSync('i18locale', e.value[0].id);
2025-03-21 17:57:32 +08:00
this.language = e.value[0].id
2025-03-20 10:58:04 +08:00
this.showlang = false
2025-03-20 17:35:53 +08:00
this.columns =[
[{
label: this.$t('zh'),
id: 'zh-Hans'
}, {
label: this.$t('en'),
id: 'en'
}]
];
2025-03-20 10:58:04 +08:00
this.list1 = [{
name: this.$t('all'),
}, {
name: this.$t('followup'),
}, {
name: this.$t('deal')
}, {
name: this.$t('lost')
}];
uni.setTabBarItem({
index: 0,
text: this.$t('tabbar.home')
})
uni.setTabBarItem({
index: 1,
text: this.$t('tabbar.customer')
})
uni.setTabBarItem({
index: 2,
text: this.$t('tabbar.mine')
})
},
2025-03-17 17:43:41 +08:00
pactChange() {
this.pactChecked = !this.pactChecked
},
2025-03-19 15:39:21 +08:00
regin(){
uni.navigateTo({
url: '/pages/login/register'
})
},
forgotPassword(){
uni.navigateTo({
url: '/pages/mine/resetPwd'
})
},
2025-03-14 16:55:12 +08:00
login() {
2025-03-15 15:46:16 +08:00
if(this.email==''){
uni.showToast({
2025-03-19 15:39:21 +08:00
title:this.$t('emailerr'),
2025-03-15 15:46:16 +08:00
icon: 'none'
});
return false
}
if(this.password==''){
uni.showToast({
2025-03-19 15:39:21 +08:00
title:this.$t('passworerr'),
2025-03-15 15:46:16 +08:00
icon: 'none'
});
return false
}
if(!this.pactChecked){
uni.showToast({
2025-03-19 15:39:21 +08:00
title:this.$t('agreementarr'),
2025-03-15 15:46:16 +08:00
icon: 'none'
});
return false
}
2025-03-21 17:57:32 +08:00
if(this.language=='zh-Hans'){
this.language= 'zh_CN'
}
2025-03-15 15:46:16 +08:00
request({
url:'user/login',
method:'POST',
data:{
email: this.email,
password: this.password,
2025-03-21 17:57:32 +08:00
language: this.language,
2025-03-15 15:46:16 +08:00
}
}).then(res => {
console.log(res.data.data)
if (res.data.code == -1) {
uni.showToast({
2025-03-19 15:39:21 +08:00
title: res.data.message,
2025-03-15 15:46:16 +08:00
icon: 'none'
2025-03-21 17:57:32 +08:00
});
2025-03-15 15:46:16 +08:00
} else if (res.data.code == 0) {
2025-03-17 17:43:41 +08:00
//存取session
2025-03-21 17:57:32 +08:00
uni.setStorageSync('userinfo',JSON.stringify(res.data.data));
2025-03-17 17:43:41 +08:00
uni.setStorageSync('token', res.data.data.token);
2025-03-15 15:46:16 +08:00
//返回数据接收成功
uni.reLaunch({
url: '/pages/index/index',// 替换为你要跳转的页面路径
});
2025-03-14 16:55:12 +08:00
}
})
},
2025-03-20 17:35:53 +08:00
navigateToAgreement() {
uni.navigateTo({
url: '/pages/login/agreement',// 替换为你要跳转的页面路径
});
},
navigateToPrivacy() {
uni.navigateTo({
url: '/pages/login/agreementuser',// 替换为你要跳转的页面路径
});
2025-03-14 16:55:12 +08:00
}
}
}
</script>
<style lang="scss" scoped>
2025-03-20 10:58:04 +08:00
.changeyy {
padding: 10px 15px;
border-radius: 50px;
background-color: #ECF2FF;
margin-bottom: 50rpx;
position: fixed;
right: 15px;
top: 5%;
color: #3471FF;
image {
width: 14px;
height: 12px;
margin-right: 5px;
}
}
2025-03-14 16:55:12 +08:00
.page {
min-height: 100vh;
2025-03-15 15:46:16 +08:00
background-image: url("../../static/image/login/loginbg.png");
2025-03-14 16:55:12 +08:00
background-size: 100%;
background-repeat: no-repeat;
display: flex;
flex-direction: column;
justify-content: space-between;
.title {
padding-top: 220rpx;
2025-03-15 15:46:16 +08:00
text-align: center;
image{
2025-03-20 10:58:04 +08:00
width: 128px;
height: 47px;
2025-03-14 16:55:12 +08:00
}
}
.form {
flex: 1;
2025-03-15 15:46:16 +08:00
margin: 0 76rpx;
2025-03-14 16:55:12 +08:00
overflow: hidden;
.inputs_button {
.inputs {
2025-03-15 15:46:16 +08:00
padding: 150rpx 0px 0;
margin-bottom: 20rpx;
2025-03-14 16:55:12 +08:00
.account,
2025-03-15 15:46:16 +08:00
.password{
height: 80rpx;
border-radius: 50px;
2025-03-14 16:55:12 +08:00
padding: 0 48rpx;
display: flex;
align-items: center;
2025-03-15 15:46:16 +08:00
background-color: #F6F6F6;
2025-03-14 16:55:12 +08:00
input {
flex: 1;
}
}
.account {
margin-bottom: 48rpx;
}
}
.button {
2025-03-20 17:35:53 +08:00
// padding: 0 32rpx;
2025-03-14 16:55:12 +08:00
view {
2025-03-15 15:46:16 +08:00
line-height: 80rpx;
border-radius: 50px;
2025-03-14 16:55:12 +08:00
text-align: center;
font-size: 32rpx;
2025-03-15 15:46:16 +08:00
background: linear-gradient(to right, #3471FF, #6776FF);
2025-03-14 16:55:12 +08:00
color: #fff;
}
}
}
2025-03-15 15:46:16 +08:00
.three{
margin: 40rpx 0px;
padding: 20rpx 40rpx;
image{
width: 100rpx;
height: 100rpx;
}
}
}
.forgot-password {
2025-03-19 15:39:21 +08:00
display: flex;
align-items: center;
justify-content:space-between;
// text-align: right;
2025-03-15 15:46:16 +08:00
margin-bottom: 20px;
2025-03-14 16:55:12 +08:00
}
.pact {
display: flex;
align-items: center;
justify-content: center;
font-size: 24rpx;
2025-03-20 10:58:04 +08:00
margin-bottom: 30px;
2025-03-14 16:55:12 +08:00
text {
color: #3264ed;
}
radio {
:deep(.uni-radio-input) {
border: 1rpx solid #3264ed;
}
transform:scale(0.6)
}
}
}
</style>