cm-unit-suppor-popup.vue 7.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338
  1. <template name="cm-parameter">
  2. <!-- 相关规格 -->
  3. <view>
  4. <tui-bottom-popup :radius="true" :show="popupShow" @close="hidePopup">
  5. <view class="tui-popup-box clearfix">
  6. <view class="tui-shopping-main" :style="{ paddingBottom: isIphoneX ? '68rpx' : '34rpx' }">
  7. <view class="tui-sku-title">
  8. <view class="tui-sku-image"> <image :src="skuProduct.image" mode=""></image> </view>
  9. <view class="tui-sku-price">
  10. <view class="sku-price-viw">
  11. <view
  12. class="sku-price-text"
  13. :class="
  14. PromotionsFormat(skuProduct.promotions) || skuProduct.svipProductFlag == 1
  15. ? 'none'
  16. : ''
  17. "
  18. >
  19. ¥{{
  20. (PromotionsFormat(skuProduct.promotions) || skuProduct.svipProductFlag == 1
  21. ? skuProduct.originalPrice
  22. : skuProduct.price) | NumFormat
  23. }}
  24. </view>
  25. </view>
  26. <view class="sku-price-vip">
  27. <view class="floor-item-act">
  28. <view class="coupon-tags" v-if="skuProduct.couponsLogo">优惠券</view>
  29. <template v-if="skuProduct.actStatus == 1 && skuProduct.promotions">
  30. <view v-if="PromotionsFormat(skuProduct.promotions)" class="floor-tags">
  31. {{ skuProduct.promotions.name }}
  32. <text
  33. v-if="skuProduct.promotions != null && skuProduct.promotions.type != 3"
  34. >
  35. :¥{{
  36. skuProduct.promotions == null
  37. ? '0.00'
  38. : skuProduct.promotions.touchPrice | NumFormat
  39. }}
  40. </text>
  41. </view>
  42. <view v-else-if="skuProduct.promotions.type != 3" class="floor-tags">
  43. {{ skuProduct.promotions.name }}
  44. </view>
  45. </template>
  46. <template v-if="skuProduct.actStatus == null && skuProduct.ladderFlag == 1">
  47. <view class="floor-tags">阶梯价格</view>
  48. </template>
  49. <template v-if="skuProduct.svipProductFlag == 1">
  50. <view class="svip-tags">
  51. <view class="tags">SVIP</view>
  52. <view class="price">{{ skuProduct.svipPriceTag }}</view>
  53. </view>
  54. </template>
  55. </view>
  56. </view>
  57. </view>
  58. </view>
  59. <view class="tui-sku-unit">
  60. <view class="sku-unit-h1">规格:</view>
  61. <view class="sku-unit-li">
  62. <view
  63. class="unit-li"
  64. v-for="(sku, index) in skuList"
  65. @click="handleChoisSku(sku, index)"
  66. :key="index"
  67. :class="skuIndex === index ? 'active' : ''"
  68. >
  69. {{ sku.unit }} <text class="tips" v-if="sku.stock === 0">缺货</text>
  70. </view>
  71. </view>
  72. </view>
  73. <view class="sku-unit-ladel" v-if="isShowLadder" @click.stop="showLaddePopup">
  74. 此规格商品存在阶梯价格,点击查看 >>>
  75. </view>
  76. </view>
  77. <view class="tui-right-flex tui-popup-btn" :style="{ paddingBottom: isIphoneX ? '68rpx' : '34rpx' }">
  78. <view class="tui-modal-flex">
  79. <button
  80. class="tui-modal-button confirm"
  81. :class="[isBtnDisabled ? 'disabled' : '']"
  82. @click="handleConfirm"
  83. >
  84. 确定
  85. </button>
  86. </view>
  87. </view>
  88. </view>
  89. </tui-bottom-popup>
  90. <!-- 阶梯价弹窗 -->
  91. <cmLadderPopup v-if="laddePopupShow" :show="laddePopupShow" :list="ladderPriceList"></cmLadderPopup>
  92. </view>
  93. </template>
  94. <script>
  95. import { mapState, mapMutations } from 'vuex'
  96. import cmLadderPopup from '@/components/cm-module/productDetails/cm-ladder-popup.vue'
  97. export default {
  98. name: 'cm-unit-popup',
  99. components: {
  100. cmLadderPopup
  101. },
  102. props: {
  103. skuProduct: {
  104. type: Object
  105. },
  106. popupShow: {
  107. type: Boolean,
  108. default: false
  109. },
  110. type: {
  111. type: Number,
  112. default: 1
  113. }
  114. },
  115. data() {
  116. return {
  117. laddePopupShow: false,
  118. isShowLadder: false,
  119. skuIndex: 0,
  120. ladderPriceList: [],
  121. skuList: [],
  122. isBtnDisabled:false,
  123. handleUnit:'',
  124. handleSkuId:0,
  125. handleMinNumber:1
  126. }
  127. },
  128. filters: {
  129. NumFormat(value) {
  130. //处理金额
  131. return Number(value).toFixed(2)
  132. }
  133. },
  134. created() {
  135. this.initData()
  136. },
  137. computed: {
  138. ...mapState(['hasLogin'])
  139. },
  140. methods: {
  141. initData() {
  142. console.log('skuProduct',this.skuProduct)
  143. this.skuList = this.skuProduct.skus
  144. this.handleUnit = this.skuList[0].unit
  145. this.handleSkuId = this.skuList[0].skuId
  146. this.handleMinNumber = this.skuList[0].minBuyNumber
  147. this.isBtnDisabled = this.skuList[0].stock === 0
  148. if (this.skuList[0].ladderPriceList) {
  149. this.isShowLadder = true
  150. }
  151. },
  152. PromotionsFormat(promo) {
  153. //促销活动类型数据处理
  154. if (promo != null) {
  155. if (promo.type == 1 && promo.mode == 1) {
  156. return true
  157. } else {
  158. return false
  159. }
  160. }
  161. return false
  162. },
  163. handleConfirm() {
  164. const data = { unit: this.handleUnit,skuId : this.handleSkuId,minBuyNumber:this.handleMinNumber}
  165. this.$emit('handleUnitConfirm', data)
  166. this.$parent.popupShow = false
  167. },
  168. handleChoisSku(sku, index) {
  169. // 选择SKU
  170. this.skuIndex = index
  171. this.handleUnit = sku.unit
  172. this.handleSkuId = sku.skuId
  173. this.ladderPriceList = sku.ladderPriceList
  174. this.isShowLadder = sku.ladderPriceList ? true : false
  175. this.isBtnDisabled = sku.stock === 0
  176. this.$emit('skuClick', sku)
  177. },
  178. showLaddePopup() {
  179. // 点击显示阶梯价
  180. this.laddePopupShow = true
  181. },
  182. hidePopup() {
  183. //隐藏
  184. this.$parent.popupShow = false
  185. }
  186. }
  187. }
  188. </script>
  189. <style lang="scss">
  190. .tui-popup-box {
  191. padding: 40rpx 24rpx 0 24rpx;
  192. }
  193. .tui-shopping-main {
  194. width: 100%;
  195. .tui-sku-title {
  196. width: 100%;
  197. height: 136rpx;
  198. float: left;
  199. margin-bottom: 30rpx;
  200. .tui-sku-image {
  201. width: 138rpx;
  202. height: 138rpx;
  203. float: left;
  204. border-radius: 8rpx;
  205. margin-right: 30rpx;
  206. box-sizing: border-box;
  207. border: 1px dashed #e1e1e1;
  208. image {
  209. width: 134rpx;
  210. height: 134rpx;
  211. border-radius: 10rpx;
  212. }
  213. }
  214. .tui-sku-price {
  215. height: 136rpx;
  216. float: left;
  217. .sku-price-viw {
  218. width: 100%;
  219. height: 40rpx;
  220. margin-bottom: 24rpx;
  221. .sku-price-text {
  222. font-size: 28rpx;
  223. line-height: 40rpx;
  224. color: #f94b4b;
  225. font-weight: bold;
  226. .sku-price-l {
  227. float: left;
  228. font-weight: normal;
  229. }
  230. &.none {
  231. text-decoration: line-through;
  232. color: #999999;
  233. font-weight: normal;
  234. }
  235. }
  236. }
  237. .sku-price-vip {
  238. width: 100%;
  239. height: 40rpx;
  240. }
  241. }
  242. }
  243. .tui-sku-unit {
  244. width: 100%;
  245. height: auto;
  246. float: left;
  247. padding-bottom: 30rpx;
  248. .sku-unit-h1 {
  249. font-size: 28rpx;
  250. line-height: 40rpx;
  251. color: #333333;
  252. font-weight: bold;
  253. }
  254. .sku-unit-li {
  255. width: 100%;
  256. height: auto;
  257. .unit-li {
  258. padding: 0 24rpx;
  259. line-height: 48rpx;
  260. text-align: center;
  261. font-size: 24rpx;
  262. color: #666666;
  263. background: #f5f5f5;
  264. float: left;
  265. margin-right: 16rpx;
  266. margin-top: 12rpx;
  267. margin-bottom: 12rpx;
  268. border-radius: 24rpx;
  269. position: relative;
  270. box-sizing: border-box;
  271. border: 1px solid #f5f5f5;
  272. &.active {
  273. border-color: $color-system;
  274. background: #fff1eb;
  275. color: $color-system;
  276. .tips {
  277. background: #e15616;
  278. }
  279. }
  280. .tips {
  281. padding: 0 10rpx;
  282. line-height: 32rpx;
  283. text-align: center;
  284. font-size: 22rpx;
  285. color: #ffffff;
  286. background: #cccccc;
  287. float: left;
  288. border-radius: 16rpx;
  289. position: absolute;
  290. right: -12rpx;
  291. top: -15rpx;
  292. }
  293. }
  294. }
  295. }
  296. .sku-unit-ladel {
  297. width: 100%;
  298. height: 64rpx;
  299. line-height: 64rpx;
  300. float: left;
  301. margin-top: 20rpx;
  302. text-align: center;
  303. font-size: 24rpx;
  304. background: #fffaf8;
  305. color: #e15616;
  306. margin-bottom: 30rpx;
  307. }
  308. }
  309. .tui-modal-flex {
  310. width: 100%;
  311. height: 84rpx;
  312. margin-top: 40rpx;
  313. display: flex;
  314. .tui-modal-button {
  315. flex: 1;
  316. line-height: 84rpx;
  317. font-size: $font-size-28;
  318. text-align: center;
  319. border-radius: 42rpx;
  320. padding: 0;
  321. margin: 0 15rpx;
  322. box-sizing: border-box;
  323. &.cancel {
  324. background: #ffe6dc;
  325. color: #e15616;
  326. }
  327. &.confirm {
  328. background: $btn-confirm;
  329. color: #ffffff;
  330. &.disabled {
  331. background: linear-gradient(135deg, rgba(242, 143, 49, 0.5) 0%, rgba(225, 86, 22, 0.5) 100%);
  332. }
  333. }
  334. }
  335. }
  336. </style>