|
版本: |
BeX5V3.1 |
小版本号: |
3.4 |
|
|
数据库: |
MS SQLServer |
服务器操作系统: |
Windows |
应用服务器: |
Tomcat |
客户端操作系统: |
Windows 7 |
浏览器: |
Chrome |
|
|
这里的拍照功能仿pai案例,但是绑定获取图片的这一段始终报错,应该是$object上下文对象获取得不对,跟踪的结始终是model对象,但是我仔细对比了pai案例的源码,几乎都一致了啊,为什么pai案例$object就能获取到当前行对象,而我的代码始终获取不到呢,能帮忙指点一下吗,十分感谢,为这个问题折腾好几天了,始终找不到原因。
附上我的源码:
<?xml version="1.0" encoding="utf-8"?>
<div xmlns="http://www.w3.org/1999/xhtml" xid="window" class="window" component="$UI/system/components/justep/window/window"
design="device:m;">
<div component="$UI/system/components/justep/model/model" xid="model" style="top:228px;left:64px;height:auto;"
>
<div component="$UI/system/components/justep/data/bizData" autoLoad="true"
xid="bizData1" concept="HR_SignRecord" columns="HR_SignRecord,fPersonID,fPersonName,fDay,fTime1,fAddress1,fTime,fAddress"
isTree="true" limit="-1">
<creator xid="default1" action="/HR/sign/logic/action/createHR_SignRecordAction"/>
<reader xid="default2" action="/HR/sign/logic/action/queryHR_SignRecord1Action"/>
<writer xid="default3" action="/HR/sign/logic/action/saveHR_SignRecordAction"/>
</div>
</div>
<span component="$UI/system/components/justep/windowDialog/windowDialog" xid="windowDialog1"
src="$UI/HR/sign/process/sign/list.w" title="签到记录"/>
<div component="$UI/system/components/justep/panel/panel" class="x-panel x-full"
xid="panel1" bottom="true">
<div class="x-panel-top" xid="top1">
<div component="$UI/system/components/justep/titleBar/titleBar" class="x-titlebar"
xid="titleBar1" title="移动签到">
<div class="x-titlebar-left" xid="left1">
<a component="$UI/system/components/justep/button/button" class="btn btn-link btn-only-icon"
label="button" xid="button1" icon="icon-chevron-left">
<i xid="i3" class="icon-chevron-left"/>
<span xid="span3"/>
</a>
</div>
<div class="x-titlebar-title" xid="title1">移动签到</div>
<div class="x-titlebar-right reverse" xid="right1">
<a component="$UI/system/components/justep/button/button" class="btn btn-link"
label="设置" xid="button2">
<i xid="i2"/>
<span xid="span2">设置</span>
</a>
</div>
</div>
</div>
<div class="x-panel-content" xid="content1">
<div component="$UI/system/components/justep/list/list" class="x-list"
xid="list1" data="bizData1">
<div component="$UI/system/components/justep/contents/contents" class="x-contents x-full"
active="0" xid="contents1">
<div class="x-contents-content" data-bind="css:{'x-content-on-left':$model.isOnLeft.bind($model,$object)(),'active':$model.isOnCenter.bind($model,$object)(),'x-content-on-right':$model.isOnRight.bind($model,$object)()}">
<div component="$UI/system/components/justep/output/output" class="x-output"
xid="output1" bind-ref="$model.bizData1.ref("fAddress")"/>
<div xid="map" style="height:139px;"/>
<img alt="" style="width:100px;height:100px;" height="30px" class="img-responsive" data-bind="attr:{src:$model.getSrc.bind($model,$object)()}"/>
<a component="$UI/system/components/justep/button/button" class="btn btn-default btn-only-icon"
label="button" xid="button3" icon="icon-ios7-camera">
<i xid="i1" class="icon-ios7-camera"/>
<span xid="span1"/>
</a>
</div>
</div>
</div>
</div>
<div class="x-panel-bottom" xid="bottom1">
<div component="$UI/system/components/justep/button/buttonGroup" class="btn-group btn-group-lg btn-group-justified center-block"
tabbed="true" xid="buttonGroup1">
<a component="$UI/system/components/justep/button/button" class="btn btn-default"
label="签到" xid="button5">
<i xid="i7"/>
<span xid="span5">签到</span>
</a>
<a component="$UI/system/components/justep/button/button" class="btn btn-default"
label="签退" xid="button4">
<i xid="i6"/>
<span xid="span4">签退</span>
</a>
</div>
</div>
</div>
</div>
js文件:
define(function(require){
var $ = require("jquery");
var justep = require("$UI/system/lib/justep");
require("$UI/system/lib/cordova/cordova");
require("cordova!com.justep.cordova.plugin.baidulocation");
require('$UI/system/lib/jquery/transition');
var DocUtils = require('$UI/system/components/justep/docCommon/docUtil');
var bizData1;
var isLeft = true;
var currentLocation;
var watchLocationID;
var Model = function(){
debugger;
this.callParent();
this.on('onload',function(){
bizData1 = this.comp('bizData1');
if(bizData1.getCount() == 0){
var row = bizData1.newData({});
// paiData.setValue('fScode','随手拍');
// paiData.setValue('fSName',"");
//paiData.setValue('fCode',"");
debugger;
bizData1.setValue('fAddress',"");
bizData1.saveData();
}
// Success callback
var success = function(p){
var latitude = p.coords.latitude;
var longitude = p.coords.longitude;
currentLocation = latitude + '|' +longitude;
};
watchLocationID = navigator.geolocation.watchPosition(success, null, {enableHighAccuracy: true});
});
//this.address = new justep.Bind.observable("");
};
// Model.prototype.modelLoad = function(event) {
// //只能在手机app上运行
//// if(!justep.Browser.isX5App){
//// alert("此功能只能在手机APP中使用!");
//// justep.Portal.closeWindow();
//// }
//
//
// var me = this;
//
// // 如果包含了百度定位插件
// if(navigator.baiduLocation){
// navigator.baiduLocation.getCurrentPosition(function(e) {
// var url = require.toUrl("./map.html?operator=chajian&longitude=" + e.coords.longitude + "&latitude=" + e.coords.latitude);
// $(me.getElementByXid('map')).html('<iframe xid="mapFrame" src="' + url + '" width="100%" height="100%" style="border:0;"></iframe>');
// me.address.set(me.comp("bizData1").getValue("fTime")+e.address);
// me.comp("bizData1").setValue("fAddress", e.address);
// me.comp("bizData1").setValue("fLongitude", e.coords.longitude);
// me.comp("bizData1").setValue("fLatitude", e.coords.latitude);
// me.address.set(me.comp("bizData1").getValue("fTime")+" "+e.address);
//
// //$(me.getElementByXid("button4")).hide();
//
// });
//
// }else{
// navigator.geolocation.getCurrentPosition(function(e){
// var url = require.toUrl("./map.html?operator=guge&longitude=" + e.coords.longitude + "&latitude=" + e.coords.latitude);
// $(me.getElementByXid('map')).html('<iframe xid="mapFrame" src="' + url + '" width="100%" height="100%" style="border:0;"></iframe>');
//
// me.comp("bizData1").setValue("fAddress", e.address);
// me.address.set(me.comp("bizData1").getValue("fTime")+" "+e.address);
//
// //$(me.getElementByXid("button4")).hide();
// });
//
// }
//
//
// };
//签到
Model.prototype.button5Click = function(event){
var data = this.comp("bizData1");
var rows2 = data.find(['fType'],['签退'],true,true,true);
var rows = data.find(['fType'],['签到'],true,true,true);
if(rows.length===0){
if(rows2.length>0){
alert("已签退,无法签到!");
return false;
}
this.comp("bizData1").setValue("fType","签到");
this.comp("bizData1").saveData({"onSuccess" : function(event){
alert("签到成功!");
//justep.Portal.closeWindow();
}
});
}else{
alert("今天已经签到过!");
}
};
Model.prototype.button4Click = function(event){
var data = this.comp("bizData1");
var rows = data.find(['fType'],['签退'],true,true,true);
if(rows.length===0){
this.comp("bizData1").setValue("fType","签退");
this.comp("bizData1").saveData({"onSuccess" : function(event){
alert("签退成功!");
//justep.Portal.closeWindow();
}
});
}else{
alert("今天已经签退过!");
}
};
Model.prototype.button3Click = function(event){
this.comp("windowDialog1").open();
};
function allPrpos(obj) {
// 用来保存所有的属性名称和值
var props = "";
// 开始遍历
for(var p in obj){
// 方法
if(typeof(obj[p])=="function"){
//obj[p]();
}else{
// p 为属性名称,obj[p]为对应属性的值
props += p + "=" + obj[p] + "; ";
}
}
// 最后显示所有的属性
alert(props);
}
Model.prototype.isOnLeft = function($object){
return isLeft;
};
Model.prototype.isOnCenter = function($object){
var isCenter = false;
if(this.comp('bizData1').getCurrentRow()){
isCenter = this.comp('bizData1').getCurrentRow().row == $object.row;
if(isCenter){
isLeft = false;
}
}
return isCenter;
};
Model.prototype.isOnRight = function($object){
if(!isLeft && this.comp('bizData1').getCurrentRow()){
isCenter = this.comp('bizData1').getCurrentRow().row == $object.row;
if(isCenter){
return false;
}
return true;
}
return false;
};
Model.prototype.getSrc = function($object){
debugger;
alert($object);
allPrpos($object);
// alert($object.row);
var codeValue = $object.row.fAddress.value.get();
if(codeValue){
var img = DocUtils.InnerUtils.getdocServerAction({
docPath:"/defaultDocNameSpace",
urlPattern:"/repository/file/download/" + codeValue + "/last/content",
context:this.getContext()
});
return img;
}
return "http://www.justep.com/file/upload/201407/09/11-27-37-58-1.jpg";
};
Model.prototype.cameraBtnClick = function(event){
var self = this;
if(navigator.camera){
debugger;
navigator.camera.getPicture(captureSuccess, captureFail, { quality: 50});
function captureSuccess(path) {
var success = function(r) {
var file = $(r.response).find("file");
var fileId = $(file).attr("file-name");
var row = bizData1.newData({});
debugger;
//bizData1.setValue('fScode','随手拍');
//bizData1.setValue('fSName',currentLocation);
bizData1.setValue('fAddress',fileId);
bizData1.saveData();
//src="$UI/HR/sign/process/sign/checkin/process/IMG_0279.JPG";
//attr:{src:$model.getSrc.bind($model,$object)()}
//$('#image2').
//$object.row.AddressPhoto.value.get();
};
var fail = function(error) {
alert("upload An error has occurred: Code = " + error.code);
};
var options = new FileUploadOptions();
var fileName= path.substr(path.lastIndexOf('/')+1);
options.fileName = fileName;
var ft = new FileTransfer();
debugger;
ft.upload(path, encodeURI(self.getUploadUrl()), success, fail, options);
};
function captureFail(){
alert('fail');
};
}else{
var msg = $('<div class="alert alert-danger" style="z-index:999;text-align:center;font-size:16px;-webkit-transition:all 0.4s;-webkit-transform:translate3d(0,-100%,0);font-weight:bold;position:absolute;top:0;left:0;width:100%;" role="alert">本demo在手机app中运行效果最佳</div>').appendTo('body');
setTimeout(function(){
msg.transform('translate3d(0,0,0)');
},1);
setTimeout(function(){
msg.transform('translate3d(0,-100%,0)').transitionEnd(function(){
msg.remove();
});
},2000);
}
};
Model.prototype.getUploadUrl = function(){
var docUrl = DocUtils.InnerUtils.getdocServerAction({
docPath:"/defaultDocNameSpace",
urlPattern:"/repository/file/cache/upload",
context:this.getContext(),
useCookie:false
});
if (docUrl.indexOf("uploadDoc.j") != -1&& docUrl.indexOf("#") == -1) {
docUrl = window.location.protocol + "//"
+ window.location.host + docUrl;
}
return docUrl;
};
Model.prototype.contents1ActiveChange = function(event){
console.log('change');
};
Model.prototype.modelModelConstruct = function(event){
var bizData1 = this.comp('bizData1');
debugger;
if(bizData1 && bizData1.getCount() == 0){
var row = bizData1.newData({});
//bizData1.setValue('fScode','随手拍');
//bizData1.setValue('fSName',"");
bizData1.setValue('fAddress',"");
debugger;
}
};
Model.prototype.button1Click = function(event){
};
Model.prototype.button3Click = function(event){
};
return Model;
});
请老师一定帮忙看看啊,该看的视频我都看过了,可还是始终解决不掉啊:'(
|
|