|
@@ -1,5 +1,11 @@
|
|
(function (app) {
|
|
(function (app) {
|
|
- app.controller('myCtrl', ["$scope","$state", function ($scope,$state) {
|
|
|
|
|
|
+ app.controller('myCtrl', ["$scope", "$state", 'userService', 'msg', function ($scope, $state, userService,msg) {
|
|
|
|
+ $scope.user = {};
|
|
|
|
+ userService.getUser().then(function (result) {
|
|
|
|
+ $scope.user = result.data.data;
|
|
|
|
+ }, function (erro) {
|
|
|
|
+ msg.error(erro.data.message);
|
|
|
|
+ });
|
|
$scope.toProfile = function () {
|
|
$scope.toProfile = function () {
|
|
$state.go('wl.my_profile');
|
|
$state.go('wl.my_profile');
|
|
}
|
|
}
|
|
@@ -40,6 +46,10 @@
|
|
$scope.modal1.remove();
|
|
$scope.modal1.remove();
|
|
$scope.modal2.remove();
|
|
$scope.modal2.remove();
|
|
});
|
|
});
|
|
|
|
+ $scope.appversion = '1.0.0';
|
|
|
|
+ if (!!window.AppVersion) {
|
|
|
|
+ $scope.appversion = AppVersion.version;
|
|
|
|
+ }
|
|
}]);
|
|
}]);
|
|
app.controller('mySetPasswordCtrl', ['$scope', '$state', function ($scope,$state) {
|
|
app.controller('mySetPasswordCtrl', ['$scope', '$state', function ($scope,$state) {
|
|
$scope.vm = {
|
|
$scope.vm = {
|
|
@@ -53,7 +63,7 @@
|
|
}
|
|
}
|
|
}]);
|
|
}]);
|
|
|
|
|
|
- app.controller('myProfileCtrl', ['$scope', 'userService', 'msg', 'util','data', function ($scope, userService, msg, util,data) {
|
|
|
|
|
|
+ app.controller('myProfileCtrl', ['$scope','$ionicActionSheet','$ionicPopup','$timeout','userService', 'msg', 'util','data', function ($scope,$ionicActionSheet,$ionicPopup,$timeout, userService, msg, util,data) {
|
|
$scope.user = data.getObject('user');
|
|
$scope.user = data.getObject('user');
|
|
$scope.genderOpt = [
|
|
$scope.genderOpt = [
|
|
{ name: "男", value: 1 },
|
|
{ name: "男", value: 1 },
|
|
@@ -65,35 +75,83 @@
|
|
msg.error(erro);
|
|
msg.error(erro);
|
|
});
|
|
});
|
|
$scope.setAvator = function () {
|
|
$scope.setAvator = function () {
|
|
- var options = {
|
|
|
|
- quality: 50,
|
|
|
|
- destinationType: 1,
|
|
|
|
- sourceType: 0,
|
|
|
|
- encodingType: 0,
|
|
|
|
- saveToPhotoAlbum: false,
|
|
|
|
- allowEdit:true
|
|
|
|
- };//https://cordova.apache.org/docs/en/latest/reference/cordova-plugin-camera/
|
|
|
|
- navigator.camera.getPicture(function (imageUri) {
|
|
|
|
- $scope.user.avatar = imageUri;
|
|
|
|
|
|
+ var sheet = $ionicActionSheet.show({
|
|
|
|
+ buttons: [{ text: '<b>拍照</b> 上传' }, { text: '从 <b>相册</b> 中选' }],
|
|
|
|
+ titleText: '图片上传',
|
|
|
|
+ cancelText: '取 消',
|
|
|
|
+ cancel: function() { return true; },
|
|
|
|
+ buttonClicked: function(index) {
|
|
|
|
+ var options = { quality: 50, targetHeight: 112, targetWidth: 112, allowEdit: true};
|
|
|
|
+ if (index == 0) options.sourceType = 1;
|
|
|
|
+ else options.sourceType = 2;
|
|
|
|
+ navigator.camera.getPicture(function(imageUri) {
|
|
|
|
+ if (imageUri == undefined) {
|
|
|
|
+ var alertPopup = $ionicPopup.alert({
|
|
|
|
+ title: '提示',
|
|
|
|
+ template: '图片未找到!'
|
|
|
|
+ });
|
|
|
|
+ alertPopup.then(function(res) {
|
|
|
|
+ console.log('1111');
|
|
|
|
+ });
|
|
|
|
+ }else {
|
|
|
|
+ $timeout(function() {
|
|
|
|
+ $scope.user.avatar = imageUri;
|
|
|
|
+ });
|
|
|
|
+ var uploadOptions = new FileUploadOptions();
|
|
|
|
+ uploadOptions.fileKey = "photo";
|
|
|
|
+ uploadOptions.fileName = "avatar.jpg";
|
|
|
|
+ uploadOptions.mimeType = "image/jpeg";
|
|
|
|
+ uploadOptions.httpMethod = 'post';
|
|
|
|
+ uploadOptions.chunkedMode = true;
|
|
|
|
+ var token='Bearer ' + localStorage['token'];
|
|
|
|
+ uploadOptions.headers = { "Authorization": token };
|
|
|
|
+ console.log("setAvator uploadOptions:"+JSON.stringify(uploadOptions));
|
|
|
|
+ var ft = new FileTransfer();
|
|
|
|
+ ft.upload(imageUri, encodeURI(config.server+"api/user"), function(sucess) {
|
|
|
|
+ console.log("setAvator sucess:"+JSON.stringify(sucess));
|
|
|
|
+ // alert(JSON.stringify(sucess));
|
|
|
|
+ }, function (fail) {
|
|
|
|
+ console.log("setAvator fail:"+JSON.stringify(fail));
|
|
|
|
+ // alert(JSON.stringify(fail));
|
|
|
|
+ }, uploadOptions);
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+ }, function(err) {
|
|
|
|
+ var alertPopup = $ionicPopup.alert({
|
|
|
|
+ title: '提示',
|
|
|
|
+ template: err
|
|
|
|
+ });
|
|
|
|
+ alertPopup.then(function(res) {
|
|
|
|
+ console.log('1111');
|
|
|
|
+ });
|
|
|
|
+ }, options);
|
|
|
|
+
|
|
|
|
+ return true;
|
|
|
|
+ }
|
|
|
|
+ });
|
|
|
|
+
|
|
|
|
+ //https://cordova.apache.org/docs/en/latest/reference/cordova-plugin-camera/
|
|
|
|
+ // navigator.camera.getPicture(function (imageUri) {
|
|
|
|
+ // $scope.user.avatar = imageUri;
|
|
|
|
|
|
- var uploadOptions = new FileUploadOptions();
|
|
|
|
- uploadOptions.fileKey = "avatar";
|
|
|
|
- uploadOptions.fileName = "avatar.jpg";
|
|
|
|
- uploadOptions.mimeType = "image/jpeg";
|
|
|
|
- uploadOptions.httpMethod = 'post';
|
|
|
|
- var token='Bearer ' + localStorage['token'];
|
|
|
|
- alert(token);
|
|
|
|
- uploadOptions.headers = { "Authorization": token };
|
|
|
|
- var ft = new FileTransfer();
|
|
|
|
- ft.upload(imageUri, encodeURI("http://120.25.204.211/api/user"), function(sucess) {
|
|
|
|
- alert(JSON.stringify(sucess));
|
|
|
|
- }, function (fail) {
|
|
|
|
- alert(JSON.stringify(fail));
|
|
|
|
- }, options);
|
|
|
|
|
|
+ // var uploadOptions = new FileUploadOptions();
|
|
|
|
+ // uploadOptions.fileKey = "avatar";
|
|
|
|
+ // uploadOptions.fileName = "avatar.jpg";
|
|
|
|
+ // uploadOptions.mimeType = "image/jpeg";
|
|
|
|
+ // uploadOptions.httpMethod = 'post';
|
|
|
|
+ // var token='Bearer ' + localStorage['token'];
|
|
|
|
+ // alert(token);
|
|
|
|
+ // uploadOptions.headers = { "Authorization": token };
|
|
|
|
+ // var ft = new FileTransfer();
|
|
|
|
+ // ft.upload(imageUri, encodeURI("http://120.25.204.211/api/user"), function(sucess) {
|
|
|
|
+ // alert(JSON.stringify(sucess));
|
|
|
|
+ // }, function (fail) {
|
|
|
|
+ // alert(JSON.stringify(fail));
|
|
|
|
+ // }, options);
|
|
|
|
|
|
- }, function (erro) {
|
|
|
|
- alert(erro);
|
|
|
|
- }, options);
|
|
|
|
|
|
+ // }, function (erro) {
|
|
|
|
+ // alert(erro);
|
|
|
|
+ // }, options);
|
|
}
|
|
}
|
|
$scope.save = function () {
|
|
$scope.save = function () {
|
|
data.updateObject('user', $scope.user);
|
|
data.updateObject('user', $scope.user);
|
|
@@ -132,6 +190,23 @@
|
|
$scope.detail = function (item) {
|
|
$scope.detail = function (item) {
|
|
$state.go('wl.my_truck_add', {item:item});
|
|
$state.go('wl.my_truck_add', {item:item});
|
|
}
|
|
}
|
|
|
|
+ $scope.delete = function (item, $event) {
|
|
|
|
+ $event.stopPropagation();
|
|
|
|
+ msg.confirm('删除提示', '确定删除?').then(function (res) {
|
|
|
|
+ if (res) {
|
|
|
|
+ msg.loading('删除中...');
|
|
|
|
+ myService.deleteTruck(item.id).then(function (result) {
|
|
|
|
+ msg.hide();
|
|
|
|
+ $scope.load(true);
|
|
|
|
+ }, function (erro) {
|
|
|
|
+ msg.hide();
|
|
|
|
+ msg.error(erro.data.message);
|
|
|
|
+ })
|
|
|
|
+ } else {
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+ });
|
|
|
|
+ }
|
|
$scope.load(true);
|
|
$scope.load(true);
|
|
}]);
|
|
}]);
|
|
app.controller('myTruckAddCtrl', ['$scope', 'myService', 'msg', '$state', '$stateParams', function ($scope, myService, msg, $state, $stateParams) {
|
|
app.controller('myTruckAddCtrl', ['$scope', 'myService', 'msg', '$state', '$stateParams', function ($scope, myService, msg, $state, $stateParams) {
|
|
@@ -170,6 +245,10 @@
|
|
msg.error(erro.data.message);
|
|
msg.error(erro.data.message);
|
|
});
|
|
});
|
|
}
|
|
}
|
|
|
|
+ //上传图片
|
|
|
|
+ $scope.setPhoto = function () {
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
|
|
}]);
|
|
}]);
|
|
app.controller('myTruckDetailCtrl', ['$scope', function ($scope) {
|
|
app.controller('myTruckDetailCtrl', ['$scope', function ($scope) {
|
|
@@ -192,6 +271,7 @@
|
|
var more = (result.data.data.length >= $scope.filter.pageSize);
|
|
var more = (result.data.data.length >= $scope.filter.pageSize);
|
|
$scope.filter.hasMore = more;
|
|
$scope.filter.hasMore = more;
|
|
$scope.items = $scope.items.concat(result.data.data);
|
|
$scope.items = $scope.items.concat(result.data.data);
|
|
|
|
+
|
|
if (init) {
|
|
if (init) {
|
|
$scope.$broadcast('scroll.refreshComplete');
|
|
$scope.$broadcast('scroll.refreshComplete');
|
|
} else {
|
|
} else {
|
|
@@ -228,6 +308,7 @@
|
|
var more = (result.data.data.length >= $scope.filter.pageSize);
|
|
var more = (result.data.data.length >= $scope.filter.pageSize);
|
|
$scope.filter.hasMore = more;
|
|
$scope.filter.hasMore = more;
|
|
$scope.items = $scope.items.concat(result.data.data);
|
|
$scope.items = $scope.items.concat(result.data.data);
|
|
|
|
+ debugger;
|
|
if (init) {
|
|
if (init) {
|
|
$scope.$broadcast('scroll.refreshComplete');
|
|
$scope.$broadcast('scroll.refreshComplete');
|
|
} else {
|
|
} else {
|
|
@@ -237,7 +318,27 @@
|
|
msg.error(erro.data.message);
|
|
msg.error(erro.data.message);
|
|
});
|
|
});
|
|
}
|
|
}
|
|
|
|
+ $scope.pay = function (item,$event) {
|
|
|
|
+ $event.stopPropagation();
|
|
|
|
+ //to do
|
|
|
|
+ }
|
|
|
|
+ $scope.delete = function (item,$event) {
|
|
|
|
+ $event.stopPropagation();
|
|
|
|
+ msg.confirm('删除提示', '确定删除?').then(function (res) {
|
|
|
|
+ if (res) {
|
|
|
|
+ msg.loading('删除中...');
|
|
|
|
+ myService.deleteOrder(item.id).then(function (result) {
|
|
|
|
+ msg.hide();
|
|
|
|
+ $scope.load(true);
|
|
|
|
+ }, function (erro) {
|
|
|
|
+ msg.hide();
|
|
|
|
+ msg.error(erro.data.message);
|
|
|
|
+ })
|
|
|
|
+ } else {
|
|
|
|
|
|
|
|
+ }
|
|
|
|
+ });
|
|
|
|
+ }
|
|
$scope.detail = function (item) {
|
|
$scope.detail = function (item) {
|
|
$state.go('wl.my_order_detail', { item: item });
|
|
$state.go('wl.my_order_detail', { item: item });
|
|
}
|
|
}
|