goods-receive-buy-popup.vue 7.7 KB

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