浏览代码

nav cart error fix

sachinganesh 2 年前
父节点
当前提交
4530c1797d
共有 2 个文件被更改,包括 69 次插入18 次删除
  1. 1
    1
      dist/Js/navbar.js
  2. 68
    17
      dist/Js/shoppingcart/select_delivery.js

+ 1
- 1
dist/Js/navbar.js 查看文件

@@ -4,7 +4,7 @@ function navINIT() {
4 4
     loadCart();
5 5
     function loadHelper(src = './dist/js/utils/helpers.js'){
6 6
         if ($(`script[src="${src}"]`).length > 0) {
7
-          return new Promise((resolve) => resolve);
7
+          return new Promise((resolve) => resolve());
8 8
         }
9 9
         return new Promise(function (resolve, reject) {
10 10
             var s;

+ 68
- 17
dist/Js/shoppingcart/select_delivery.js 查看文件

@@ -4,8 +4,10 @@ function initSelectDevlivery() {
4 4
     let currencyId = null;
5 5
     let billingInfo = null;
6 6
     let userName = null;
7
+    let stateArr = [];
7 8
 
8 9
     $('.mianselectdelivery').removeClass('d-none');
10
+    
9 11
    
10 12
     let orderBtnAction = {
11 13
         removeOrdernowBtn() {
@@ -98,6 +100,39 @@ function initSelectDevlivery() {
98 100
 
99 101
     }
100 102
 
103
+    function clearAllInputs(){
104
+        $("#state").select2({
105
+            placeholder: "Select a City",
106
+            allowClear: true
107
+        });
108
+
109
+        $('#phonenumber').val(null);
110
+        $('#addressdes').val(null);
111
+        $('#zipcode').val(null);
112
+    }
113
+
114
+    async function appendFormDetails(){
115
+        let cookieRes = COOKIE_HELPER_ACTIONS.getCookie();
116
+        console.log(cookieRes);
117
+        const { errorMsg, isError, response } = await API_SERVICES_ACTIONS.getAPIService(`apis/v4/bizgaze/integrations/products/getbillinginfo/contactid/${cookieRes.userId}`);
118
+        let res = JSON.parse(response.result)[0];
119
+        debugger;
120
+        const {cityid, lobid,organizationname,addressline,cityname,phonenumber,zipcode,name } =res;
121
+
122
+        setAddressHeader({name:organizationname,phonenumber,addressline,cityname,zipcode});
123
+
124
+        $('#phonenumber').val(phonenumber);
125
+            $('#addressdes').val(addressline);
126
+            $('#zipcode').val(zipcode);
127
+            debugger;
128
+            $('.userNamelogin').html(`${userName}`);
129
+
130
+        editMode = true;
131
+        console.log(stateArr);
132
+        renderStates(stateArr);
133
+
134
+    }
135
+
101 136
     async function getAddressRes() {
102 137
         let cookieRes = COOKIE_HELPER_ACTIONS.getCookie();
103 138
         console.log(cookieRes);
@@ -263,6 +298,8 @@ function initSelectDevlivery() {
263 298
         })
264 299
     }
265 300
 
301
+    
302
+
266 303
     async function loadEvents() {
267 304
         $('.addnewAddressContainer').off('click').click(function (e) {
268 305
             $('.addnewAddressContainer').addClass('d-none');
@@ -285,8 +322,19 @@ function initSelectDevlivery() {
285 322
             paymentContainerAction.paymentContainerAdd();
286 323
             $('.displayadress').removeClass('d-none');
287 324
            }
325
+
326
+           clearAllInputs();
288 327
         });
289 328
 
329
+        $('.changeAddressBtn').off('click').click(function (e){
330
+            console.log(e.target);
331
+            //getAddressRes();
332
+            appendFormDetails();
333
+            removeOrderSummary();
334
+            changeAddressBtnAction.removeChangeAddressBtn();
335
+            $('.displayadress').addClass('d-none')
336
+        })
337
+
290 338
         
291 339
         $('.saveanddeliver').off('click').click(async function (e) {
292 340
            
@@ -338,12 +386,7 @@ function initSelectDevlivery() {
338 386
          
339 387
 
340 388
         });
341
-        $('.changeAddressBtn').off('click').click(function (e){
342
-            console.log(e.target);
343
-            removeOrderSummary();
344
-            changeAddressBtnAction.removeChangeAddressBtn();
345
-            $('.displayadress').addClass('d-none')
346
-        })
389
+       
347 390
 
348 391
         $('.ordernowbtn').off().click(async function (e){
349 392
             let cookieRes = COOKIE_HELPER_ACTIONS.getCookie();
@@ -488,6 +531,21 @@ function initSelectDevlivery() {
488 531
 
489 532
     }
490 533
 
534
+    function renderStates(data){
535
+        $('#state').off('select2:select');
536
+        let html = '';
537
+        for (let i = 0; i < data.length; i++) {
538
+            html += `<option value="${data[i].cityid}" data-id="${data[i].cityid}">${data[i].cityname}</option>`
539
+
540
+        }
541
+
542
+        $('#state').append(html);
543
+        $("#state").select2({
544
+            placeholder: "Select a City",
545
+            allowClear: true
546
+        });
547
+    }
548
+
491 549
     async function getCountryStateCurrency() {
492 550
         const countryRes = await API_SERVICES_ACTIONS.getAPIService('apis/v4/bizgaze/integrations/products/getcountry');;
493 551
 
@@ -527,17 +585,10 @@ function initSelectDevlivery() {
527 585
         console.log("start")
528 586
         let html = '';
529 587
         statesList = stateData;
530
-        for (let i = 0; i < stateData.length; i++) {
531
-            html += `<option value="${stateData[i].cityid}" data-id="${stateData[i].cityid}">${stateData[i].cityname}</option>`
532
-
533
-        }
588
+        stateArr = stateData;
589
+        renderStates(stateArr)
534 590
 
535
-        $('#state').append(html);
536
-
537
-        $("#state").select2({
538
-            placeholder: "Select a City",
539
-            allowClear: true
540
-        });
591
+       
541 592
 
542 593
         const currencyRes = await API_SERVICES_ACTIONS.getAPIService('apis/v4/bizgaze/integrations/products/getcurrencies');
543 594
 
@@ -580,7 +631,7 @@ debugger;
580 631
         <input checked data-op="online" name="payment" type="radio" class="paymentbtn   " id="online">
581 632
     </label>
582 633
     <label for="cod">
583
-        Cash on develiop
634
+        Cash on delivery
584 635
         <input data-op="cod" name="payment" type="radio" class="paymentbtn  " id="cod">
585 636
     </label>`);
586 637
 

正在加载...
取消
保存