|
@@ -122,13 +122,14 @@
|
|
}
|
|
}
|
|
}]);
|
|
}]);
|
|
|
|
|
|
- app.controller('myTruckCtrl', ['$scope', '$state', 'myService', 'msg', function ($scope, $state, myService, msg) {
|
|
|
|
|
|
+ app.controller('myTruckCtrl', ['$scope', '$state', 'myService', 'msg','config', function ($scope, $state, myService, msg,config) {
|
|
$scope.filter = {
|
|
$scope.filter = {
|
|
hasMore: false,
|
|
hasMore: false,
|
|
page: 0,
|
|
page: 0,
|
|
pageSize: 10,
|
|
pageSize: 10,
|
|
}
|
|
}
|
|
$scope.items = [];
|
|
$scope.items = [];
|
|
|
|
+ $scope.host = config.server +'/upload/photo/';
|
|
$scope.load = function (init) {
|
|
$scope.load = function (init) {
|
|
if (init) {
|
|
if (init) {
|
|
$scope.filter.pageIndex = 1;
|
|
$scope.filter.pageIndex = 1;
|
|
@@ -205,7 +206,10 @@
|
|
{ name: '其他', value: '20' }];
|
|
{ name: '其他', value: '20' }];
|
|
$scope.save = function () {
|
|
$scope.save = function () {
|
|
msg.loading('保存中...');
|
|
msg.loading('保存中...');
|
|
|
|
+ console.log('id '+$scope.vm.id);
|
|
if ($scope.vm.id>0) {
|
|
if ($scope.vm.id>0) {
|
|
|
|
+ $scope.vm.photo = null;
|
|
|
|
+ console.log('updateTruck '+ JSON.stringify($scope.vm));
|
|
myService.updateTruck($scope.vm).then(function (result) {
|
|
myService.updateTruck($scope.vm).then(function (result) {
|
|
msg.hide();
|
|
msg.hide();
|
|
$state.go('wl.my_truck');
|
|
$state.go('wl.my_truck');
|
|
@@ -233,21 +237,27 @@
|
|
uploadOptions.fileName = "photo.jpg";
|
|
uploadOptions.fileName = "photo.jpg";
|
|
uploadOptions.mimeType = "image/jpeg";
|
|
uploadOptions.mimeType = "image/jpeg";
|
|
uploadOptions.httpMethod = 'post';
|
|
uploadOptions.httpMethod = 'post';
|
|
|
|
+ var id = '';
|
|
|
|
+ if ($scope.vm.id>0) {
|
|
|
|
+ id = '/'+$scope.vm.id;
|
|
|
|
+ }
|
|
uploadOptions.chunkedMode = true;
|
|
uploadOptions.chunkedMode = true;
|
|
var token = 'Bearer ' + localStorage['token'];
|
|
var token = 'Bearer ' + localStorage['token'];
|
|
uploadOptions.headers = { "Authorization": token };
|
|
uploadOptions.headers = { "Authorization": token };
|
|
|
|
+
|
|
var ft = new FileTransfer();
|
|
var ft = new FileTransfer();
|
|
- ft.upload(imageUri, encodeURI(config.server + "api/trucks"), function (sucess) {
|
|
|
|
- $timeout(function () {
|
|
|
|
- var res = JSON.parse(sucess.response);
|
|
|
|
- $scope.vm.photo = res.data.photo;
|
|
|
|
- });
|
|
|
|
- console.log('上传成功'+JSON.stringify(sucess.response));
|
|
|
|
- //alert('上传成功'+JSON.stringify(sucess));
|
|
|
|
- }, function (fail) {
|
|
|
|
- console.log('上传失败'+JSON.stringify(fail));
|
|
|
|
- //alert('上传失败'+JSON.stringify(fail));
|
|
|
|
- }, uploadOptions);
|
|
|
|
|
|
+ ft.upload(imageUri, encodeURI(config.server + "api/trucks" + id), function (sucess) {
|
|
|
|
+ $timeout(function () {
|
|
|
|
+ var res = JSON.parse(sucess.response);
|
|
|
|
+ $scope.vm.id = res.data.id;
|
|
|
|
+ $scope.vm.photo = res.data.photo;
|
|
|
|
+ });
|
|
|
|
+ console.log('上传成功'+JSON.stringify(sucess.response));
|
|
|
|
+ //alert('上传成功'+JSON.stringify(sucess));
|
|
|
|
+ }, function (fail) {
|
|
|
|
+ console.log('上传失败'+JSON.stringify(fail));
|
|
|
|
+ //alert('上传失败'+JSON.stringify(fail));
|
|
|
|
+ }, uploadOptions);
|
|
}, function (erro) {
|
|
}, function (erro) {
|
|
msg.error(erro);
|
|
msg.error(erro);
|
|
});
|
|
});
|