Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- var shop_name = "Giovan Shop"; // NAMA TOKO ONLINE
- var domain = "http://giovanshop.linkaplikasi.com/mobile/"; // DOMAIN URL ADMIN
- var admin_url = domain;
- var base_url_api = "http://api.tokomobile.co.id/ongkir/development/api";
- var token_api = "c0e26b7e7bdafb9595e574de6338595c";
- var domain_api = "giovanshop.linkaplikasi.com";
- var base_url = domain+"_api_/android_dev/"; // URL API
- var base_url_media = admin_url+"media"; // DIREKTORI PENYIMPANAN IMAGE DI HOSTING
- var dir_image = "Pictures/GiovanShop"; // DIREKTORI PENYIMPANAN IMAGE DI SD CARD
- var token = "c0e26b7e7bdafb9595e574de6338595c"; // ISI DENGAN TOKEN
- .controller("cekongkirController", function($scope, $state, $http, $ionicLoading, $ionicPopup, $window, cekOngkirService) {
- var _this = this
- $scope.postData = {};
- $scope.arr_prov = [];
- $scope.arr_kota = [];
- $scope.arr_kecamatan = [];
- $scope.arr_ekspedisi = [];
- $scope.postData = {};
- //GET SELURUH PROVINSI
- $http.get("")
- .then(function(response) {
- });
- var param = "?token="+token_api+"&domain="+domain_api;
- var link = base_url_api+"/province"+param;
- $http({
- method : 'GET',
- url : link,
- //headers: header_data ,
- data : {},
- timeout: 10000
- }).then(
- function(res) {
- $ionicLoading.hide()
- console.log(res.data);
- $scope.data_provinsi = res.data.result;
- }, function(response) {
- $ionicLoading.hide();
- alert('Failed to continue, please check your internet connection');
- });
- //GET KOTA BY PROVINSI ID
- $scope.getKotaByProvinsi = function () {
- $ionicLoading.show()
- var param = "?token="+token_api+"&domain="+domain_api+"&province_id="+$scope.postData.prov;
- var link = base_url_api+"/city"+param;
- $http({
- method : 'GET',
- url : link,
- //headers: header_data ,
- data : {},
- timeout: 10000
- }).then(
- function(res) {
- $ionicLoading.hide()
- console.log(res.data);
- $scope.kota = "-Pilih Kota-";
- $scope.kota_id = "0";
- $scope.kecamatan = "-Pilih Kecamatan-";
- $scope.kecamatan_id = "0";
- //$scope.editProfilKotaTop = false;
- $scope.editProfilKota = true;
- $scope.data_kota = res.data.result;
- }, function(response) {
- $ionicLoading.hide();
- alert('Failed to continue, please check your internet connection');
- });
- }
- //GET KECAMATAN BY KOTA ID
- $scope.getKecamatanByKota = function () {
- $ionicLoading.show()
- var param = "?token="+token_api+"&domain="+domain_api+"&city_id="+$scope.postData.kota;
- var link = base_url_api+"/subdistrict"+param;
- $http({
- method : 'GET',
- url : link,
- //headers: header_data ,
- data : {},
- timeout: 10000
- }).then(
- function(res) {
- $ionicLoading.hide()
- console.log(res.data);
- $scope.kecamatan = "-Pilih Kecamatan-";
- $scope.kecamatan_id = "0";
- //$scope.editProfilKotaTop = false;
- $scope.editProfilKecamatan = true;
- $scope.data_kecamatan = res.data.result;
- }, function(response) {
- $ionicLoading.hide();
- alert('Failed to continue, please check your internet connection');
- });
- }
- //get_content origin city id dll
- var link = base_url+"get_content";
- $http({
- method : 'POST',
- url : link,
- //headers: header_data ,
- data : {
- customer_id:window.localStorage['customer_id'],
- token:token
- },
- timeout: 10000
- }).then(
- function(res) {
- console.log(res.data);
- var json = res.data;
- $window.localStorage['origin_city_id'] = json[19].value;
- $window.localStorage['origin_city_name'] = json[24].value;
- $window.localStorage['satuan_berat'] = json[25].value;
- var x = 0;
- if(json[20].value=="available"){
- $scope.arr_ekspedisi.push({"code":"jne"});
- console.log("jne"+json[20].value);
- x++;
- }
- if(json[21].value=="available"){
- $scope.arr_ekspedisi.push({"code":"tiki"});
- console.log("tiki"+json[21].value);
- x++;
- }
- if(json[22].value=="available"){
- $scope.arr_ekspedisi.push({"code":"pos"});
- console.log("pos"+json[22].value);
- x++;
- }
- if(json[23].value=="available"){
- $scope.arr_ekspedisi.push({"code":"wahana"});
- console.log("wahana"+json[23].value);
- x++;
- }
- $scope.satuan_berat = $window.localStorage['satuan_berat'];
- $ionicLoading.hide()
- }, function(response) {
- $ionicLoading.hide();
- alert('Failed to continue, please check your internet connection');
- })
- //get tarif
- $scope.getTarif = function (val) {
- //get tarif list ke api rajaongkir
- $ionicLoading.show()
- var param="?token="+token_api+"&domain="+domain_api+"&origin_city_id="+$window.localStorage['origin_city_id']+"&destination_id="+kec_id+"&destination_type=subdistrict&weight="+total_weight+"&satuan="+$window.localStorage['satuan_berat']+"&courier="+val;
- var link = base_url_api+"/cost"+param;
- $http({
- method : 'GET',
- url : link,
- //headers: header_data ,
- data : {
- customer_id:window.localStorage['customer_id'],
- token:token
- },
- timeout: 10000
- }).then(
- function(res) {
- console.log(res);
- $ionicLoading.hide()
- $scope.listTarif = res.data.result[0].costs;
- console.log($scope.listTarif);
- }, function(response) {
- $ionicLoading.hide();
- alert('Failed to continue, please check your internet connection');
- });
- }
- //set Tarif
- $scope.setOngkir = function (val) {
- val = val.split("#");
- $scope.ongkir = val[0];
- var subtotal = $scope.total_amount.replace(".","");
- var ongkir = $scope.ongkir.replace(".","");
- $scope.tarif_tipe = val[1];
- $scope.total_all = toRp(parseInt(subtotal) + parseInt(ongkir));
- }
- $scope.get_ongkir = function (val) {
- cekOngkirService.prov_id = $scope.postData.prov;
- cekOngkirService.kota_id = $scope.postData.kota;
- cekOngkirService.kec_id = $scope.postData.kecamatan;
- cekOngkirService.berat_id = $scope.postData.berat;
- $state.go('eventmenu.get_ongkir');
- }
- })
- .controller("getOngkirController", function($scope, $state, $http, $ionicLoading, cekOngkirService, $window) {
- var _this = this
- /* var provinsi = $scope.postData.prov;
- var kota = $scope.postData.kota;
- var kecamatan = $scope.postData.kecamatan;
- var berat = $scope.postData.berat;
- */
- var prov_id = cekOngkirService.prov_id;
- var kota_id = cekOngkirService.kota_id;
- var kec_id = cekOngkirService.kec_id;
- var berat_id = cekOngkirService.berat_id;
- console.log(prov_id);
- $ionicLoading.show()
- var param="?token="+token_api+"&domain="+domain_api+"&origin_city_id="+$window.localStorage['origin_city_id']+"&destination_id="+kec_id+"&destination_type=subdistrict&weight="+berat_id+"&satuan="+$window.localStorage['satuan_berat']+"&courier=jne:pos:tiki:wahana";
- var link = base_url_api+"/cost"+param;
- $http({
- method : 'GET',
- url : link,
- data : {},
- timeout: 10000
- }).then(
- function(res) {
- $ionicLoading.hide()
- console.log(res.data);
- $scope.get_ongkir = res.data.result;
- }, function(response) {
- $ionicLoading.hide();
- alert('Failed to continue, please check your internet connection');
- });
- })
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement