goods-detail.vue 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117
  1. <template>
  2. <el-row v-loading="dataListLoading">
  3. <el-col :span="6" :offset="2">
  4. <div class="TT-photo">
  5. <img :src="info.productImgUrl" alt="">
  6. </div>
  7. </el-col>
  8. <el-col :span="14">
  9. <el-form :model="info">
  10. <el-form-item label="名称:">
  11. <span class="col_f64f6f">{{ info.productName }}</span>
  12. </el-form-item>
  13. <el-form-item label="价格:">
  14. <span class="col_f64f6f font-w_bold">¥{{ info.productPrice >= 0 ? info.productPrice.toFixed(2) : '' }}</span>
  15. </el-form-item>
  16. <el-form-item label="库存:">
  17. <span>库存{{ info.productStorageNum }}件</span>
  18. </el-form-item>
  19. <el-form-item label="商品销量:">
  20. <span>{{ info.productSaleNum }}</span>
  21. </el-form-item>
  22. <el-form-item label="仓库:">
  23. <span class="col_f64f6f">{{ info.warehouseName }}</span>
  24. </el-form-item>
  25. <el-form-item label="快递费:">
  26. <span class="col_f64f6f">¥{{ info.warehousePrice >= 0 ? info.warehousePrice.toFixed(2) : '' }}</span>
  27. </el-form-item>
  28. <el-form-item class="margin-top_30">
  29. <el-button type="primary" @click="$router.push({name: 'goodsCreateOrder', query: {id: id}})">立即购买</el-button>
  30. </el-form-item>
  31. </el-form>
  32. </el-col>
  33. <el-col :span="12" :offset="6">
  34. <div class="TT-photo">
  35. <img :src="info.productImgUrl" alt="">
  36. </div>
  37. </el-col>
  38. </el-row>
  39. </template>
  40. <script>
  41. import Crypto from '@/utils/crypto'
  42. export default {
  43. name: 'goods-detail',
  44. props: {
  45. id: {
  46. type: String,
  47. default: ''
  48. }
  49. },
  50. data () {
  51. return {
  52. dataListLoading: false,
  53. info: {}
  54. }
  55. },
  56. activated () {
  57. if (!this.$route.meta.isUseCache) {
  58. this.info = {}
  59. this.funInit()
  60. }
  61. this.$route.meta.isUseCache = false
  62. },
  63. methods: {
  64. funInit () {
  65. this.dataListLoading = true
  66. this.$http({
  67. url: this.$http.adornUrl('/gift/product/detail'),
  68. method: 'get',
  69. params: this.$http.adornParams({
  70. 'id': Crypto.decrypt(this.id)
  71. })
  72. }).then(({ data }) => {
  73. if (data.status) {
  74. this.info = data.data
  75. } else {
  76. this.$message.error(data.msg)
  77. }
  78. this.dataListLoading = false
  79. })
  80. }
  81. },
  82. beforeRouteLeave (to, from, next) {
  83. console.log(to.name)
  84. if (['goodsCreateOrder'].includes(to.name)) {
  85. from.meta.isUseCache = true
  86. }
  87. next()
  88. }
  89. }
  90. </script>
  91. <style lang="scss" scoped>
  92. .col_f64f6f {
  93. color: #f64f6f;
  94. }
  95. .font-w_bold {
  96. font-weight: bold;
  97. }
  98. .margin-top_30 {
  99. margin-top: 30px;
  100. }
  101. /deep/ .el-form-item {
  102. margin-bottom: 0;
  103. }
  104. .TT-photo {
  105. img {
  106. display: block;
  107. width: 100%;
  108. }
  109. }
  110. </style>