红绿项目
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.
 
 
 
 

220 lines
4.8 KiB

<template>
<view class="">
<navigation :showBack="false">
<image :src="logoUrl" mode="aspectFit" class="logo" slot="logo"></image>
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" @input="btnControl()" style="height: 50px;" />
</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="password"
placeholder-style="color: #BFC2CCFF;font-size:14px;" v-model="password" style="height: 50px;" />
</view>
<view class="rePass" @click="gores()">
Reset Password
</view>
<button class="login-btn" @click="login()" :class="btncol==1?'on':''" :disabled="btncol==1?false:true">
Login
</button>
<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() {
const ticket= uni.getStorageSync('logInfo').data;
if(ticket!=''&&ticket!=undefined&&ticket!=null){
uni.reLaunch({
url:'../menu/goods/index'
})
}
// console.log(uni.getSystemInfoSync().platform)
this.siteInfoData = uni.getStorageSync('siteInfo')
this.countryCode = uni.getStorageSync('countryCode')
const siteInfo = api.siteInfo()
siteInfo.then(d => {
let that = this
uni.setStorage({
key: 'siteInfo',
data: d.data,
success: function() {
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
// if(ticket != ''){
// uni.navigateTo({
// url: '../menu/index/index'
// })
// }
},
methods: {
btnControl() {
this.btncol = 1;
if (this.mobile == '') {
this.btncol = 0;
}
},
gores() {
uni.navigateTo({
url: './resetPassword/index'
})
},
goReg() {
uni.navigateTo({
url: '../register/index'
})
},
login() {
uni.showLoading({
title: 'loading'
});
if (this.mobile == '') {
uni.showToast({
title: 'Please input mobile 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;
// }
const post = api.login({
"mobile": this.mobile,
'password': md5(this.password),
})
post.then(res => {
var that = this;
if (res.errCode == "SUCCESS") {
// #ifdef H5
var url = uni.getStorageSync('url');
if(url){
location.href=url
}
// #endif
uni.setStorage({
key: 'logInfo',
data: res,
success: function() {
console.log('success')
}
});
uni.setStorage({
key: 'loginMobile',
data: this.mobile,
success: function() {
console.log('success', 8686668)
}
});
uni.showToast({
title: 'Successful login',
icon: 'success',
duration: 1500
})
setTimeout(function() {
uni.reLaunch({
url: '../menu/goods/index'
})
}, 1500)
console.log(uni.getStorageSync('logInfo').data, 66666666666666666666)
} else {
uni.showToast({
title: res.errMsg,
icon: 'none',
duration: 2500
})
}
})
.catch(e => {
uni.showToast({
title: e,
icon: 'none',
duration: 2500
})
})
}
},
}
</script>
<style>
@import './index.css';
</style>