151 lines
4.4 KiB
Vue
151 lines
4.4 KiB
Vue
<template>
|
|
<view>
|
|
<view class="hz-text-center" style="padding-top:200rpx;">
|
|
<image src="../../static/images/logo.png" style="width:138rpx;height:140rpx;"></image>
|
|
</view>
|
|
<view class="hz-font-bolder hz-font-xl hz-text-center hz-font-color-primary">
|
|
{{$t('common.appName')}}
|
|
</view>
|
|
<view class="hz-font-bolder hz-font-xl hz-text-center hz-font-color-dark" style="margin-top:160rpx;">
|
|
Mockup IDP Login
|
|
</view>
|
|
<view style="margin-top:30rpx;margin-right:60rpx;margin-left:60rpx;">
|
|
<u--input
|
|
v-model="userId"
|
|
placeholder="Login User ID"
|
|
prefixIcon="account"
|
|
prefixIconStyle="font-size: 20px;color:#C39A4B;"
|
|
customStyle="border-radius:22px;"
|
|
></u--input>
|
|
</view>
|
|
<view style="margin-top:30rpx;margin-right:60rpx;margin-left:60rpx;">
|
|
<u--input
|
|
v-model="password"
|
|
placeholder="Login Password"
|
|
prefixIcon="lock-open"
|
|
:password="true"
|
|
prefixIconStyle="font-size: 20px;color: #C39A4B"
|
|
customStyle="border-radius:22px;"
|
|
></u--input>
|
|
</view>
|
|
<!--<view style="margin-top:30rpx;margin-right:60rpx;margin-left:60rpx;">
|
|
<u-radio-group
|
|
v-model="propertyCode"
|
|
placement="row">
|
|
<u-radio activeColor="#C39A4B" label="Macau" name="MM" customStyle="width:50%;" @change="changeProperty"></u-radio>
|
|
<u-radio activeColor="#C39A4B" label="Cotai" name="MC" @change="changeProperty"></u-radio>
|
|
</u-radio-group>
|
|
</view>-->
|
|
<view style="margin-top:30rpx;margin-right:60rpx;margin-left:60rpx;">
|
|
<view @click="mockSSOLogin" class="hz-btn hz-font-color-white hz-font-lg hz-font-bold hz-text-center" >{{$t("common.loginsso")}}</view>
|
|
</view>
|
|
<u-modal :content="msgStr" :show="showMsg" :confirmText="yesText" closeOnClickOverlay @confirm="confirmMsg" confirmColor="#C39A4B" @cancel="cancelMsg" @close="cancelMsg"></u-modal>
|
|
</view>
|
|
</template>
|
|
|
|
<script>
|
|
import CryptoJS from 'crypto-js';
|
|
import {mockUserSSOLogin} from '../../api/ssoApi.js'
|
|
export default {
|
|
data() {
|
|
return {
|
|
// 数据变量
|
|
userId: '',
|
|
password:'',
|
|
propertyCode:'MM',
|
|
userData:null,
|
|
deviceData:null,
|
|
siteData:null,
|
|
// 界面变量
|
|
msgStr:'',
|
|
showMsg:false,
|
|
yesText:this.$t("common.ok"),
|
|
|
|
}
|
|
},
|
|
onLoad() {
|
|
// 初始化界面
|
|
this.initUI();
|
|
this.siteData = uni.getStorageSync("siteData");
|
|
this.userData = uni.getStorageSync("userData");
|
|
},
|
|
onShow() {
|
|
},
|
|
methods: {
|
|
// 加密方法
|
|
hashPassword(pwd){
|
|
if(!pwd){
|
|
return '';
|
|
}
|
|
return CryptoJS.SHA256(pwd).toString(CryptoJS.enc.Hex);
|
|
},
|
|
// 数据方法
|
|
async mockSSOLogin(){
|
|
uni.showLoading({
|
|
title: this.$t("common.loading")
|
|
});
|
|
try{
|
|
const encryptedPassword = this.hashPassword(this.password);
|
|
let params = {userId:this.userId, credential:encryptedPassword, propertyCode:this.propertyCode};
|
|
const res = await mockUserSSOLogin(params);
|
|
|
|
if(res.success === true){
|
|
if(res.data !== null){
|
|
uni.redirectTo({
|
|
url:'/pages/login/login?code=' + res.accessToken
|
|
})
|
|
}
|
|
}else if(res.errorCode!==undefined && res.errorCode == 'ERROR_LOCKED'){
|
|
this.msgStr = this.$t("common.userLocked");
|
|
this.showMsg = true;
|
|
} else if (res != null && res.code == 'ERROR_LOCKED') {
|
|
this.msgStr = this.$t("common.userLocked");
|
|
this.showMsg = true;
|
|
} else if (res != null && res.code == 'ERROR_IP_BANNED') {
|
|
this.msgStr = this.$t("common.ipLocked");
|
|
this.showMsg = true;
|
|
} else {
|
|
this.msgStr = 'Login failed.';
|
|
this.showMsg = true;
|
|
}
|
|
}catch(e){
|
|
this.writeLog(this.userId,"mockSSOLogin","","[APP][ssoLogin.vue][mockSSOLogin]catch error"+JSON.stringify(e),"","",1,false);
|
|
if(e.data !== undefined && e.data.errorCode !== undefined && e.data.errorCode !==""){
|
|
if(e.data.errorCode == 'ERROR_LOCKED'){
|
|
this.msgStr = this.$t("common.userLocked");
|
|
this.showMsg = true;
|
|
}
|
|
}else{
|
|
this.msgStr = "System Error";
|
|
this.showMsg = true;
|
|
}
|
|
}finally{
|
|
uni.hideLoading();
|
|
}
|
|
},
|
|
// 界面方法
|
|
changeProperty(e){
|
|
this.propertyCode = e;
|
|
},
|
|
initUI() {
|
|
this.deviceData = uni.getStorageSync("deviceData");
|
|
},
|
|
confirmMsg(){
|
|
this.showMsg = false;
|
|
},
|
|
cancelMsg(){
|
|
this.showMsg = false;
|
|
}
|
|
},
|
|
}
|
|
</script>
|
|
|
|
<style>
|
|
.u-border {
|
|
border-width: 0.5px !important;
|
|
border-color: #434343 !important;
|
|
border-style: solid;
|
|
height:30px;
|
|
}
|
|
</style>
|