detail.vue 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116
  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" v-if="user.userType == 2">
  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. //加入购物车
  70. addCar() {
  71. let params = {
  72. buyUserId: this.user.id,
  73. enterpriseId: this.item.merchantId,
  74. shopId: this.item.shopId,
  75. tradeAreaId: this.item.tradeAreaId,
  76. saleGoodsInfoId: this.item.id,
  77. goodsImg: this.item.goodsImg,
  78. goodsName: this.item.goodsName,
  79. publishGoodsId: this.item.id
  80. };
  81. this.http.request({
  82. url: '/level-one-server/app/TbGoodsCart/addGoodsInShopCart',
  83. data: params,
  84. method: 'POST',
  85. contentType: 'application/json; charset=utf-8',
  86. success: res => {
  87. uni.showToast({ title: '添加成功' });
  88. }
  89. });
  90. },
  91. // 立即购买
  92. buy() {
  93. this.http.request({
  94. url: '/level-one-server/app/TbGoodsTransit/purchaseLevelOntGoodsTransit',
  95. data: { goodsTransitId: this.item.id },
  96. method: 'POST',
  97. contentType: 'application/json; charset=utf-8',
  98. success: res => {
  99. uni.redirectTo({ url: '/pages/market/one/leader/success' });
  100. }
  101. });
  102. }
  103. }
  104. };
  105. </script>
  106. <style lang="scss">
  107. page {
  108. background-color: $pg;
  109. }
  110. .btn {
  111. width: 100%;
  112. border-radius: 5px;
  113. }
  114. </style>