detail.vue 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123
  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>25吨</text>
  13. </view>
  14. <view class="item">
  15. <text class="desc">毛重:</text>
  16. <text>25吨</text>
  17. </view>
  18. <view class="item">
  19. <text class="desc">净重:</text>
  20. <text>25吨</text>
  21. </view>
  22. <view class="item">
  23. <text class="desc">商户:</text>
  24. <text>基栋收购商</text>
  25. </view>
  26. <view class="item">
  27. <text class="desc">互市区:</text>
  28. <text>东兴一桥互市区</text>
  29. </view>
  30. <view class="item">
  31. <text class="desc">发布时间:</text>
  32. <text>2023-08 15:35</text>
  33. </view>
  34. <u-divider text="商品介绍"></u-divider>
  35. <view class="contents">八角茴香是木兰科八角属的常绿乔木。树皮灰褐色或红褐色;叶互生或叶簇生于枝端;叶片革质,椭圆状倒卵</view>
  36. </view>
  37. </view>
  38. <view class="mfooter">
  39. <view class="flex">
  40. <view class="f">
  41. <button class="save btn" @click="addCar()">加入购物车</button>
  42. </view>
  43. <view class="f">
  44. <button class="btn" @click="buy()">立即购买</button>
  45. </view>
  46. </view>
  47. </view>
  48. </view>
  49. </template>
  50. <script>
  51. export default {
  52. data() {
  53. return {
  54. user: this.getUser(),
  55. item: {}
  56. };
  57. },
  58. onLoad(e) {
  59. if (e.id) {
  60. this.http.request({
  61. url: '/level-one-server/TbGoodsTransit/getById?id=' + e.id,
  62. success: res => {
  63. this.item = res.data.data;
  64. }
  65. });
  66. }
  67. },
  68. methods: {
  69. addCar() {
  70. let params = {
  71. buyUserId: this.user.id,
  72. enterpriseId: this.goods.merchantId,
  73. shopId: this.goods.shopId,
  74. tradeAreaId: this.goods.tradeAreaId,
  75. saleGoodsInfoId: this.goods.id,
  76. goodsImg: this.goods.goodsImg,
  77. goodsName: this.goods.goodsName
  78. // buyNum: parseInt(this.num)
  79. };
  80. this.http.request({
  81. url: '/level-one-server/app/TbGoodsCart/addGoodsInShopCart',
  82. data: params,
  83. contentType: 'application/json; charset=utf-8',
  84. method: 'POST',
  85. success: res => {
  86. setTimeout(function () {
  87. uni.showToast({
  88. title: res.data.msg
  89. });
  90. }, 1000);
  91. }
  92. });
  93. },
  94. // 立即购买
  95. buy() {
  96. this.http.request({
  97. url: '/level-one-server/app/TbGoodsTransit/purchaseLevelOntGoodsTransit',
  98. data: { goodsTransitId: this.item.id },
  99. method: 'POST',
  100. contentType: 'application/json; charset=utf-8',
  101. success: res => {
  102. uni.showToast({ title: '操作成功' });
  103. setTimeout(() => {
  104. uni.$emit('purchaser_buy_list');
  105. uni.navigateBack();
  106. }, 1000);
  107. }
  108. });
  109. }
  110. }
  111. };
  112. </script>
  113. <style lang="scss">
  114. page {
  115. background-color: $pg;
  116. }
  117. .btn {
  118. width: 100%;
  119. border-radius: 5px;
  120. }
  121. </style>