onlineDetail.vue 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132
  1. <template>
  2. <view class="product-detail-page">
  3. <view class="headers">
  4. <headersVue headerTitle="商品详情" @headerJump="headerJump"></headersVue>
  5. </view>
  6. <view class="product-image-container" v-if="productDetailObj.spuId_info">
  7. <image
  8. v-if="!isError && productDetailObj.spuId_info.cover_url"
  9. :src="productDetailObj.spuId_info.cover_url"
  10. mode="scaleToFill"
  11. @error="handleError"
  12. class="product-image"
  13. ></image>
  14. <image
  15. src="/static/images/new_ui/kongtu.png"
  16. mode="scaleToFill"
  17. class="product-image"
  18. v-else
  19. />
  20. </view>
  21. <ProductInfo :product="productDetailObj" :skuId_info="skuId_info"/>
  22. <ProductSpec :product="productDetailObj" :skuId_info="skuId_info"/>
  23. <DeliveryInfo :delivery="productDetailObj" :skuId_info="skuId_info"/>
  24. <view class="merchant-code-container">
  25. <view class="label">商户编码</view>
  26. <view class="value">{{ productDetailObj.spuId_info && productDetailObj.spuId_info.spu_id }}</view>
  27. </view>
  28. <RichTextDetail :productDetail="productDetail" />
  29. </view>
  30. </template>
  31. <script>
  32. import ProductInfo from "./components/detail/ProductInfo.vue";
  33. import ProductSpec from "./components/detail/ProductSpec.vue";
  34. import DeliveryInfo from "./components/detail/DeliveryInfo.vue";
  35. import RichTextDetail from "./components/detail/RichTextDetail.vue";
  36. import headersVue from "../../shop/components/headers/headers.vue";
  37. import {productDetailApi} from "@/commit/product.js"
  38. export default {
  39. components: {
  40. ProductInfo,
  41. ProductSpec,
  42. DeliveryInfo,
  43. RichTextDetail,
  44. headersVue,
  45. },
  46. data() {
  47. return {
  48. productDetailObj:{},
  49. productDetail: "", // 这里需要根据实际富文本数据格式填充,例如从接口获取
  50. isError:false,
  51. skuId_info:{}
  52. };
  53. },
  54. async onLoad(options) {
  55. this.spu_id = options.spu_id;
  56. await this.getProductDetail(this.spu_id);
  57. },
  58. methods: {
  59. handleError(){
  60. this.isError = true;
  61. },
  62. headerJump() {
  63. uni.redirectTo({ url: "./onlineproductselection" });
  64. },
  65. async getProductDetail(spu_id) {
  66. uni.showLoading({
  67. title: '加载中',
  68. mask: true
  69. })
  70. try {
  71. const res = await productDetailApi({spu_id:spu_id || this.spu_id})
  72. if(res.data.status == 200){
  73. this.productDetailObj = res.data.data || {}
  74. this.productDetail = this.productDetailObj.spuId_info.detail
  75. this.skuId_info = this.productDetailObj.skuId_info[0] || {}
  76. }
  77. uni.hideLoading()
  78. } catch (error) {
  79. uni.hideLoading()
  80. }
  81. },
  82. },
  83. };
  84. </script>
  85. <style>
  86. page {
  87. background-color: #f7f8fc;
  88. }
  89. </style>
  90. <style lang="scss" scoped>
  91. .product-detail-page {
  92. height: 100%;
  93. padding: 0 26rpx 40rpx;
  94. .headers {
  95. position: fixed;
  96. top: 0;
  97. width: 100%;
  98. height: 100rpx;
  99. box-sizing: border-box;
  100. z-index: 666;
  101. }
  102. }
  103. .product-image-container {
  104. width: 100%;
  105. margin-bottom: 30rpx;
  106. border-radius: 10rpx;
  107. // border: 2rpx solid red;
  108. overflow: hidden;
  109. margin-top: 120rpx;
  110. background: #fff;
  111. }
  112. .product-image {
  113. width: 100%;
  114. }
  115. .merchant-code-container {
  116. background-color: #ffffff;
  117. border-radius: 10rpx;
  118. box-shadow: 0 2rpx 4rpx rgba(0, 0, 0, 0.1);
  119. padding: 30rpx;
  120. margin-bottom: 30rpx;
  121. }
  122. .label {
  123. font-size: 28rpx;
  124. color: #666666;
  125. margin-bottom: 10rpx;
  126. }
  127. .value {
  128. font-size: 30rpx;
  129. color: #333333;
  130. }
  131. </style>