thedreamydresses.shop Open in urlscan Pro
2a06:98c1:3121::3  Public Scan

Submitted URL: http://thedreamydresses.shop/static/site/js/heade.js?v=1.0.1
Effective URL: https://thedreamydresses.shop/static/site/js/heade.js?v=1.0.1
Submission: On August 25 via api from US — Scanned from NL

Form analysis 0 forms found in the DOM

Text Content

let header = {
  data: {
    colors: ["#5e5047"],
    hover_img: "",
    menu_box: false,
    rate: 5,
    v: false,
    small_left_icon: true,
    imgloading: true,
    Bottom_prompt: true,
    show3: true,
    emails_footer: "",
    big_dial: false,
    Easy_po_up: false,
    drawer: false,
    drawer_cart: false,
    // big ping
    drawer_cart_big: false,
    search: "",
    search1: '',
    chartList: [], islogin: null,
    radio: '2',
    tabs: 0,
    fullscreenLoading: false,
    dialogVisible: false,
    activeName: 'first',
    ruleForm: {
      username: '',
      password: '',

    },
    regForm: {
      username: '',
      password: '',
      address: ""
    },
    PaymentGoods: [],
    currency: "",
    activeMenu: 'Home',
    topMenu: [{ product_type: 'Home' }],
    topMenu1: [],
    num: 1,
    csrftoken: "",
    listData: {
      product_sku: {
        sku_code: {
          data: [], show_name: ''
        }
      }
    },
    randomList: [
      {
        sku_code_add: {
          data: []
        },
        sku_code: { data: [] }
      }
    ],
    languageUrl: "",
    language_value: "",
    specifications: '',
    bill_number: "", dectitle: "", specificationsInfo: {},
    sku_code_List: [],
    isshow: 8,
    selspecificat: "", url: '',
    cartNum: 0,
    template: '', s: '', sku_code_AddList: [], disablepRompt: false, wishlist_box: [], product_number: '', visitorId: "",
    languageList: [
      { label: 'English', value: 'en', url: window.location.href },
      { label: 'German', value: 'de', url: window.location.origin + '/de' + window.location.pathname },
      { label: 'Spanish', value: 'es', url: window.location.origin + '/es' + window.location.pathname },
      { label: 'French', value: 'fr', url: window.location.origin + '/fr' + window.location.pathname },
    ],
    hasLang: [
      { label: 'English', value: 'en', url: '' },
      { label: 'German', value: 'de', url: '' },
      { label: 'Spanish', value: 'es', url: '' },
      { label: 'French', value: 'fr', url: '' },
    ],
  },

  computed: {
    chatnum() {
      let num = this.chartList.reduce((sum, e) => sum + Number(e.Product_num), 0)
      //    if (num >=2) {

      //   this.Bottom_prompt = false    

      // } else {
      //   this.Bottom_prompt = true
      // }
      return num
    },

    allPrice() {
      let num = this.chartList.reduce((sum, e) => sum + e.Product_num * e.price, 0)
      return num.toFixed(2)
    },
  },

  created() {
    window.addEventListener('pageshow', (e) => {
      if (e.persisted || (window.performance && 
        window.performance.navigation.type == 2)) {
        location.reload()
      }
    }, false)   

  
    // let b = window.location.pathname.substring(4)
    // this.hasLang.forEach(i => {
    //   i.url = window.location.origin + '/' + i.value + '/' + b
    // })

    const root = document.documentElement;

    // const mainColor = getComputedStyle(root).getPropertyValue('--primary-color-te6');

    // root.style.setProperty('--primary-color-te6', '#83b735');
    this.randomProduct()
    // let g = document.getElementById('deft')
    // g.setAttribute('src', `${g.getAttribute("src")}?t=${new Date().getTime()}`)
    // window.addEventListener('scroll', function () {
    //   let header = document.getElementById('header')
    //   let headertep2 = document.getElementById('stuck')

    //   let scrollDistance = document.documentElement.scrollTop;
    //   if (scrollDistance > 202) {
    //     header.classList.add('header');
    //     header.classList.add('stuck');
    //   } else {
    //     header.classList.remove('header');
    //     header.classList.remove('stuck');
    //   }
    // });
    if (localStorage.getItem('IsAdd') !== null) {
      this.drawer_cart_big = true
      localStorage.removeItem('IsAdd')
    }
    if (localStorage.getItem('Language') !== null) {
      this.language_value = localStorage.getItem('Language')
    }
    if (localStorage.getItem('Bottom_prompt') !== null) {
      this.Bottom_prompt = JSON.parse(localStorage.getItem('Bottom_prompt'))
    }
    if (localStorage.getItem('wishlist_box') !== null) {
      this.wishlist_box = JSON.parse(localStorage.getItem('wishlist_box'))
    }
    if (!window.location.href.includes('shop')) {
      localStorage.setItem('ranking_selection_value', '')
    }
    // this.template = document.getElementById('template').value
    if (localStorage.getItem('topMenu1') != null) {
      this.topMenu1 = JSON.parse(localStorage.getItem('topMenu1'))
    }
    if (localStorage.getItem('bill_number') != null) {
      this.bill_number = JSON.parse(localStorage.getItem('bill_number'))
    }
    console.log(localStorage.getItem('activeMenu'), 'localStorage.getItem()');
    if (localStorage.getItem('activeMenu') !== null) {
      this.activeMenu = JSON.parse(localStorage.getItem('activeMenu'))
    }
    let urlParams = new URLSearchParams(window.location.search);
    if (!urlParams.get('cf')) {
      if (localStorage.getItem('chartList') !== null) {
        this.chartList = JSON.parse(localStorage.getItem('chartList'))
        if (this.chartList.length > 0) {
          this.currency = this.chartList[0].currency
        }
      }
    }

    if (localStorage.getItem('islogin') !== null) {
      this.islogin = JSON.parse(localStorage.getItem('islogin'))
    }
    // templ 3  templ 5  
    // this.get_product_type()
    // this.csrftoken = document.querySelector('[name=csrfmiddlewaretoken]').value;

    setTimeout(() => { this.small_left_icon = false }, 8000)
    this.visitorIds()
  },

  methods: {
    showImage(val) {
      this.hover_img = val
    },
    languageChange(val) {
      let b = window.location.pathname.substring(4)
      let c = window.location.pathname.slice(1, 3)
      console.log(window.location, c);
      let arr = ['en', 'de', 'fr', 'es',]
      if (arr.includes(c)) {
        if (val == 'en') {
          window.location.href = window.location.origin + '/' + b
        } else {
          window.location.href = window.location.origin + '/' + val + '/' + b
        }
      } else {
        if (val == 'en') {
          window.location.href = window.location.origin + '/' + b
        } else {
          window.location.href = window.location.origin + '/' + val + window.location.pathname
        }
      }

      localStorage.setItem('Language', val);
    },
    dd(id) {
      let a = document.getElementById(id)
      $(a).next().animate({ height: 'toggle' })
      // a.nextElementSibling.style.display='block'
      console.log(5, a);
    },
    randomProduct() {
      let a = []
      this.chartList.find(i => {
        a.push(i.id)
      })
      randomProduct({ product_number: a }).then(res => {
        if (res.code == 200) {
          this.randomList = res.data
          this.randomList.forEach(i => {
            i.sku_code_addB = ''
            i.sku_codeA = ''
          })
        }
      })
    },
    visitorIds() {
      const fpPromise = FingerprintJS.load();
      fpPromise.then(fp => {
        // Get the visitor identifier
        fp.get().then(result => {
          this.visitorId = result.visitorId;
          localStorage.setItem('visitorId', this.visitorId);
        });
      });
    },
    Bottom_promptChange() {
      this.Bottom_prompt = false
      localStorage.setItem('Bottom_prompt', this.Bottom_prompt)
    },
    Continue_home(value) {
      let currentIframe = window.self;
      if (value == 'Checkout') {
        location.reload();
        return
      }
      if (value) {
        parent.location.href = `${this.urlxxx}/${value}/`
      } else {
        parent.location.href = `${this.urlxxx}`
      }

    },
    wishlist(item) {
      console.log(this.wishlist_box);
      let ishave = this.wishlist_box.filter(el => {
        return el.id === item.id
      })
      if (ishave.length === 0) {
        this.wishlist_box.push(item)
        this.$message.success('Added successfully')
      } else {
        this.$message.error('The product has been added')
      }
      localStorage.setItem('wishlist_box', JSON.stringify(this.wishlist_box))
    },
    disabled() {
      this.disablepRompt = true
      var section = document.getElementById('rargerID');
      section.scrollIntoView({ behavior: 'smooth' });

    },

    send_email() {
      if (this.emails_footer.includes("@")) {
        this.$message.success('Successfully sent')
      } else if (this.emails_footer == '') {
        this.$message.error('Cannot be empty')
      } else {
        this.$message.error('Email input error')
      }
    },
    // template9
    removetype() {
      localStorage.removeItem('activeMenu')
    },
    addCar(type) {
      let data = {
        type: type
      }
      addCar(data).then(res => { })
    },
    handleSelect(command) {
      let a = command.replace(/\s+/g, '-')
      this.activeMenu = a.toLowerCase()
      console.log(a, '55');
      localStorage.setItem('activeMenu', JSON.stringify(this.activeMenu))
    },
    topro(val) {
      console.log(val);
      localStorage.setItem('product_number', val)
    },
    change_S(d) {
      window.location.href = `/searchdetails/?s=${d}`
    },
    top_search() {
      if (this.language_value == 'en' || this.language_value == '') {
        if (this.activeMenu == 'shop') {
          window.location.href = `/shop/Home/page-1/?title=${this.search}`
        } else {
          window.location.href = `/shop/${this.activeMenu == '' ? '' : this.activeMenu + '/'}page-1/?title=${this.search}`
        }
      } else {
        if (this.activeMenu == 'shop') {
          window.location.href = `/${this.language_value}/shop/Home/page-1/?title=${this.search}`
        } else {
          window.location.href = `/${this.language_value}/shop/${this.activeMenu == '' ? '' : this.activeMenu + '/'}page-1/?title=${this.search}`
        }
      }


      sessionStorage.setItem('top_search', this.search)

    },
    handleCommand_Menu(command) {
      let a = command.replace(/\s+/g, '-')
      //  return
      this.activeMenu = a
      localStorage.setItem('activeMenu', JSON.stringify(a))
      if (command == 'Home') {
        window.location.href = '/';
      } else {
        window.location.href = `/shop/${a.toLowerCase()}/`
      }
    },
    // dnanjo menu
    handleCommand1(command) {

      let a = command.replace(/\s+/g, '-')
      //  return
      this.activeMenu = a
      localStorage.setItem('activeMenu', JSON.stringify(a))
      window.location.href = `/shop/${a.toLowerCase()}/`
    },
    //server  tem2
    handleCommand(command) {
      if (command == 'Home') {
        window.location.href = '/';
      } else {
        window.location.href = command.toLowerCase();
      }
    },
    specificationsSelect(item, index) {
      this.srcListK = []
      if (item.img != '') {
        this.url = item.img
        this.srcListK.push(item.img)
      }
      this.specificationsInfo = item
      this.selspecificat = index
      this.dectitle = `${item.name ? item.name : ''} ${item.currency ? item.currency : ''} ${item.price ? item.price : ''}`
    },
    handleChange() {

    },
    unpdatacart() {

      localStorage.setItem('User_Enforcement', true)
      this.fullscreenLoading = true
      this.chartList.forEach(item => {
        // item.allPrice=(Number(item.price)*Number(item.Product_num))
        item.price = Number(item.price)
        item.Product_num = Number(item.Product_num)
        item.allPrice = (item.price * item.Product_num).toFixed(2)
      })
      localStorage.setItem("chartList", JSON.stringify(this.chartList))
      setTimeout(() => {
        this.fullscreenLoading = false
      }, 500);
    },
    CHECKOUT(v) {
      if (v != 'no') {
        this.addCar('checkout')
      }
      this.getDomain()
    },

    encrypt(text, offset) {
      let result = '';
      for (let i = 0; i < text.length; i++) {
        let charCode = text.charCodeAt(i);
        if (charCode >= 65 && charCode <= 90) {
          result += String.fromCharCode((charCode - 65 + offset) % 26 + 65);
        } else if (charCode >= 97 && charCode <= 122) {
          result += String.fromCharCode((charCode - 97 + offset) % 26 + 97);
        } else {
          result += text[i];
        }
      }
      return result;
    },
    commit_cartinfo(v) {
      let b = this.PaymentGoods.reduce((sum, e) => sum + e.Product_num * e.price, 0)
      let data = {
        fkey: this.visitorId, chartList: v == 'buynow' ? this.PaymentGoods : this.chartList, total: v == 'buynow' ? b : this.allPrice, domain: window.location.hostname
      }    
      const loading = this.$loading({
        lock: true,
        text: 'Loading',
        spinner: 'el-icon-loading',
        background: 'rgba(255, 255, 255, 0.7)'
      });
      commit_cartinfo(data).then(res => {     
        if (res.code == 200) {
          if (window.location.hostname == '192.168.124.31') {
            window.location.href = `http://${res.data.domain_b}:8999/checkout/?cf=${this.encrypt(res.data.domain_a, 3)}`
          } else {
            window.location.href = `https://${res.data.domain_b}/checkout/?cf=${this.encrypt(res.data.domain_a, 3)}`
          }
        }
        loading.close();
      }).catch(err=>{       
        setTimeout(() => {  this.commit_cartinfo(v) }, 2000)
      })
    },
    getDomain(v) {
      this.commit_cartinfo(v)
      localStorage.removeItem("bill_number")
      return
      if (window.location.hostname == 'songqiwangluo.com') {
        let b = this.PaymentGoods.reduce((sum, e) => sum + e.Product_num * e.price, 0)
        let data = {
          fkey: this.visitorId, chartList: v == 'buynow' ? this.PaymentGoods : this.chartList, total: v == 'buynow' ? b : this.allPrice
        }
        add_cart(data).then(res => {
          if (res.code == 200) {
            window.location.href = `https://${res.data.domain}/publicCheckout/?cf=${this.encrypt(window.location.hostname, 3)}`
          }
        })
      }
      // ------------------------------
      if (v == 'buynow') {
        let b = this.PaymentGoods.reduce((sum, e) => sum + e.Product_num * e.price, 0)
        if (Number(b) > 1.99) {
          window.location.href = '/checkout/?v=buynow'
        } else {
          let data = {
            fkey: this.visitorId, chartList: this.PaymentGoods, total: b
          }
          add_cart(data).then(res => {
            if (res.code == 200) {
              window.location.href = `https://${res.data.domain}/publicCheckout/?cf=${this.encrypt(window.location.hostname, 3)}`
            }
          })
        }
      } else {
        if (Number(this.allPrice) > 1.99) {
          window.location.href = '/checkout/'
        } else {
          let data = {
            fkey: this.visitorId, chartList: this.chartList, total: this.allPrice
          }
          add_cart(data).then(res => {
            if (res.code == 200) {
              window.location.href = `https://${res.data.domain}/publicCheckout/?cf=${this.encrypt(window.location.hostname, 3)}`
            }
          })
        }
      }
    },
    // getDomain(v, l) {  
    //   localStorage.removeItem('bill_number')
    //   if (l) {
    //     if (v == 'buynow') {
    //       let b = this.PaymentGoods.reduce((sum, e) => sum + e.Product_num * e.price, 0)
    //       if (Number(b) > 200) {
    //         window.location.href = '/' + l + '/checkout/?v=buynow'
    //       } else {
    //         let data = {
    //           fkey: this.visitorId, chartList: this.PaymentGoods, total: b
    //         }
    //         add_cart(data).then(res => {
    //           if (res.code == 200) {
    //             // window.location.href = `http://192.168.124.31:1400/publicCheckout/?cf=${this.encrypt(window.location.hostname, 3)}`
    //             window.location.href = `https://${res.data.domain}/${l}/publicCheckout/?cf=${this.encrypt(window.location.hostname, 3)}`
    //           }
    //         })
    //       }
    //     } else {
    //       if (Number(this.allPrice) >200) {
    //         window.location.href = '/' + l + '/checkout/'
    //       } else {
    //         let data = {
    //           fkey: this.visitorId, chartList: this.chartList, total: this.allPrice
    //         }
    //         add_cart(data).then(res => {
    //           if (res.code == 200) {
    //             window.location.href = `https://${res.data.domain}/${l}/publicCheckout/?cf=${this.encrypt(window.location.hostname, 3)}`
    //           }
    //         })
    //       }
    //     }

    //   } else {
    //     if (v == 'buynow') {
    //       let b = this.PaymentGoods.reduce((sum, e) => sum + e.Product_num * e.price, 0)
    //       if (Number(b)  >200) {
    //         window.location.href = '/checkout/?v=buynow'
    //       } else {
    //         let data = {
    //           fkey: this.visitorId, chartList: this.PaymentGoods, total: b
    //         }
    //         add_cart(data).then(res => {
    //           if (res.code == 200) {
    //             // window.location.href = `http://192.168.124.31:1400/publicCheckout/?cf=${this.encrypt(window.location.hostname, 3)}`
    //             window.location.href = `https://${res.data.domain}/publicCheckout/?cf=${this.encrypt(window.location.hostname, 3)}`
    //           }
    //         })
    //       }
    //     } else {
    //       if (Number(this.allPrice) >200) {
    //         window.location.href = '/checkout/'
    //       } else {
    //         let data = {
    //           fkey: this.visitorId, chartList: this.chartList, total: this.allPrice
    //         }
    //         add_cart(data).then(res => {
    //           if (res.code == 200) {
    //             window.location.href = `https://${res.data.domain}/publicCheckout/?cf=${this.encrypt(window.location.hostname, 3)}`
    //           }
    //         })
    //       }
    //     }

    //   }
    // },
    back() {

      history.back();

    },
    encryptAES(text, key) {
      return CryptoJS.AES.encrypt(text, key).toString();
    },
    VIEWCART() {
      window.location.href = '/cart/'
    },
    buynow_dio(data, num, l) {
      this.addCar('checkout')
      // if (this.bill_number != '') {
      //   this.$message.error('You have unpaid orders, please process the unfinished orders first')
      //   return
      // }

      if (this.listData.product_sku && this.listData.product_sku.sku_code.data.length > 0) {
        if (this.selspecificat == null) {
          this.$message.error('Please select a specification');
          return
        }
      }
      if (this.listData.product_sku && this.listData.product_sku.sku_code_add.data.length > 0) {
        if (this.specifications == '' || this.selspecificat == null) {
          this.$message.error('Please select a specification');
          return
        }
      }
      this.disablepRompt = false
      this.isIntroduction = true
      let { main_img, product_type, title, price, id, currency, url, } = data
      let listboj = {
        id, currency, product_number: this.product_number, url: url,
        main_img, product_type, title, price: Number(price), Product_num: Number(this.num), allPrice: Number(price) * Number(this.num)
      }

      let hasSize = {
        url: url, id, currency: !this.specificationsInfo.currency || this.specificationsInfo.currency == '' ? currency : this.specificationsInfo.currency, product_number: this.product_number,
        main_img: !this.specificationsInfo.img || this.specificationsInfo.img == '' ? main_img : this.specificationsInfo.img, product_type, title, price: !this.specificationsInfo.price || this.specificationsInfo.price == '' ? price : this.specificationsInfo.price, Product_num: this.num, allPrice: !this.specificationsInfo.price || this.specificationsInfo.price == '' ? price * this.num : this.specificationsInfo.price * this.num, skuinfo: `${this.specificationsInfo.name},${this.specifications}`, sku_code: this.specificationsInfo.name, sku_code_add: this.specifications
      }
      let v = []
      if (this.listData.product_sku && this.listData.product_sku.sku_code.data.length > 0) {
        v.push(hasSize)
      } else {
        v.push(listboj)
      }
      this.PaymentGoods = v
      localStorage.setItem("PaymentGoods", JSON.stringify(v))

      if (l != 'None') {
        this.getDomain('buynow', l)
      } else {
        this.getDomain('buynow')
      }

    },
    cartbuysubmit_dio(data, num) {
      if (data.sku_code.data.length > 0) {
        if (data.sku_codeA == '' || data.sku_codeA == null) {
          this.$message.error('Please select a specification');
          return
        }
      }
      if (data.sku_code_add.data.length > 0) {
        if (data.sku_code_addB == '' || data.sku_code_addB == null) {
          this.$message.error('Please select a specification');
          return
        }
      }

      let { main_img, product_type, title, price, id, currency, url, product_number } = data
      let listboj = {
        id, currency, product_number: num, url: url,
        main_img, product_type, title, price: Number(price), Product_num: Number(num), allPrice: Number(price) * Number(num)
      }

      let hasSize = {
        url: url, id, currency: data.currency, product_number: product_number, skuinfo: `${data.sku_codeA},${data.sku_code_addB}`,
        main_img: main_img, product_type, title, price, Product_num: num, allPrice: price * num, sku_code: data.sku_codeA, sku_code_add: data.sku_code_addB
      }

      let item = this.chartList.find(item => {
        return item.id == id;
      });

      let skusame = this.chartList.find(item => {
        return item.sku_code == hasSize.sku_code && item.sku_code_add == hasSize.sku_code_add;
      });

      if (data.sku_code.data.length > 0) {
        if (this.chartList.length > 0) {

          if (skusame != undefined) {
            this.chartList.forEach(element => {
              if (element.sku_code == hasSize.sku_code && element.sku_code_add == hasSize.sku_code_add) {
                element.Product_num = Number(element.Product_num) + Number(num)
                // !this.specificationsInfo.price || this.specificationsInfo.price == '' ? element.price = element.price : element.price = this.specificationsInfo.price
                element.allPrice = Number(element.price) * Number(element.Product_num)
                element.allPrice = element.allPrice.toFixed(2)
              }
            })
          } else {
            this.chartList.push(hasSize)
          }
        } else {
          this.chartList.push(hasSize)
        }
      } else {
        if (this.chartList.length > 0) {

          if (item != undefined) {
            this.chartList.forEach(element => {
              if (element.id == item.id) {
                element.Product_num = Number(element.Product_num) + Number(num)
                element.allPrice = Number(element.price) * Number(element.Product_num)
              }
            })
          } else {
            this.chartList.push(listboj)
          }
        } else {
          this.chartList.push(listboj)
        }
      }
      this.$message.success('Added to shopping cart')
      localStorage.setItem("chartList", JSON.stringify(this.chartList))
      localStorage.setItem('IsAdd', true)
      this.randomProduct()

    },
    formsubmit_dio(data, num) {
      this.disablepRompt = false
      this.addCar('addCart')
      // if (this.bill_number != '') {
      //   this.$message.error('You have unpaid orders, please process the unfinished orders first')
      //   return
      // }
      if (this.listData.product_sku && this.listData.product_sku.sku_code.data.length > 0) {
        if (this.selspecificat == null) {
          this.$message.error('Please select a specification');
          return
        }
      }
      if (this.listData.product_sku && this.listData.product_sku.sku_code_add.data.length > 0) {
        if (this.specifications == '' || this.selspecificat == null) {
          this.$message.error('Please select a specification');
          return
        }
      }

      this.isIntroduction = true

      let { main_img, product_type, title, price, id, currency, url, product_number } = data
      let listboj = {
        id, currency, product_number: this.product_number, url: url,
        main_img, product_type, title, price: Number(price), Product_num: Number(this.num), allPrice: Number(price) * Number(this.num)
      }

      let hasSize = {
        url: url, id, currency: !this.specificationsInfo.currency || this.specificationsInfo.currency == '' ? currency : this.specificationsInfo.currency, product_number: this.product_number,
        main_img: !this.specificationsInfo.img || this.specificationsInfo.img == '' ? main_img : this.specificationsInfo.img, product_type, title, price: !this.specificationsInfo.price || this.specificationsInfo.price == '' ? price : this.specificationsInfo.price, Product_num: this.num, allPrice: !this.specificationsInfo.price || this.specificationsInfo.price == '' ? price * this.num : this.specificationsInfo.price * this.num, skuinfo: `${this.specificationsInfo.name},${this.specifications}`, sku_code: this.specificationsInfo.name, sku_code_add: this.specifications
      }

      let item = this.chartList.find(item => {
        return item.id == id;
      });

      let skusame = this.chartList.find(item => {
        return item.sku_code == hasSize.sku_code && item.sku_code_add == hasSize.sku_code_add;
      });

      if (this.listData.product_sku && this.listData.product_sku.sku_code.data.length > 0) {
        if (this.chartList.length > 0) {

          if (skusame != undefined) {
            this.chartList.forEach(element => {
              if (element.sku_code == hasSize.sku_code && element.sku_code_add == hasSize.sku_code_add) {
                element.Product_num = Number(element.Product_num) + Number(num)
                !this.specificationsInfo.price || this.specificationsInfo.price == '' ? element.price = element.price : element.price = this.specificationsInfo.price
                element.allPrice = Number(element.price) * Number(element.Product_num)
                // element.allPrice = element.allPrice.toFixed(2)
              }
            })
          } else {
            this.chartList.push(hasSize)
          }
        } else {
          this.chartList.push(hasSize)
        }
      } else {
        if (this.chartList.length > 0) {

          if (item != undefined) {
            this.chartList.forEach(element => {
              if (element.id == item.id) {
                element.Product_num = Number(element.Product_num) + Number(num)
                element.allPrice = Number(element.price) * Number(element.Product_num)
              }
            })
          } else {
            this.chartList.push(listboj)
          }
        } else {
          this.chartList.push(listboj)
        }
      }
      this.$message.success('Added to shopping cart')
      localStorage.setItem("chartList", JSON.stringify(this.chartList))
      localStorage.setItem('IsAdd', true)
      location.reload()
    },
    // cha kan details
    chaKanDetails(item) {
      this.imgloading = true
      this.product_number = item.product_number
      this.srcListK = []
      this.dectitle = `${item.name ? item.name : ''} ${item.currency ? item.currency : ''} ${item.price ? item.price : ''}`
      this.specificationsInfo = item
      this.Easy_po_up = true
      fetch('/app/get_productpage', {
        method: 'POST',
        headers: {
          'Content-Type': 'application/json',
          // 'X-CSRFToken': this.csrftoken
        },
        mode: 'same-origin',
        body: JSON.stringify({
          pn: item.product_number,
        })
      }).then(response => response.json())
        .then(data => {
          if (data.data != null) {
            this.listData = data.data
            this.sku_code_List = data.data.product_sku.sku_code.data
            this.sku_code_AddList = data.data.product_sku.sku_code_add.data
            if (this.sku_code_List.length > 0) {
              this.url = this.sku_code_List[0].img
              this.srcListK.push(this.url)
              this.dectitle = `${this.sku_code_List[0].name}${this.sku_code_List[0].currency ? this.sku_code_List[0].currency : ''}${this.sku_code_List[0].price ? this.sku_code_List[0].price : ''}`
              this.specificationsInfo = this.sku_code_List[0]
            }
            this.imgloading = false
          }

        })
        .catch(error => {
          console.error('Error:', error);
        });
    },

    // changeMenu(item) {
    //   this.activeMenu = item.product_type
    //   localStorage.setItem('activeMenu', JSON.stringify(item.product_type))
    //   if (item.product_type == 'Home') {
    //     window.location.href = '/'
    //   } else {
    //     window.location.href = `/shop/`
    //   }
    // },
    get_product_type() {
      get_product_type().then(res => {
        if (res.code == 200) {

          let arr = [{ product_type: "Home" }]
          this.topMenu = [...arr, ...res.data]
          // templte7
          this.topMenu1 = res.data
          localStorage.setItem('topMenu1', JSON.stringify(this.topMenu1))
        }
      })
    },

    tabbar(prodec) {
      window.location.href = `/product/${prodec.product_number}`
    },
    get_product_list(header) {
      if (header) {
        window.location.href = `${window.location.origin}/shop/?title=${this.search}`
      }
    },

    deletechart(index) {
      // if (this.bill_number != '') {
      //   this.$message.error('You have unpaid orders, please process the unfinished orders first')
      //   return
      // }
      this.chartList.splice(index, 1)
      // localStorage.removeItem("chartList");
      localStorage.setItem("chartList", JSON.stringify(this.chartList))
      console.log(localStorage.chartList);
    },
    regForms(formName) {
      console.log(1);
      this.regForm.password = hex_md5(this.regForm.password)
      this.$refs[formName].validate((valid) => {
        if (valid) {
          register(this.regForm).then(res => {
            if (res.code == 200) {
              this.$message.success(res.message)
              this.dialogVisible = false
            } else {
              this.$message.error(res.message)
            }
          })
        } else {
          console.log('error submit!!');
          return false;
        }
      });
    },
    submitForm(formName) {
      this.ruleForm.password = hex_md5(this.ruleForm.password)
      this.$refs[formName].validate((valid) => {
        if (valid) {
          login_very(this.ruleForm).then(res => {
            if (res.code == 200) {
              this.$message.success(res.message)
              this.dialogVisible = false
              this.islogin = res.data.username
              localStorage.setItem('islogin', JSON.stringify(res.data.username))
              localStorage.setItem('token', JSON.stringify(res.data.token))
            } else {
              this.$message.error(res.message)
            }
          })
        } else {
          console.log('error submit!!');
          return false;
        }
      });
    },
    changeSize() {
      if (this.specifications != '') {
        this.disablepRompt = false
      } else {
        this.disablepRompt = true
      }
    },
    cart_close() {
      this.url = ''
      this.Easy_po_up = false
      this.specifications = ''
      this.selspecificat = 0
      this.listData = {
        product_sku: {
          sku_code: {
            data: [], show_name: ''
          }
        }
      }

    },
    handleClose() {
      this.dialogVisible = false
      this.$refs['ruleForm'].resetFields();
      this.$refs['regForm'].resetFields();

    },


  }

}