Advertisement
Guest User

Untitled

a guest
Dec 11th, 2017
111
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 7.28 KB | None | 0 0
  1. var shop_name = "Giovan Shop"; // NAMA TOKO ONLINE
  2. var domain = "http://giovanshop.linkaplikasi.com/mobile/"; // DOMAIN URL ADMIN
  3. var admin_url = domain;
  4.  
  5. var base_url_api = "http://api.tokomobile.co.id/ongkir/development/api";
  6. var token_api = "c0e26b7e7bdafb9595e574de6338595c";
  7. var domain_api = "giovanshop.linkaplikasi.com";
  8.  
  9. var base_url = domain+"_api_/android_dev/"; // URL API
  10. var base_url_media = admin_url+"media"; // DIREKTORI PENYIMPANAN IMAGE DI HOSTING
  11. var dir_image = "Pictures/GiovanShop"; // DIREKTORI PENYIMPANAN IMAGE DI SD CARD
  12. var token = "c0e26b7e7bdafb9595e574de6338595c"; // ISI DENGAN TOKEN
  13.  
  14.  
  15. .controller("cekongkirController", function($scope, $state, $http, $ionicLoading, $ionicPopup, $window, cekOngkirService) {
  16. var _this = this
  17. $scope.postData = {};
  18. $scope.arr_prov = [];
  19. $scope.arr_kota = [];
  20. $scope.arr_kecamatan = [];
  21. $scope.arr_ekspedisi = [];
  22. $scope.postData = {};
  23.  
  24. //GET SELURUH PROVINSI
  25. $http.get("")
  26. .then(function(response) {
  27. });
  28.  
  29. var param = "?token="+token_api+"&domain="+domain_api;
  30. var link = base_url_api+"/province"+param;
  31. $http({
  32. method : 'GET',
  33. url : link,
  34. //headers: header_data ,
  35. data : {},
  36. timeout: 10000
  37. }).then(
  38. function(res) {
  39. $ionicLoading.hide()
  40. console.log(res.data);
  41. $scope.data_provinsi = res.data.result;
  42. }, function(response) {
  43. $ionicLoading.hide();
  44. alert('Failed to continue, please check your internet connection');
  45. });
  46.  
  47.  
  48. //GET KOTA BY PROVINSI ID
  49. $scope.getKotaByProvinsi = function () {
  50. $ionicLoading.show()
  51. var param = "?token="+token_api+"&domain="+domain_api+"&province_id="+$scope.postData.prov;
  52. var link = base_url_api+"/city"+param;
  53. $http({
  54. method : 'GET',
  55. url : link,
  56. //headers: header_data ,
  57. data : {},
  58. timeout: 10000
  59. }).then(
  60. function(res) {
  61. $ionicLoading.hide()
  62. console.log(res.data);
  63. $scope.kota = "-Pilih Kota-";
  64. $scope.kota_id = "0";
  65. $scope.kecamatan = "-Pilih Kecamatan-";
  66. $scope.kecamatan_id = "0";
  67.  
  68. //$scope.editProfilKotaTop = false;
  69. $scope.editProfilKota = true;
  70. $scope.data_kota = res.data.result;
  71. }, function(response) {
  72. $ionicLoading.hide();
  73. alert('Failed to continue, please check your internet connection');
  74. });
  75.  
  76. }
  77.  
  78. //GET KECAMATAN BY KOTA ID
  79. $scope.getKecamatanByKota = function () {
  80. $ionicLoading.show()
  81. var param = "?token="+token_api+"&domain="+domain_api+"&city_id="+$scope.postData.kota;
  82. var link = base_url_api+"/subdistrict"+param;
  83. $http({
  84. method : 'GET',
  85. url : link,
  86. //headers: header_data ,
  87. data : {},
  88. timeout: 10000
  89. }).then(
  90. function(res) {
  91. $ionicLoading.hide()
  92. console.log(res.data);
  93. $scope.kecamatan = "-Pilih Kecamatan-";
  94. $scope.kecamatan_id = "0";
  95.  
  96. //$scope.editProfilKotaTop = false;
  97. $scope.editProfilKecamatan = true;
  98. $scope.data_kecamatan = res.data.result;
  99. }, function(response) {
  100. $ionicLoading.hide();
  101. alert('Failed to continue, please check your internet connection');
  102. });
  103. }
  104.  
  105. //get_content origin city id dll
  106. var link = base_url+"get_content";
  107. $http({
  108. method : 'POST',
  109. url : link,
  110. //headers: header_data ,
  111. data : {
  112. customer_id:window.localStorage['customer_id'],
  113. token:token
  114. },
  115. timeout: 10000
  116. }).then(
  117. function(res) {
  118. console.log(res.data);
  119. var json = res.data;
  120.  
  121. $window.localStorage['origin_city_id'] = json[19].value;
  122. $window.localStorage['origin_city_name'] = json[24].value;
  123. $window.localStorage['satuan_berat'] = json[25].value;
  124.  
  125. var x = 0;
  126. if(json[20].value=="available"){
  127. $scope.arr_ekspedisi.push({"code":"jne"});
  128. console.log("jne"+json[20].value);
  129. x++;
  130. }
  131. if(json[21].value=="available"){
  132. $scope.arr_ekspedisi.push({"code":"tiki"});
  133. console.log("tiki"+json[21].value);
  134. x++;
  135. }
  136. if(json[22].value=="available"){
  137. $scope.arr_ekspedisi.push({"code":"pos"});
  138. console.log("pos"+json[22].value);
  139. x++;
  140. }
  141. if(json[23].value=="available"){
  142. $scope.arr_ekspedisi.push({"code":"wahana"});
  143. console.log("wahana"+json[23].value);
  144. x++;
  145. }
  146.  
  147. $scope.satuan_berat = $window.localStorage['satuan_berat'];
  148. $ionicLoading.hide()
  149. }, function(response) {
  150. $ionicLoading.hide();
  151. alert('Failed to continue, please check your internet connection');
  152. })
  153.  
  154. //get tarif
  155. $scope.getTarif = function (val) {
  156. //get tarif list ke api rajaongkir
  157. $ionicLoading.show()
  158. 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;
  159. var link = base_url_api+"/cost"+param;
  160. $http({
  161. method : 'GET',
  162. url : link,
  163. //headers: header_data ,
  164. data : {
  165. customer_id:window.localStorage['customer_id'],
  166. token:token
  167. },
  168. timeout: 10000
  169. }).then(
  170. function(res) {
  171. console.log(res);
  172. $ionicLoading.hide()
  173.  
  174. $scope.listTarif = res.data.result[0].costs;
  175. console.log($scope.listTarif);
  176. }, function(response) {
  177. $ionicLoading.hide();
  178. alert('Failed to continue, please check your internet connection');
  179. });
  180.  
  181. }
  182.  
  183. //set Tarif
  184. $scope.setOngkir = function (val) {
  185. val = val.split("#");
  186. $scope.ongkir = val[0];
  187. var subtotal = $scope.total_amount.replace(".","");
  188. var ongkir = $scope.ongkir.replace(".","");
  189. $scope.tarif_tipe = val[1];
  190.  
  191. $scope.total_all = toRp(parseInt(subtotal) + parseInt(ongkir));
  192. }
  193.  
  194. $scope.get_ongkir = function (val) {
  195. cekOngkirService.prov_id = $scope.postData.prov;
  196. cekOngkirService.kota_id = $scope.postData.kota;
  197. cekOngkirService.kec_id = $scope.postData.kecamatan;
  198. cekOngkirService.berat_id = $scope.postData.berat;
  199. $state.go('eventmenu.get_ongkir');
  200.  
  201. }
  202.  
  203. })
  204.  
  205. .controller("getOngkirController", function($scope, $state, $http, $ionicLoading, cekOngkirService, $window) {
  206. var _this = this
  207. /* var provinsi = $scope.postData.prov;
  208. var kota = $scope.postData.kota;
  209. var kecamatan = $scope.postData.kecamatan;
  210. var berat = $scope.postData.berat;
  211. */
  212. var prov_id = cekOngkirService.prov_id;
  213. var kota_id = cekOngkirService.kota_id;
  214. var kec_id = cekOngkirService.kec_id;
  215. var berat_id = cekOngkirService.berat_id;
  216. console.log(prov_id);
  217. $ionicLoading.show()
  218. 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";
  219. var link = base_url_api+"/cost"+param;
  220. $http({
  221. method : 'GET',
  222. url : link,
  223. data : {},
  224. timeout: 10000
  225. }).then(
  226. function(res) {
  227. $ionicLoading.hide()
  228. console.log(res.data);
  229. $scope.get_ongkir = res.data.result;
  230. }, function(response) {
  231. $ionicLoading.hide();
  232. alert('Failed to continue, please check your internet connection');
  233. });
  234. })
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement