index.vue 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. <template>
  2. <view class="ui-unit-image-goods">
  3. <u--image mode="aspectFit" :src="local_src" width="355rpx" height="340rpx" :lazy-load="true" :fade="true"
  4. duration="450">
  5. <template v-slot:loading>
  6. <u-loading-icon color="#f7f7f7"></u-loading-icon>
  7. </template>
  8. </u--image>
  9. </view>
  10. </template>
  11. <script>
  12. export default {
  13. name: 'unit-goods-image',
  14. props: {
  15. // 商品图片
  16. src: {
  17. type: String,
  18. default: ''
  19. },
  20. default_img: {
  21. type: String
  22. },
  23. // 商品SKU,用于埋点,曝光
  24. sku: {
  25. type: String,
  26. default: ''
  27. },
  28. // 当前商品曝光顺序
  29. index: {
  30. type: Number,
  31. default: 0
  32. }
  33. },
  34. data() {
  35. const lazyload = this.$store.state.page.env != 1;
  36. let siteinfo = getApp().globalData.siteinfo;
  37. const img = siteinfo.root_img + '/static/app/imgs/default-goods.png';
  38. return {
  39. local_src: this.src || img, // 默认图
  40. lazyload // 是否开启懒加载
  41. };
  42. },
  43. computed: {
  44. // 埋点参数构造
  45. analytics() {
  46. const params = {
  47. pm: `mp`,
  48. p: `p-${this.$root.pageId}`,
  49. bv: {
  50. // cpID: `${this.$root.pageInstanceId}`,
  51. // cpnum: `${this.$root.compKey}`,
  52. // cplocation: `${this.$root.uiIndex}`,
  53. sku: `${this.sku}`,
  54. // cporder: `${this.$root.layoutIndex}`,
  55. rank: `${this.index}`
  56. }
  57. };
  58. return JSON.stringify(params);
  59. }
  60. }
  61. };
  62. </script>
  63. <style lang="less" scoped>
  64. .ui-unit-image-goods {
  65. display: flex;
  66. align-items: center;
  67. align-content: center;
  68. img {
  69. width: 100%;
  70. }
  71. }
  72. </style>