|
楼主 |
发表于 2017-2-21 20:41:24
|
显示全部楼层
js:
define(function(require){
var $ = require("jquery");
var justep = require("$UI/system/lib/justep");
var sfwq = 0;
var id = null;
var Model = function(){
this.sfkyfs = justep.Bind.observable(false);
this.callParent();
};
Model.prototype.backBtnClick = function(event){
if(sfwq ==0){
lxr = lxrdata.find(['ID'], [id], true,false,false);
if(lxr.length!=0)lxr[0].val("xxsl", 0);}
this.owner.close();
};
Model.prototype.sendBtnClick = function(event){
this.sendMsg();
};
Model.prototype.sendMsg = function(){
var msg= this.comp("msgContent").val();
var me =this;
var list=this.comp("list1");
if(msg==null||msg.trim().length==0){
layer.msg ("不能发送空消息");
return;
}
this.owner.getModel().fasmsg(sfwq,id,1,msg);
//
me.comp("scrollView").scrollTo("end");
//清空内容
this.comp("msgContent").clear();
me.comp("scrollView").scrollTo("end");
};
Model.prototype.msgContentKeypress = function(event){
// 回车键事件
if(event.which == 13) {
this.sendMsg();
}
};
Model.prototype.sendBtnTouchstart = function(event){
};
Model.prototype.sendBtnTouchend = function(event){
this.comp("sendBtn").removeClass("btn-onclick");
};
Model.prototype.modelLoad = function(event){
};
Model.prototype.setxxgl = function(row){
this.comp("scrollView").scrollTo("end");
if(sfwq == 0){
//row.val(row.val())
if(row.val("sfwg") != 0)return false;
if(row.val("Uid") != id)return false;
}else if(row.val("Gid") != id)return false;
return true;
};
Model.prototype.modelParamsReceive = function(event){
sfwq = event.params.data.sfwq;
id = event.params.data.id;
var name = event.params.data.name;
if(sfwq == 0){
this.comp("backBtn").set({"label" : "与 " + name + " 聊天"});
this.comp("buttonbt").set({"label" : ""});
}
else {
this.comp("buttonbt").set({"label" : name });
this.comp("backBtn").set({"label" : ""});
}
this.comp("list1").refresh();
};
Model.prototype.pdsj = function(createTime){
var time = justep.Date.fromString(createTime,'yyyy-MM-dd hh:mm:ss');
var currentTime = new Date();
var ges= "hh:mm";
if(!createTime)return "null";if(between === 0)return "";
/*var between = justep.Date.diff(time,currentTime,'h');
if(between === 0)return "";*/
var between = justep.Date.diff(time,currentTime,'h');
if(between >= 24)
{
between = justep.Date.diff(time,currentTime,'m');
if(between < 12)ges = "MM/dd hh:mm";
else ges = "yyyy-MM-dd hh:mm";
}
return justep.Date.toString(time, ges);
};
Model.prototype.i4Click = function(event){
var row = event.bindingContext.$object;
this.getParentModel().retruefasmsg(row.val("hdsj"));
};
Model.prototype.button1Click = function(event){
$(this.getElementByXid('inputImage')).click();
};
Model.prototype.file1Change = function(event) {
var self = this;
// 从选取文件对话框返回后,检查用户是否选择了文件,是否选择了图片文件
if (!event.target.files) {
return;
}
var $inputImage = $(this.getElementByXid('inputImage'));
var file = event.target.files[0];
if (/^image\/\w+$/.test(file.type)) {
$(this.getElementByXid('inputImage')).val();
//file = URL.createObjectURL(file);
//file = $(this.getElementByXid('inputImage')).val()[0]
//alert(.fileName)
this.owner.getModel().fasmsg(sfwq,id,4,file);
} else {
layer.msg('请选择图片文件!');
}
};
Model.prototype.msgContentChange = function(event){
alert("");
/*if(this.comp("msgContent").val() != "")this.sfkyfs.set(true);
else this.sfkyfs.set(false);*/
/*if(this.comp("msgContent").val() != ""){this.comp("sendBtn").addClass("btn-onclick");}
else this.comp("sendBtn").removeClass("btn-onclick");*/
};
return Model;
}); |
|