goods-receive-buy-popup.vue 7.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260
  1. <template>
  2. <view class="goods-receive-buy-pupup" v-if="productData">
  3. <uni-popup ref="popup" type="bottom">
  4. <view class="close iconfont icon-iconfontguanbi" @click="close"></view>
  5. <view class="popup-content" :style="{ paddingBottom: safeArea ? 0 : '40rpx' }">
  6. <view class="content">
  7. <!-- 商品图片 -->
  8. <image :src="productData.mainImage" class="cover"></image>
  9. <view class="info">
  10. <!-- 数量 -->
  11. <view class="row">
  12. <view class="count">
  13. <view class="label">数量</view>
  14. <cm-number-box
  15. class="number-box"
  16. v-model.lazy="count"
  17. :max="limitedNum"
  18. ></cm-number-box>
  19. </view>
  20. <view
  21. class="clickable"
  22. @click="$emit('detail')"
  23. v-if="productData.activeStatus > 0 && productData.ladderList.length > 0"
  24. >
  25. 查看活动价
  26. </view>
  27. </view>
  28. <!-- 单价 -->
  29. <view class="row">
  30. <view class="label">单价</view>
  31. <!-- 拼团价 -->
  32. <template v-if="productData.activityType === 'group'">
  33. <view class="amount" v-if="groupBuyFlag">{{ productPrice | priceFormat }}</view>
  34. <view class="amount" v-else>{{ productData.normalPrice | priceFormat }}</view>
  35. </template>
  36. <!-- 其它价格 -->
  37. <template v-else>
  38. <view class="amount">{{ productPrice | priceFormat }}</view>
  39. </template>
  40. </view>
  41. <!-- 券后价 -->
  42. <view class="row" v-if="productData.couponStatus === 1 && productData.couponId">
  43. <view class="tag-qh">券后价¥{{ productData.couponPrice | priceFormat }}</view>
  44. </view>
  45. </view>
  46. </view>
  47. <view class="tip">
  48. <template v-if="productData.couponStatus > 0 && productData.couponId">
  49. 当前商品可使用
  50. <text v-text="couponTip"></text>
  51. 优惠券
  52. </template>
  53. </view>
  54. <tui-button type="base" width="600rpx" height="90rpx" shape="circle" @click="$emit('submit', count)">
  55. <template v-if="navbarType === 'buy'">
  56. <text v-if="productData.couponStatus === 1 && productData.couponId">领券购买</text>
  57. <text v-else>立即购买</text>
  58. </template>
  59. <template v-else>
  60. 确认
  61. </template>
  62. </tui-button>
  63. </view>
  64. </uni-popup>
  65. </view>
  66. </template>
  67. <script>
  68. import { mapGetters } from 'vuex'
  69. export default {
  70. name: 'goods-receive-buy-pupup',
  71. props: {
  72. productData: {
  73. type: Object,
  74. default: () => null
  75. },
  76. currentCoupon: {
  77. type: Object,
  78. default: () => null
  79. },
  80. couponTip: {
  81. type: String,
  82. default: ''
  83. },
  84. navbarType: {
  85. type: String,
  86. default: 'buy'
  87. },
  88. groupBuyFlag: {
  89. type: Boolean,
  90. default: true
  91. }
  92. },
  93. data() {
  94. return {
  95. count: 1
  96. }
  97. },
  98. computed: {
  99. ...mapGetters(['safeArea']),
  100. productPrice() {
  101. return this.generatePrice()
  102. },
  103. limitedNum() {
  104. if (this.productData.collageStatus > 0) {
  105. return this.productData.collageProduct.limitedNum || this.productData.stock
  106. }
  107. return this.productData.stock
  108. }
  109. },
  110. methods: {
  111. onNumberChange(num) {
  112. this.count = num
  113. },
  114. open() {
  115. this.$refs.popup.open()
  116. this.$emit('open')
  117. this.count = 1
  118. },
  119. close() {
  120. this.$refs.popup.close()
  121. this.$emit('close')
  122. this.count = 1
  123. },
  124. generatePrice() {
  125. // 非阶梯价
  126. if (this.productData.activeStatus <= 0) {
  127. return this.productData.price
  128. }
  129. // 阶梯价列表为空
  130. if (!this.productData.ladderList) {
  131. return this.productData.price
  132. }
  133. // 阶梯价
  134. const lastItem = this.productData.ladderList
  135. .sort((a, b) => b.buyNum - a.buyNum)
  136. .find(item => this.count >= item.buyNum)
  137. return lastItem ? lastItem.buyPrice : this.productData.price
  138. }
  139. }
  140. }
  141. </script>
  142. <style>
  143. .vue-ref {
  144. border-radius: 16rpx 16rpx 0 0;
  145. overflow: hidden;
  146. }
  147. </style>
  148. <style lang="scss" scoped>
  149. .goods-receive-buy-pupup {
  150. position: relative;
  151. .close {
  152. position: absolute;
  153. right: 24rpx;
  154. top: 24rpx;
  155. color: #999;
  156. font-size: 32rpx;
  157. }
  158. .popup-content {
  159. @extend .cm-flex-center;
  160. flex-direction: column;
  161. padding: 40rpx 32rpx;
  162. background-color: #fff;
  163. border-radius: 16rpx 16rpx 0 0;
  164. &::after {
  165. position: absolute;
  166. content: '';
  167. width: 100%;
  168. height: 80rpx;
  169. bottom: -80rpx;
  170. left: 0;
  171. background-color: #fff;
  172. }
  173. .content {
  174. width: 100%;
  175. @extend .cm-flex-between;
  176. justify-content: flex-start;
  177. .cover {
  178. width: 180rpx;
  179. height: 180rpx;
  180. }
  181. .info {
  182. margin-left: 24rpx;
  183. .row {
  184. @extend .cm-flex-center;
  185. justify-content: flex-start;
  186. &:first-child {
  187. margin-bottom: 40rpx;
  188. }
  189. }
  190. .count {
  191. @extend .cm-flex-center;
  192. justify-content: flex-start;
  193. .number-box {
  194. margin: 0 24rpx;
  195. }
  196. }
  197. .label {
  198. font-size: 24rpx;
  199. color: #666666;
  200. &::after {
  201. content: ':';
  202. }
  203. }
  204. .clickable {
  205. font-size: 26rpx;
  206. color: #ff457b;
  207. }
  208. .amount {
  209. font-size: 26rpx;
  210. color: #ff457b;
  211. font-weight: bold;
  212. &::before {
  213. content: '¥';
  214. }
  215. }
  216. .tag-qh {
  217. display: inline-block;
  218. line-height: 40rpx;
  219. height: 40rpx;
  220. margin-top: 14rpx;
  221. background: #ff457b;
  222. border-radius: 25rpx;
  223. padding: 0 15rpx;
  224. font-size: 24rpx;
  225. font-weight: bold;
  226. color: #ffffff;
  227. }
  228. }
  229. }
  230. .tip {
  231. margin: 70rpx 0 24rpx;
  232. font-size: 24rpx;
  233. color: #666;
  234. text {
  235. color: #ff457b;
  236. }
  237. }
  238. }
  239. }
  240. </style>