Ext.namespace('ExtFrame.ui');
ExtFrame.ui.ChatWin = function(_toUserName, _currentUser) { var toUserName = _toUserName;
var currentUser = _currentUser;
var win = null;
/**
 * @method creteWin
 * @public
 * @description create the ChatWin
 */
var createWin = function() {
win = new Ext.Window({
title : currentUser+' 与 ' + toUserName + ' 聊天中',
id : toUserName,
width : 515,
height : 450,
collapsible : true,
labelAlign : 'left',
labelWidth : 60,
hideLabel : false,
maximizable : true,
border : false,
layout : 'border',
frame : true,
    
items : [{
region : 'center',
border : 0,
height : 150,
xtype : 'panel',
id : 'showMsg',
layout : 'fit',
bodyStyle : 'padding:10px;'
}, {
region : 'south',
minHeight : 150,
split : true,
xtype : 'form',
layout:'fit',
border : false,
hideLabels : true,
bodyStyle : 'background:transparent;',
height : 150,
items : [
{
xtype : 'htmleditor',
id : 'editMsg',
fieldLabel : '',
name : 'editMsg',
height:130,
value:'ddddddddddd',
allowBlank : false,
anchor : '0-50',
border : false

}],
 tbar:[{   
                text:'视频',   
                tooltip:'视频聊天',   
                iconCls:'user'  
            },'-',{   
                text:'语音',   
                tooltip:'语音聊天',   
                iconCls:'email'  
            },{   
                text:'邮件',   
                tooltip:'语音聊天',   
                iconCls:'email'  
            },{   
                text:'聊天记录',   
                tooltip:'语音聊天',   
                iconCls:'email'  
            },{   
                text:'个人资料',   
                tooltip:'语音聊天',   
                iconCls:'user'  
            },{   
                text:'截图',   
                tooltip:'语音聊天',   
                iconCls:'user'  
            },{   
                text:'发送附件',   
                tooltip:'语音聊天',   
                iconCls:'user'  
            }],   
buttons : [{
text : '发送',
handler : function (){
    

var message = this.ownerCt.form.items.items[0].getValue();
var sendDate = new Date().format('Y-m-d H:i:s');
var showPanel = this.ownerCt.ownerCt.getComponent(0);
var formatMsg = "<div class='_msgtitle' style='color:blue'>"
+ currentUser + " " + sendDate + "</div><div class='_msg'>"
+ message + "</div>";
showPanel.body.insertHtml("beforeEnd", formatMsg);
showPanel.body.scroll('bottom', 9999);
this.ownerCt.form.items.items[0].reset();
submitMsg(message);
}
}, {
text : '关闭',
handler : closeWin
}]
}]
});
win.show();

}
/**
 * @method sendMsg
 * @private
 * @description view your messages dynamicly
 */
var viewMsg = function() {

} /**
 * @method closeWin
 * @private
 * @description close the chatWin
 */
var closeWin = function() {
Ext.getCmp(toUserName).close();
}
/**
 * @method submitMsg
 * @param message
 * @private
 * @description submit the messages to the server
 */
var submitMsg = function(message) {
var conn = new Ext.data.Connection();
conn.request({
url : 'qq.do?method=sentMsg',
method : 'POST',
params : {
fromUserName : currentUser,
toUserName : toUserName,
message : message
},
sucess : function(responseObject) { },
failure : function() {
Ext.Msg.alert('发送失败', responseObject.statusText);
}
});
}
return {
/**
 * @method init
 * @public
 * @description initializes the win
 */
init : function() {
if (!win) {
createWin();
} else
win.show();
}
}
}代码粘贴出来了。请大家帮我看看,为什么不能这样用。都搞了1天了,没有一点进展。着急的很啊

解决方案 »

  1.   

    好像不是scope的原因吧。我吧很多地方都加上了scopt:this,但还是抱那个错误啊。代码粘出来。大家看看。更改后的代码。Ext.namespace('ExtFrame.ui');
    ExtFrame.ui.ChatWin = function(_toUserName, _currentUser) { var toUserName = _toUserName;
    var currentUser = _currentUser;
    var win = null;
    /**
     * @method creteWin
     * @public
     * @description create the ChatWin
     */
    var createWin = function() {
    win = new Ext.Window({
    title : currentUser+' 与 ' + toUserName + ' 聊天中',
    id : toUserName,
    width : 515,
    height : 450,
    collapsible : true,
    labelAlign : 'left',
    labelWidth : 60,
    hideLabel : false,
    maximizable : true,
    border : false,
    layout : 'border',
    frame : true,
        scope : this,
    items : [{
    region : 'center',
    border : 0,
    height : 150,
    xtype : 'panel',
    id : 'showMsg',
    scope : this,
    layout : 'fit',
    bodyStyle : 'padding:10px;'
    }, {
    region : 'south',
    minHeight : 150,
    split : true,
    xtype : 'form',
    layout:'fit',
    border : false,
    hideLabels : true,
    bodyStyle : 'background:transparent;',
    height : 150,
    scope : this,
    items : [
    {
    xtype : 'htmleditor',
    id : 'editMsgssssss',
    fieldLabel : '',
    name : 'editMsg',
    height:130,
    scope : this,
    value:'ddddddddddd',
    allowBlank : false,
    anchor : '0-50',
    border : false

    }],
     tbar:[{   
                    text:'视频',   
                    tooltip:'视频聊天',
                    scope : this,   
                    iconCls:'user'  
                },'-',{   
                    text:'语音',   
                    tooltip:'语音聊天', 
                    scope : this,  
                    iconCls:'email'  
                },{   
                    text:'邮件',   
                    tooltip:'语音聊天',  
                    scope : this, 
                    iconCls:'email'  
                },{   
                    text:'聊天记录',   
                    tooltip:'语音聊天', 
                    scope : this,  
                    iconCls:'email'  
                },{   
                    text:'个人资料',   
                    tooltip:'语音聊天',  
                    scope : this, 
                    iconCls:'user'  
                },{   
                    text:'截图',   
                    tooltip:'语音聊天',   
                    scope : this,
                    iconCls:'user'  
                },{   
                    text:'发送附件',   
                    tooltip:'语音聊天',   
                    scope : this,
                    iconCls:'user'  
                }],   
    buttons : [{
    text : '发送',
    scope : this,
    handler : function (){
         var message = this.ownerCt.form.items.items[0].getValue();
    var sendDate = new Date().format('Y-m-d H:i:s');
    var showPanel = this.ownerCt.ownerCt.getComponent(0);
    var formatMsg = "<div class='_msgtitle' style='color:blue'>"
    + currentUser + " " + sendDate + "</div><div class='_msg'>"
    + message + "</div>";
    showPanel.body.insertHtml("beforeEnd", formatMsg);
    showPanel.body.scroll('bottom', 9999);
    this.ownerCt.form.items.items[0].reset();
    submitMsg(message);
    }
    }, {
    text : '关闭',
    handler : closeWin
    }]
    }]
    });
    win.show();

    }
    /**
     * @method sendMsg
     * @private
     * @description view your messages dynamicly
     */
    var viewMsg = function() {

    } /**
     * @method closeWin
     * @private
     * @description close the chatWin
     */
    var closeWin = function() {
    Ext.getCmp(toUserName).close();
    }
    /**
     * @method submitMsg
     * @param message
     * @private
     * @description submit the messages to the server
     */
    var submitMsg = function(message) {
    var conn = new Ext.data.Connection();
    conn.request({
    url : 'qq.do?method=sentMsg',
    method : 'POST',
    params : {
    fromUserName : currentUser,
    toUserName : toUserName,
    message : message
    },
    sucess : function(responseObject) { },
    failure : function() {
    Ext.Msg.alert('发送失败', responseObject.statusText);
    }
    });
    }
    return {
    /**
     * @method init
     * @public
     * @description initializes the win
     */
    init : function() {
    if (!win) {
    createWin();
    } else
    win.show();
    }
    }
    }
      

  2.   

     ——————————如果我没有猜错的花,你可能用的ext2.2 之后的版本吧,ext2.1这个好事,但之后好像不好使,我听别人给我讲这个的时候,是用的2。1 我自己用的3.0,也提示那样的错误,正在研究中