goodsDetails.vue 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133
  1. <template>
  2. <view>
  3. <navigation-bar background-color="#fff" front-color="#000000" />
  4. <u-image width="100%" height="400rpx" :src="goods.goodsImg"></u-image>
  5. <view class="title pad">
  6. {{goods.goodsName}}
  7. </view>
  8. <view class="price pad">
  9. ¥{{goods.price}} {{goods.goodsUnits}}
  10. </view>
  11. <view class="pad">
  12. <u-tag class="tag" v-for="(item,index) in type" :key="index" :text="item" type="warning" plain></u-tag>
  13. </view>
  14. <view class="pad">
  15. <u--text prefixIcon="home" iconStyle="font-size: 50rpx" :text="goods.merchantName" size="26"></u--text>
  16. </view>
  17. <view class="pad">
  18. <u--text prefixIcon="map" iconStyle="font-size: 50rpx" :text="goods.tradeAreaName" size="26"></u--text>
  19. </view>
  20. <view class="pad des">
  21. <u--text text="商品描述:" size="24"></u--text>
  22. <u--text :text="goods.description? goods.description : '卖家很懒,什么都没有留下'" size="24"></u--text>
  23. </view>
  24. <view class="footer">
  25. <u-button class="custom-style" type="warning" @click="addCar()">加入购物车</u-button>
  26. <u-button class="custom-style" type="error">立即购买</u-button>
  27. </view>
  28. <u-popup :show="show" @close="close" @open="open">
  29. <view>
  30. <text>出淤泥而不染,濯清涟而不妖</text>
  31. </view>
  32. </u-popup>
  33. </view>
  34. </template>
  35. <script>
  36. import common from '../../common/js/common'
  37. export default {
  38. data() {
  39. return {
  40. id: '',
  41. goods: {},
  42. type: [],
  43. show: false,
  44. num: 1
  45. }
  46. },
  47. onLoad(option) {
  48. this.id = option.id
  49. this.getGoodsDetails()
  50. },
  51. methods: {
  52. getGoodsDetails() {
  53. let params = {
  54. id: this.id
  55. }
  56. this.$api.getGoodsDetails(params).then(res => {
  57. this.goods = res.data
  58. if (this.goods) {
  59. this.type = this.goods.goodsType.toString().split("、")
  60. }
  61. })
  62. },
  63. addCar() {
  64. this.show = true
  65. let user = uni.getStorageInfoSync("info")
  66. let params = {
  67. buyUserId: user.id,
  68. enterpriseId: this.goods.merchantId,
  69. shopId: shopId,
  70. tradeAreaId: this.goods.tradeAreaId,
  71. saleGoodsInfoId: this.goods.id,
  72. buyUserType: user.userType,
  73. buyType: 2,
  74. goodsImg: this.goods.goodsImg,
  75. goodsName: this.goods.goodsName,
  76. buyNum: num
  77. }
  78. this.$api.addCar(this.goods).then(res => {
  79. console.log(res)
  80. })
  81. }
  82. }
  83. }
  84. </script>
  85. <style lang="scss">
  86. page {
  87. padding: 0;
  88. }
  89. .pad {
  90. width: 100%;
  91. padding: 10rpx;
  92. display: flex;
  93. }
  94. .title {
  95. font-size: 42rpx;
  96. }
  97. .price {
  98. color: red;
  99. font-size: 40rpx;
  100. }
  101. // .flex-box {
  102. // }
  103. .tag {
  104. width: auto;
  105. margin-right: 10rpx;
  106. }
  107. .custom-style {
  108. width: 50%;
  109. height: 100rpx;
  110. font-size: 30rpx;
  111. }
  112. .des {
  113. border-top: 1rpx #888 solid;
  114. margin-bottom: 10rpx;
  115. }
  116. .footer {
  117. width: 100%;
  118. display: flex;
  119. position: absolute;
  120. bottom: 1rpx;
  121. }
  122. </style>