goodsDetails.vue 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165
  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. <view class="num">
  31. <u-button class="numBtn" icon="minus" @click="minus()"></u-button>
  32. <text v-model="num">{{num}}</text>
  33. <u-button class="numBtn" icon="plus" @click="add()"></u-button>
  34. </view>
  35. <u-button type="primary" shape="circle" size="40" text="确定" @click="addCar()"></u-button>
  36. </view>
  37. </u-popup> -->
  38. </view>
  39. </template>
  40. <script>
  41. import common from '../../common/js/common'
  42. export default {
  43. data() {
  44. return {
  45. id: '',
  46. goods: {},
  47. type: [],
  48. show: false,
  49. num: 1
  50. }
  51. },
  52. onLoad(option) {
  53. this.id = option.id
  54. this.getGoodsDetails()
  55. },
  56. methods: {
  57. getGoodsDetails() {
  58. let params = {
  59. id: this.id
  60. }
  61. this.$api.getGoodsDetails(params).then(res => {
  62. this.goods = res.data
  63. if (this.goods) {
  64. this.type = this.goods.goodsType.toString().split("、")
  65. }
  66. })
  67. },
  68. minus() {
  69. if (this.num == 1) {
  70. this.$$common.toast("已经到最小数量,无法在减少")
  71. return
  72. } else {
  73. this.num--
  74. }
  75. },
  76. add() {
  77. this.num++
  78. },
  79. addCar() {
  80. // this.show = true
  81. let user = uni.getStorageSync("info")
  82. let params = {
  83. buyUserId: user.id,
  84. enterpriseId: this.goods.merchantId,
  85. shopId: this.goods.shopId,
  86. tradeAreaId: this.goods.tradeAreaId,
  87. saleGoodsInfoId: this.goods.id,
  88. // buyUserType: user.userType,
  89. // buyType: parseInt(2),
  90. goodsImg: this.goods.goodsImg,
  91. goodsName: this.goods.goodsName,
  92. // buyNum: parseInt(this.num)
  93. }
  94. this.$api.addCar(params).then(res => {
  95. if(res.code == 200) {
  96. this.$common.toast(res.msg)
  97. }
  98. })
  99. }
  100. }
  101. }
  102. </script>
  103. <style lang="scss">
  104. page {
  105. padding: 0;
  106. }
  107. .pad {
  108. width: 100%;
  109. padding: 10rpx;
  110. display: flex;
  111. }
  112. .title {
  113. font-size: 42rpx;
  114. }
  115. .price {
  116. color: red;
  117. font-size: 40rpx;
  118. }
  119. // .flex-box {
  120. // }
  121. .tag {
  122. width: auto;
  123. margin-right: 10rpx;
  124. }
  125. .custom-style {
  126. width: 50%;
  127. height: 100rpx;
  128. font-size: 30rpx;
  129. }
  130. .des {
  131. border-top: 1rpx #888 solid;
  132. margin-bottom: 10rpx;
  133. }
  134. .num {
  135. width: 100%;
  136. padding: 10rpx;
  137. display: flex;
  138. align-items: center;
  139. justify-content: center;
  140. font-size: 40rpx;
  141. }
  142. .numBtn {
  143. width: 20%;
  144. margin: 20rpx;
  145. }
  146. .footer {
  147. width: 100%;
  148. display: flex;
  149. position: absolute;
  150. bottom: 1rpx;
  151. }
  152. </style>