goods.js 1.06 KB
// components/Goods/Goods.js
import homeApi from '~/api/module/home.js'
import cartApi from '~/api/module/cart.js'
Component({
  /**
   * 组件的属性列表
   */
  properties: {
    list: {
      type: Array,
      value: []
    }
  },

  /**
   * 组件的初始数据
   */
  data: {
    IMGURL: wx.$imgUrl
  },

  /**
   * 组件的方法列表
   */
  methods: {
    setWidth() {
      wx.p.wxApi.getViewInfo(
        '.Goods',
        res => {
          this.setData({
            previewHeight: res.width * 2
          })
        },
        this
      )
    },
    // 进入商品详情
    handleSale(e) {
      let { target } = e.currentTarget.dataset
      // 自营商品与云中鹤商品数据不同
      let url = target?.goodsSource == 1 ? '/packageIndex/pages/goodsDetail/index' : '/packageIndex/pages/selfGoodsDetail/index'
      wx.p.router.go(url, target)
    },
    joinCart(e) {
      this.handleSale(e)
    }
  },
  lifetimes: {
    attached() {
      this.setWidth()
      let userInfo = wx.p.storage.get('userInfo')
      this.setData({userInfo})
    }
  }
})