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

+ 68
- 17
dist/Js/shoppingcart/select_delivery.js Переглянути файл

4
     let currencyId = null;
4
     let currencyId = null;
5
     let billingInfo = null;
5
     let billingInfo = null;
6
     let userName = null;
6
     let userName = null;
7
+    let stateArr = [];
7
 
8
 
8
     $('.mianselectdelivery').removeClass('d-none');
9
     $('.mianselectdelivery').removeClass('d-none');
10
+    
9
    
11
    
10
     let orderBtnAction = {
12
     let orderBtnAction = {
11
         removeOrdernowBtn() {
13
         removeOrdernowBtn() {
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
     async function getAddressRes() {
136
     async function getAddressRes() {
102
         let cookieRes = COOKIE_HELPER_ACTIONS.getCookie();
137
         let cookieRes = COOKIE_HELPER_ACTIONS.getCookie();
103
         console.log(cookieRes);
138
         console.log(cookieRes);
263
         })
298
         })
264
     }
299
     }
265
 
300
 
301
+    
302
+
266
     async function loadEvents() {
303
     async function loadEvents() {
267
         $('.addnewAddressContainer').off('click').click(function (e) {
304
         $('.addnewAddressContainer').off('click').click(function (e) {
268
             $('.addnewAddressContainer').addClass('d-none');
305
             $('.addnewAddressContainer').addClass('d-none');
285
             paymentContainerAction.paymentContainerAdd();
322
             paymentContainerAction.paymentContainerAdd();
286
             $('.displayadress').removeClass('d-none');
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
         $('.saveanddeliver').off('click').click(async function (e) {
339
         $('.saveanddeliver').off('click').click(async function (e) {
292
            
340
            
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
         $('.ordernowbtn').off().click(async function (e){
391
         $('.ordernowbtn').off().click(async function (e){
349
             let cookieRes = COOKIE_HELPER_ACTIONS.getCookie();
392
             let cookieRes = COOKIE_HELPER_ACTIONS.getCookie();
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
     async function getCountryStateCurrency() {
549
     async function getCountryStateCurrency() {
492
         const countryRes = await API_SERVICES_ACTIONS.getAPIService('apis/v4/bizgaze/integrations/products/getcountry');;
550
         const countryRes = await API_SERVICES_ACTIONS.getAPIService('apis/v4/bizgaze/integrations/products/getcountry');;
493
 
551
 
527
         console.log("start")
585
         console.log("start")
528
         let html = '';
586
         let html = '';
529
         statesList = stateData;
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
         const currencyRes = await API_SERVICES_ACTIONS.getAPIService('apis/v4/bizgaze/integrations/products/getcurrencies');
593
         const currencyRes = await API_SERVICES_ACTIONS.getAPIService('apis/v4/bizgaze/integrations/products/getcurrencies');
543
 
594
 
580
         <input checked data-op="online" name="payment" type="radio" class="paymentbtn   " id="online">
631
         <input checked data-op="online" name="payment" type="radio" class="paymentbtn   " id="online">
581
     </label>
632
     </label>
582
     <label for="cod">
633
     <label for="cod">
583
-        Cash on develiop
634
+        Cash on delivery
584
         <input data-op="cod" name="payment" type="radio" class="paymentbtn  " id="cod">
635
         <input data-op="cod" name="payment" type="radio" class="paymentbtn  " id="cod">
585
     </label>`);
636
     </label>`);
586
 
637
 

Завантаження…
Відмінити
Зберегти