Rsd.define('Rsd.tool.LoginDialog', {
extend: 'Rsd.container.Dialog',
requires: [
'Rsd.form.Button',
'Rsd.form.Label',
'Rsd.form.Link',
'Rsd.form.CheckBox',
'Rsd.form.Image',
'Rsd.control.IframeBox',
'Rsd.control.ListView'
],
width:'40%',
height:600,
title:'用户登录',
/**
* Session 验证接口
*/
checkSessionServiceName:'mission.account.checksession',
items:[
{
xtype: 'container',
margin: '70 0 0 10%',
border: false,
height: 300,
width:'90%',
layout: 'vbox',
items: [
{
xtype: 'input',
inputType: 'text',
label: {content: '用户名', width: 100,height:35,style:{fontSize:'120%'}},
height: 40,
width:'70%',
emptyText: 'user id',
value: '',
margin: '0 0 0 0'
},
{
xtype: 'input',
inputType: 'password',
label: {content: '密 码', width: 100,height:35,style:{fontSize:'120%'}},
height: 40,
width:'70%',
emptyText: 'password',
margin: '25 0 0 0'
},
{
xtype: 'checkbox',
label: {content: '记住密码', position: 'right', align: 'left',width:'auto'},
height: 30,
width:80,
margin: '20 0 15 100'
},
{
xtype: 'button',
text: '登 录',
height:50,
width:'50%',
margin: '10 30 5 90',
accessKey:'enter',
border: false,
style:{
element:'ctrl',
borderColor:"#2182e6bf",
backgroundColor:"#2182e6bf",
color:"#ebebf5",
fontSize:"15px"
},
handler:'btn_login'
},
{
xtype: 'image',
id: 'loading',
margin:'10 50 0 90',
label:{content:'正在验证信息,请稍等...',position:'right',lineHeight:20,width:400},
src: './resources/images/loading.gif',
visible: false,
border: false,
width:430,
height: 40
}
]
},
//扫码登录
{
xtype:'iframe',
width:'50%',
label:{height:50,position:'top'},
height: 370,
hidden:true,
method:"get",
style:{color:'#000'},
ctrl:{ style:{overflow:'hidden'},},
margin: '0 0 0 25%',
src:'javascript:void(0);'
},
{
xtype: 'container',
header:{content:'其他登录方式',height:50,style:{borderBottom:'1px #504a43 solid'}},
height:150,
width:'90%',
margin: '0 0 0 5%',
layout:'hbox',
items:[
{
xtype:'image',
height:80,
flex:1,
imageStyle:{width:50,height:50,borderRadius:'25px'},
label:{content:'微信扫码登录',position:'bottom',aling:'center'},
src:'./resources/images/wechat.jpg',
handler:'btn_wechat'
},
{
xtype:'image',
height:70,
flex:1,
imageStyle:{width:50,height:50,borderRadius:'25px'},
label:{content:'手机号登录',position:'bottom',aling:'center'},
src:'./resources/images/mobile.jpg',
handler:'btn_mobile'
},
{
xtype:'image',
height:70,
flex:1,
imageStyle:{width:50,height:50,borderRadius:'25px'},
label:{content:'邮箱登录',position:'bottom',aling:'center'},
src:'./resources/images/email.jpg',
handler:'btn_email'
}
]
}
],
/**
*
* @param {*} config
*/
constructor: function HtmlShareBox(config) {
config = config || {};
this.apply(config);
// this.items[0].label.position = 'right';
// this.items[0].label.height = '100%';
// this.items[0].label.width = 100;
},
/**
*
*/
onAfterInit:function onAfterInit(){
var me = this;
me.callParent();
//注册信息接收事件:接受来自扫码登录 iframe的信息
window.addEventListener('message', function(event) {
//event.data获取传过来的数据
//console.log(event);
if(event.data)
{
setTimeout(function(){
var _token = event.data.token;
if(_token)
{
if(Rsd.isEmpty(me.checkSessionServiceName))
{
Rsd.alert('未设置属性checkSessionServiceName');
return;
}
Rsd.setAppToken(_token);
Rsd.requestService(me.checkSessionServiceName,{token:_token},function(_data){
//console.log(_data);
if (_data == null) {
Rsd.alert('请求验证失败,请联系管理员!');
return;
}
if(_data.success)
{
Rsd.setAppToken(_token);
Rsd.addCookie("token",_token);
me.close();
Rsd.app.restart();
//window.history.replaceState({token:_token}, '', url);
}
});
}
},10);
}
});
},
btn_login:function btn_login()
{
console.log(this.get('loading'));
this.get('loading').visible = true;
},
btn_wechat:function btn_wechat()
{
this.items[1].setSrc("https://vx.sellerpartner.cn/wxop/oauth2/login/49e75756-12ec-4dc5-9def-a6a4c4757dc4?state=LoginSP&style=black&self=true&css=https%3A%2F%2Fvx.sellerpartner.cn%2Fwxop%2Foauth2%2Fcss%2F49e75756-12ec-4dc5-9def-a6a4c4757dc4");
this.items[0].hide();
this.items[1].show();
},
btn_mobile:function btn_mobile()
{
alert('未开通手机号登录服务');
},
btn_email:function btn_email()
{
alert('未开通邮箱登录服务');
}
});