detail.vue 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117
  1. <template>
  2. <view>
  3. <view class="product_detail">
  4. <image src="../../../static/news.jpg" mode="widthFix" class="pic"></image>
  5. <view class="box">
  6. <view class="title">{{ item.goodsName }}</view>
  7. <view class="price">¥ {{ item.price }}</view>
  8. <view class="clear"></view>
  9. <u-divider text="规格参数"></u-divider>
  10. <view class="item">
  11. <text class="desc">净重:</text>
  12. <text>{{item.netWeight}}吨</text>
  13. </view>
  14. <view class="item">
  15. <text class="desc">毛重:</text>
  16. <text>{{item.grossWeight}}吨</text>
  17. </view>
  18. <view class="item">
  19. <text class="desc">计量单位:</text>
  20. <text>{{item.goodsUnits}}</text>
  21. </view>
  22. <view class="item">
  23. <text class="desc">商户:</text>
  24. <text>{{item.merchantName}}</text>
  25. </view>
  26. <view class="item">
  27. <text class="desc">互市区:</text>
  28. <text>{{item.tradeAreaName}}</text>
  29. </view>
  30. <view class="item">
  31. <text class="desc">发布时间:</text>
  32. <text>{{item.createTime}}</text>
  33. </view>
  34. <u-divider text="商品介绍"></u-divider>
  35. <view class="contents" v-if="item.description">{{item.description}}</view>
  36. <view class="contents">暂无关于该商品的介绍</view>
  37. </view>
  38. </view>
  39. <view class="mfooter" v-if="user.userType == 2">
  40. <view class="flex">
  41. <view class="f">
  42. <button class="save btn" @click="addCar()">加入购物车</button>
  43. </view>
  44. <view class="f">
  45. <button class="btn" @click="buy()">立即购买</button>
  46. </view>
  47. </view>
  48. </view>
  49. </view>
  50. </template>
  51. <script>
  52. export default {
  53. data() {
  54. return {
  55. user: this.getUser(),
  56. item: {}
  57. };
  58. },
  59. onLoad(e) {
  60. if (e.id) {
  61. this.http.request({
  62. url: '/level-one-server/TbGoodsTransit/getById?id=' + e.id,
  63. success: res => {
  64. this.item = res.data.data;
  65. }
  66. });
  67. }
  68. },
  69. methods: {
  70. //加入购物车
  71. addCar() {
  72. let params = {
  73. buyUserId: this.user.id,
  74. enterpriseId: this.item.merchantId,
  75. shopId: this.item.shopId,
  76. tradeAreaId: this.item.tradeAreaId,
  77. saleGoodsInfoId: this.item.id,
  78. goodsImg: this.item.goodsImg,
  79. goodsName: this.item.goodsName,
  80. publishGoodsId: this.item.id
  81. };
  82. this.http.request({
  83. url: '/level-one-server/app/TbGoodsCart/addGoodsInShopCart',
  84. data: params,
  85. method: 'POST',
  86. contentType: 'application/json; charset=utf-8',
  87. success: res => {
  88. uni.showToast({ title: '添加成功' });
  89. }
  90. });
  91. },
  92. // 立即购买
  93. buy() {
  94. this.http.request({
  95. url: '/level-one-server/app/TbGoodsTransit/purchaseLevelOntGoodsTransit',
  96. data: { goodsTransitId: this.item.id },
  97. method: 'POST',
  98. contentType: 'application/json; charset=utf-8',
  99. success: res => {
  100. uni.redirectTo({ url: '/pages/market/one/leader/success' });
  101. }
  102. });
  103. }
  104. }
  105. };
  106. </script>
  107. <style lang="scss">
  108. page {
  109. background-color: $pg;
  110. }
  111. .btn {
  112. width: 100%;
  113. border-radius: 5px;
  114. }
  115. </style>