goods-receive-buy-popup.vue 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211
  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"></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. <view class="amount">{{ productData.price | priceFormat }}</view>
  28. </view>
  29. <!-- 券后价 -->
  30. <view class="row" v-if="productData.couponStatus > 0">
  31. <view class="tag-qh">券后价¥{{ productData.couponPrice | priceFormat }}</view>
  32. </view>
  33. </view>
  34. </view>
  35. <view class="tip">
  36. <template v-if="productData.couponStatus > 1">
  37. 当前商品可使用
  38. <text v-text="currentCoupon.couponTitle"></text>
  39. 优惠券
  40. </template>
  41. </view>
  42. <tui-button type="base" width="600rpx" height="90rpx" shape="circle" @click="$emit('submit', count)">
  43. {{ navbarType === 'buy' ? (productData.couponStatus > 0 ? '领券购买' : '立即购买') : '加入购物车' }}
  44. </tui-button>
  45. </view>
  46. </uni-popup>
  47. </view>
  48. </template>
  49. <script>
  50. import { mapGetters } from 'vuex'
  51. export default {
  52. name: 'goods-receive-buy-pupup',
  53. props: {
  54. productData: {
  55. type: Object,
  56. default: () => null
  57. },
  58. currentCoupon: {
  59. type: Object,
  60. default: () => null
  61. },
  62. navbarType: {
  63. type: String,
  64. default: 'buy'
  65. }
  66. },
  67. data() {
  68. return {
  69. count: 1
  70. }
  71. },
  72. computed: {
  73. ...mapGetters(['safeArea'])
  74. },
  75. watch: {
  76. count() {
  77. console.log(this.count, typeof this.count)
  78. }
  79. },
  80. methods: {
  81. open() {
  82. this.$refs.popup.open()
  83. this.$emit('open')
  84. this.count = 1
  85. },
  86. close() {
  87. this.$refs.popup.close()
  88. this.$emit('close')
  89. this.count = 1
  90. }
  91. }
  92. }
  93. </script>
  94. <style>
  95. .vue-ref {
  96. border-radius: 16rpx 16rpx 0 0;
  97. overflow: hidden;
  98. }
  99. </style>
  100. <style lang="scss" scoped>
  101. .goods-receive-buy-pupup {
  102. position: relative;
  103. .close {
  104. position: absolute;
  105. right: 24rpx;
  106. top: 24rpx;
  107. color: #999;
  108. font-size: 32rpx;
  109. }
  110. .popup-content {
  111. @extend .cm-flex-center;
  112. flex-direction: column;
  113. padding: 40rpx 32rpx;
  114. background-color: #fff;
  115. border-radius: 16rpx 16rpx 0 0;
  116. &::after {
  117. position: absolute;
  118. content: '';
  119. width: 100%;
  120. height: 80rpx;
  121. bottom: -80rpx;
  122. left: 0;
  123. background-color: #fff;
  124. }
  125. .content {
  126. width: 100%;
  127. @extend .cm-flex-between;
  128. justify-content: flex-start;
  129. .cover {
  130. width: 180rpx;
  131. height: 180rpx;
  132. }
  133. .info {
  134. margin-left: 24rpx;
  135. .row {
  136. @extend .cm-flex-center;
  137. justify-content: flex-start;
  138. &:first-child {
  139. margin-bottom: 40rpx;
  140. }
  141. }
  142. .count {
  143. @extend .cm-flex-center;
  144. justify-content: flex-start;
  145. .number-box {
  146. margin: 0 24rpx;
  147. }
  148. }
  149. .label {
  150. font-size: 24rpx;
  151. color: #666666;
  152. &::after {
  153. content: ':';
  154. }
  155. }
  156. .clickable {
  157. font-size: 26rpx;
  158. color: #ff457b;
  159. }
  160. .amount {
  161. font-size: 26rpx;
  162. color: #ff457b;
  163. font-weight: bold;
  164. &::before {
  165. content: '¥';
  166. }
  167. }
  168. .tag-qh {
  169. display: inline-block;
  170. line-height: 40rpx;
  171. height: 40rpx;
  172. margin-top: 14rpx;
  173. background: #ff457b;
  174. border-radius: 25rpx;
  175. padding: 0 15rpx;
  176. font-size: 24rpx;
  177. font-weight: bold;
  178. color: #ffffff;
  179. }
  180. }
  181. }
  182. .tip {
  183. margin: 70rpx 0 24rpx;
  184. font-size: 24rpx;
  185. color: #666;
  186. text {
  187. color: #ff457b;
  188. }
  189. }
  190. }
  191. }
  192. </style>