app-goods-detail.vue 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  1. <template>
  2. <view class="app-goods-detail" v-if="goods">
  3. <view class="comments">
  4. <app-comments
  5. :goods-id="goods.id"
  6. ></app-comments>
  7. </view>
  8. <view class="detail" v-if="newDetail">
  9. <image src="/static/image/icon/goods-detail.png"></image>
  10. <view>
  11. <app-rich-text
  12. :content="newDetail"
  13. @preview="preview" @navigate="navigate"
  14. ></app-rich-text>
  15. </view>
  16. </view>
  17. </view>
  18. </template>
  19. <script>
  20. import appRichText from "../../basic-component/app-rich/parse";
  21. import appComments from "../../page-component/app-comments/app-comments.vue";
  22. export default {
  23. name: "app-goods-detail",
  24. data() {
  25. return {
  26. // newDetail: ''
  27. }
  28. },
  29. methods: {
  30. preview(src, e) {
  31. },
  32. navigate(href, e) {
  33. },
  34. },
  35. components: {
  36. 'app-rich-text': appRichText,
  37. 'app-comments': appComments,
  38. },
  39. props: {
  40. goods: {
  41. type: Object,
  42. default() {
  43. return {
  44. }
  45. }
  46. },
  47. detail: {
  48. type: String,
  49. default() {
  50. return '';
  51. }
  52. },
  53. },
  54. created() {
  55. this.$store.dispatch('gConfig/setImageWidth', 48);
  56. },
  57. computed: {
  58. newDetail() {
  59. let detail = '正在加载数据,模拟网络延迟2秒😝';
  60. if (this.goods && typeof this.goods.detail != 'undefined') {
  61. detail = this.goods.detail;
  62. } else if (this.detail) {
  63. detail = this.detail;
  64. }
  65. return detail;
  66. },
  67. },
  68. // watch: {
  69. // goods: {
  70. // handler(v) {
  71. // if (this.goods && typeof this.goods.detail != 'undefined') {
  72. // this.newDetail = this.goods.detail;
  73. // }
  74. // },
  75. // immediate: true,
  76. // },
  77. // detail: {
  78. // handler(v) {
  79. // this.newDetail = v;
  80. // },
  81. // immediate: true
  82. // }
  83. // }
  84. }
  85. </script>
  86. <style scoped lang="scss">
  87. .comments {
  88. margin-bottom: #{20rpx};
  89. background-color: #ffffff;
  90. }
  91. .detail {
  92. background-color: #ffffff;
  93. padding: #{0 24upx};
  94. image {
  95. width: 100%;
  96. height: #{80rpx};
  97. display: block;
  98. }
  99. }
  100. </style>