红绿项目
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 

203 lines
4.8 KiB

<template>
<view class="">
<navigation>Login</navigation>
<view class="login-body">
<view class="input-item flex">
<view class="login-sigh flex">
<view class="imgcon">
<image src="../../static/login/[email protected]" mode=""></image>
</view>
<span class="quhao">+{{areacode}}</span>
</view>
<input type="text" value="" placeholder="mobile number"
placeholder-style="color: #BFC2CCFF;font-size:14px;" v-model="mobile" @focus="btncol=1" @blur="btncol=2" />
</view>
<view class="input-item flex">
<view class="login-sigh login-sigh2 flex">
<view class="imgcon">
<image src="../../static/login/[email protected]" mode=""></image>
</view>
</view>
<input type="password" value="" placeholder="New password"
placeholder-style="color: #BFC2CCFF;font-size:14px;" v-model="password" @focus="btncol=1" @blur="btncol=2" />
</view>
<view class="rePass" @click="gores()">
Reset Password
</view>
<view class="login-btn" @click="login()" :class="btncol==1?'on':''">
Login
</view>
<view class="login-re" @click="goReg()">
Register
</view>
</view>
</view>
</template>
<script>
import api from '@/utils/api'
import utils from '@/utils'
import md5 from 'js-md5'
import store from '@/store'
import cont from "@/components/navigation/navigation.vue"
export default {
data() {
return {
mobile: '',
password: '',
siteInfoData: {},
countryCode: {},
logoUrl: '',
btncol:0,
areacode:'',
siteName:'',
}
},
onLoad() {
this.siteInfoData = uni.getStorageSync('siteInfo')
this.countryCode = uni.getStorageSync('countryCode')
console.log(this.siteInfoData, 9999)
console.log(this.countryCode, 99999)
const siteInfo = api.siteInfo()
siteInfo.then(d => {
let that = this
uni.setStorage({
key: 'siteInfo',
data: d.data,
success: function() {
console.log('success')
that.logoUrl = d.data.siteDomain + d.data.siteLogo
that.siteName = d.data.siteName
that.areacode=d.data.areaCode
}
});
this.siteInfoData = d.data
})
.catch((e) => {
console.log(e)
})
this.logoUrl = this.siteInfoData.siteDomain + this.siteInfoData.siteLogo
this.siteName = this.siteInfoData.siteName
// const ticket = this.$store.state.ticket
const ticket= uni.getStorageSync('logInfo').data;
console.log(ticket,7777777777777777777)
if (ticket != '') {
uni.navigateTo({
url: '../index/index'
})
} else {
//页面加载完成,获取本地存储的用户名及密码
// this.account = this.$store.state.account;
// this.password = this.$store.state.password;
}
},
methods: {
gores(){
uni.navigateTo({
url: './resetPassword/index'
})
},
goReg() {
uni.navigateTo({
url: '../register/index'
})
},
login() {
if (this.mobile == '') {
uni.showToast({
title: ' Please enter the login Phone Number',
icon: 'none',
duration: 1500
})
return;
}
if (this.password == '') {
uni.showToast({
title: 'password is empty',
icon: 'none',
duration: 1500
})
return;
}
var a= /^(?![0-9]+$)(?![a-zA-Z]+$)[0-9A-Za-z]{5,19}$/;
if(!a.test(this.password)){
uni.showToast({
title: 'Incorrect password format,a password requires a combination of numbers and letters',
icon: 'none',
duration: 1500
})
return;
}
if(this.password.length<6||this.password.length>20){
uni.showToast({
title: 'The login password requires 6-20 digits',
icon: 'none',
duration: 1500
})
return;
}
uni.request({
url: '/start/api/user/login',
data: {
"mobile": this.mobile,
'password': md5(this.password),
},
header: {
'Content-Type': 'application/x-www-form-urlencoded;charset=utf-8' //自定义请求头信息
},
method: 'POST', //请求方式 或GET,必须为大写
success: (res) => {
uni.setStorage({
key: 'logInfo',
data: res.data,
success: function() {
console.log('success',999)
}
});
if(res.data.errCode=="SUCCESS"){
uni.showToast({
title: res.data.errMsg,
icon: 'success',
duration: 1500
})
setTimeout(function(){
uni.reLaunch({
url:'../index/index'
})
},2500)
}else{
uni.showToast({
title: res.data.errMsg,
icon: 'none',
duration: 2500
})
}
console.log(res.data,9990);
},
fail: (res) => {
uni.showToast({
title: res.data.errMsg,
icon: 'none',
duration: 2500
})
console.log(res.data);
}
});
}
},
}
</script>
<style>
@import './index.css';
</style>