product-detail.js 1.33 KB
import api from '@/api/api'
import {
  httpGet,
  httpPost
} from '@/api/fetch-api.js'

export default {
  data() {
    return {
      key: 'value',
      product: {},
      store: {},
      params: {},
      imageUrls: [],
      active: 0,
      sticky: true,
    }
  },
  components: {},
  methods: {
    onNavHandler(index, title) {
      document.getElementById("scroll" + index).scrollIntoView({
        behavior: "smooth",
      });
    },
    toTop() {
      document.getElementById("scroll0").scrollIntoView({
        behavior: "smooth",
      });
    },
    // 进入店铺
    toShopDetail() {
      let c = this.store.storeCode || "";
      if (c) {
        this.$router.push({
          path: "/shop/detail",
          query: {
            c: c,
          }
        })
      }
    },
    // 请求产品详情
    queryProductDetail() {
      let c = this.$route.query.c;
      httpGet({
        url: api.productDetail,
        data: {
          productCode: c,
        }
      }).then((result) => {
        this.product = result.product || {};
        this.store = result.store || {};
        this.params = result.params || {};
        this.imageUrls = result && result.product && result.product.imageUrls || [];
      })
    },
    initData() {
      this.queryProductDetail();
    }
  },
  mounted() {},
  created() {
    this.initData();
  }
}