cm-unit-popup.vue 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618
  1. <template name="cm-parameter">
  2. <!-- 相关规格 -->
  3. <tui-bottom-popup :radius="true" :show="popupShow" @close="hidePopup">
  4. <view class="tui-popup-box clearfix">
  5. <view class="tui-shopping-main" :style="{ paddingBottom: isIphoneX ? '68rpx' : '34rpx' }">
  6. <view class="tui-sku-title">
  7. <view class="tui-sku-image"> <image :src="product.image" mode=""></image> </view>
  8. <view class="tui-sku-price">
  9. <view class="sku-price-viw">
  10. <view class="sku-price-text"
  11. :class="PromotionsFormat(product.promotions) || product.svipProductFlag == 1 ? 'none' : ''"
  12. >
  13. ¥{{
  14. (PromotionsFormat(product.promotions) || product.svipProductFlag == 1
  15. ? product.originalPrice
  16. : product.price) | NumFormat
  17. }}
  18. </view>
  19. </view>
  20. <view class="sku-price-vip">
  21. <view class="floor-item-act">
  22. <view class="coupon-tags" v-if="product.couponsLogo">优惠券</view>
  23. <template v-if="product.actStatus == 1 && product.promotions">
  24. <view v-if="PromotionsFormat(product.promotions)" class="floor-tags">
  25. {{ product.promotions.name }}
  26. <text v-if="product.promotions != null && product.promotions.type != 3">
  27. :¥{{
  28. product.promotions == null
  29. ? '0.00'
  30. : product.promotions.touchPrice | NumFormat
  31. }}
  32. </text>
  33. </view>
  34. <view v-else-if="product.promotions.type != 3" class="floor-tags">
  35. {{ product.promotions.name }}
  36. </view>
  37. </template>
  38. <template v-if="product.actStatus == null && product.ladderFlag == 1">
  39. <view class="floor-tags">阶梯价格</view>
  40. </template>
  41. <template v-if="product.svipProductFlag == 1">
  42. <view class="svip-tags">
  43. <view class="tags" :class="{ none: vipFlag != 1 }">SVIP</view>
  44. <view class="price" v-if="isShowVipFlag(product)">{{
  45. product.svipPriceTag
  46. }}</view>
  47. </view>
  48. </template>
  49. </view>
  50. </view>
  51. </view>
  52. </view>
  53. <view class="tui-sku-unit">
  54. <view class="sku-unit-h1">规格:</view>
  55. <view class="sku-unit-li">
  56. <view
  57. class="unit-li"
  58. v-for="(sku, index) in skuList"
  59. @click="handleChoisSku(sku, index)"
  60. :key="index"
  61. :class="skuIndex === index ? 'active' : ''"
  62. >
  63. {{ sku.unit }} <text class="tips">缺货</text>
  64. </view>
  65. </view>
  66. </view>
  67. <view class="sku-unit-nunbox">
  68. <view class="sku-unit-nunbox" v-if="product.step === 2">
  69. <view class="text">*该商品只能以起订量的整数倍购买</view>
  70. </view>
  71. <view class="sku-unit-nunbox-t">
  72. <view class="sku-unit-nunbox-text">购买数量:</view>
  73. <view class="sku-unit-nunbox-num">
  74. <view class="number-box">
  75. <view
  76. class="iconfont icon-jianhao"
  77. @click="changeCountSub"
  78. ></view>
  79. <input
  80. class="btn-input"
  81. type="number"
  82. v-model="number"
  83. maxlength="4"
  84. @blur="changeNumber($event)"
  85. />
  86. <view
  87. class="iconfont icon-jiahao"
  88. @click="changeCountAdd"
  89. ></view>
  90. </view>
  91. </view>
  92. </view>
  93. </view>
  94. </view>
  95. <view class="tui-right-flex tui-popup-btn" :style="{ paddingBottom: isIphoneX ? '68rpx' : '34rpx' }">
  96. <view class="tui-modal-flex">
  97. <view class="tui-modal-button cancel" @click="handleConfirm">加入购物车</view>
  98. <view class="tui-modal-button confirm" @click="toConfirmation">立即购买</view>
  99. </view>
  100. </view>
  101. </view>
  102. </tui-bottom-popup>
  103. </template>
  104. <script>
  105. import { mapState, mapMutations } from 'vuex'
  106. import uniGrader from '@/components/uni-grade/uni-grade.vue'
  107. export default {
  108. name: 'cm-unit-popup',
  109. components: {
  110. uniGrader
  111. },
  112. props: {
  113. product: {
  114. type: Object
  115. },
  116. popupShow: {
  117. type: Boolean,
  118. default: false
  119. },
  120. type: {
  121. type: Number,
  122. default: 1
  123. }
  124. },
  125. data() {
  126. return {
  127. userId:0,// 用户Id
  128. vipFlag: 0, // 是否是超级会员 0否 1是
  129. skuIndex: 0,
  130. number: 0,
  131. buyRetailPriceStep: 1,
  132. buyRetailPrice: 0,
  133. ladderPriceList: [],
  134. isQuantity: false,
  135. skuList: [
  136. {
  137. unit: '135ml70ml', // 规格
  138. normalPrice: 1000, // 市场价
  139. price: 500, // 售价
  140. costPrice: 500, // 结算价
  141. stock: 100 // 库存
  142. },
  143. {
  144. unit: ' 精华70ml', // 规格
  145. normalPrice: 1000, // 市场价
  146. price: 500, // 售价
  147. costPrice: 500, // 结算价
  148. stock: 100 // 库存
  149. },
  150. {
  151. unit: '精华70ml', // 规格
  152. normalPrice: 1000, // 市场价
  153. price: 500, // 售价
  154. costPrice: 500, // 结算价
  155. stock: 100 // 库存
  156. },
  157. {
  158. unit: '【70ml】2瓶', // 规格
  159. normalPrice: 1000, // 市场价
  160. price: 500, // 售价
  161. costPrice: 500, // 结算价
  162. stock: 100 // 库存
  163. },
  164. {
  165. unit: '【50ml】3瓶', // 规格
  166. normalPrice: 1000, // 市场价
  167. price: 500, // 售价
  168. costPrice: 500, // 结算价
  169. stock: 100 // 库存
  170. },
  171. {
  172. unit: '【50ml】3瓶', // 规格
  173. normalPrice: 1000, // 市场价
  174. price: 500, // 售价
  175. costPrice: 500, // 结算价
  176. stock: 100 // 库存
  177. },
  178. {
  179. unit: '【50ml】3瓶', // 规格
  180. normalPrice: 1000, // 市场价
  181. price: 500, // 售价
  182. costPrice: 500, // 结算价
  183. stock: 100 // 库存
  184. },
  185. {
  186. unit: '【50ml】3瓶', // 规格
  187. normalPrice: 1000, // 市场价
  188. price: 500, // 售价
  189. costPrice: 500, // 结算价
  190. stock: 100 // 库存
  191. },
  192. {
  193. unit: '【50ml】3瓶', // 规格
  194. normalPrice: 1000, // 市场价
  195. price: 500, // 售价
  196. costPrice: 500, // 结算价
  197. stock: 100 // 库存
  198. },
  199. {
  200. unit: '【50ml】3瓶', // 规格
  201. normalPrice: 1000, // 市场价
  202. price: 500, // 售价
  203. costPrice: 500, // 结算价
  204. stock: 100 // 库存
  205. },
  206. {
  207. unit: '【50ml】3瓶', // 规格
  208. normalPrice: 1000, // 市场价
  209. price: 500, // 售价
  210. costPrice: 500, // 结算价
  211. stock: 100 // 库存
  212. },
  213. {
  214. unit: '【50ml】3瓶', // 规格
  215. normalPrice: 1000, // 市场价
  216. price: 500, // 售价
  217. costPrice: 500, // 结算价
  218. stock: 100 // 库存
  219. },
  220. {
  221. unit: '【50ml】3瓶', // 规格
  222. normalPrice: 1000, // 市场价
  223. price: 500, // 售价
  224. costPrice: 500, // 结算价
  225. stock: 100 // 库存
  226. },
  227. {
  228. unit: '【50ml】3瓶', // 规格
  229. normalPrice: 1000, // 市场价
  230. price: 500, // 售价
  231. costPrice: 500, // 结算价
  232. stock: 100 // 库存
  233. },
  234. {
  235. unit: '【50ml】3瓶', // 规格
  236. normalPrice: 1000, // 市场价
  237. price: 500, // 售价
  238. costPrice: 500, // 结算价
  239. stock: 100 // 库存
  240. },
  241. {
  242. unit: '【50ml】3瓶', // 规格
  243. normalPrice: 1000, // 市场价
  244. price: 500, // 售价
  245. costPrice: 500, // 结算价
  246. stock: 100 // 库存
  247. },
  248. {
  249. unit: '【50ml】3瓶', // 规格
  250. normalPrice: 1000, // 市场价
  251. price: 500, // 售价
  252. costPrice: 500, // 结算价
  253. stock: 100 // 库存
  254. },
  255. {
  256. unit: '【50ml】3瓶', // 规格
  257. normalPrice: 1000, // 市场价
  258. price: 500, // 售价
  259. costPrice: 500, // 结算价
  260. stock: 100 // 库存
  261. },
  262. {
  263. unit: '【50ml】3瓶', // 规格
  264. normalPrice: 1000, // 市场价
  265. price: 500, // 售价
  266. costPrice: 500, // 结算价
  267. stock: 100 // 库存
  268. },
  269. {
  270. unit: '【35ml】4瓶', // 规格
  271. normalPrice: 1000, // 市场价
  272. price: 500, // 售价
  273. costPrice: 500, // 结算价
  274. stock: 100 // 库存
  275. }
  276. ]
  277. }
  278. },
  279. filters: {
  280. NumFormat(value) {
  281. //处理金额
  282. return Number(value).toFixed(2)
  283. }
  284. },
  285. created() {
  286. this.initData()
  287. },
  288. computed: {
  289. ...mapState(['hasLogin'])
  290. },
  291. methods: {
  292. async initData(data) {
  293. const userInfo = await this.$api.getStorage()
  294. this.vipFlag = userInfo.vipFlag ? userInfo.vipFlag : 0
  295. this.userId = userInfo.userId ? userInfo.userId : 0
  296. this.number = this.product.minBuyNumber
  297. this.buyRetailPrice = this.product.price
  298. this.ladderPriceList = this.product.ladderPriceList ? this.product.ladderPriceList : null
  299. this.buyRetailPriceStep = this.handleData.step
  300. if (this.handleData.ladderPriceFlag == 1) {
  301. this.number = this.handleData.maxBuyNumber ? this.handleData.maxBuyNumber : 1
  302. } else {
  303. this.number = this.handleData.minBuyNumber
  304. }
  305. },
  306. PromotionsFormat(promo) {
  307. //促销活动类型数据处理
  308. if (promo != null) {
  309. if (promo.type == 1 && promo.mode == 1) {
  310. return true
  311. } else {
  312. return false
  313. }
  314. }
  315. return false
  316. },
  317. isShowVipFlag(pros) {
  318. // 未登录 || 非会员
  319. if (!this.hasLogin || !this.vipFlag === 1) return false
  320. // 商品所有机构可见
  321. if (pros.priceFlag === 0) return true
  322. // 商品价格仅资质机构可见
  323. if (pros.priceFlag === 2 && this.userIdentity === 2) return true
  324. // 商品价格仅医美机构可见
  325. if (pros.priceFlag === 3 && this.userIdentity === 2 && this.firstClubType == 1) return true
  326. // 其它
  327. return false
  328. },
  329. changeCountAdd() {
  330. //popup弹窗数量增加按钮
  331. if (this.buyRetailPriceStep == 2) {
  332. this.number += this.product.minBuyNumber
  333. } else {
  334. this.number++
  335. }
  336. this.calculatPerice()
  337. },
  338. changeCountSub() {
  339. //popup弹窗数量减按钮
  340. if (this.number <= this.product.minBuyNumber) {
  341. this.number = this.product.minBuyNumber
  342. this.isQuantity = true
  343. this.$util.msg(`该商品最小起订量为${this.product.minBuyNumber}`, 2000)
  344. return
  345. } else {
  346. if (this.buyRetailPriceStep == 2) {
  347. this.number -= this.product.minBuyNumber
  348. } else {
  349. this.number--
  350. }
  351. this.calculatPerice()
  352. this.isQuantity = false
  353. }
  354. },
  355. changeNumber(e) {
  356. let _value = e.detail.value
  357. if (!this.$api.isNumber(_value)) {
  358. this.number = this.product.minBuyNumber
  359. } else if (_value < this.product.minBuyNumber) {
  360. this.$util.msg(`该商品最小起订量为${this.product.minBuyNumber}`, 2000)
  361. this.number = this.product.minBuyNumber
  362. } else if (_value % this.product.minBuyNumber != 0) {
  363. this.$util.msg('购买量必须为起订量的整数倍', 2000)
  364. this.number = this.product.minBuyNumber
  365. } else {
  366. this.number = e.detail.value
  367. this.calculatPerice()
  368. }
  369. },
  370. calculatPerice() {
  371. //判断是否为阶梯价然后做计算价格处理
  372. if (this.product.ladderPriceFlag == 1) {
  373. this.product.ladderPrices.forEach((item, index) => {
  374. if (this.number >= item.buyNum) {
  375. this.buyRetailPrice = item.buyPrice
  376. }
  377. })
  378. }
  379. },
  380. toConfirmation() {
  381. //跳转确认订单页面
  382. this.$parent.popupShow1 = false
  383. let productStp = {
  384. productIds: this.product.productId,
  385. productCount: this.number
  386. }
  387. console.log('productStp',productStp)
  388. this.$api.navigateTo(
  389. `/pages/user/order/create-order?type=1&data=${JSON.stringify({ data: productStp })}`
  390. )
  391. },
  392. handleConfirm() {
  393. //增加购物车成功和toast弹窗提示成功
  394. this.ProductService.shoppingAddCart({
  395. productId: this.product.productId,
  396. userId: this.userId,
  397. productCount: this.number
  398. })
  399. .then(response => {
  400. this.$parent.popupShow1 = false
  401. this.$util.msg('加入购物车成功', 1500, true, 'success')
  402. this.$parent.ProductCartNumber()
  403. })
  404. .catch(error => {
  405. this.$util.msg(error.msg, 2000)
  406. })
  407. },
  408. handleChoisSku(sku, index) {
  409. // 选择SKU
  410. this.skuIndex = index
  411. },
  412. hidePopup() {
  413. this.$parent.popupShow1 = false
  414. }
  415. }
  416. }
  417. </script>
  418. <style lang="scss">
  419. .tui-popup-box {
  420. padding: 40rpx 24rpx 0 24rpx;
  421. }
  422. .tui-shopping-main {
  423. width: 100%;
  424. .tui-sku-title {
  425. width: 100%;
  426. height: 136rpx;
  427. float: left;
  428. margin-bottom: 30rpx;
  429. .tui-sku-image {
  430. width: 138rpx;
  431. height: 138rpx;
  432. float: left;
  433. border-radius: 8rpx;
  434. margin-right: 30rpx;
  435. box-sizing: border-box;
  436. border: 1px dashed #e1e1e1;
  437. image {
  438. width: 134rpx;
  439. height: 134rpx;
  440. border-radius: 10rpx;
  441. }
  442. }
  443. .tui-sku-price {
  444. height: 136rpx;
  445. float: left;
  446. .sku-price-viw {
  447. width: 100%;
  448. height: 40rpx;
  449. margin-bottom: 24rpx;
  450. .sku-price-text {
  451. font-size: 28rpx;
  452. line-height: 40rpx;
  453. color: #f94b4b;
  454. font-weight: bold;
  455. .sku-price-l{
  456. float: left;
  457. font-weight: normal;
  458. }
  459. &.none {
  460. text-decoration: line-through;
  461. color: #999999;
  462. font-weight: normal;
  463. }
  464. }
  465. }
  466. .sku-price-vip {
  467. width: 100%;
  468. height: 40rpx;
  469. }
  470. }
  471. }
  472. .tui-sku-unit {
  473. width: 100%;
  474. height: auto;
  475. float: left;
  476. .sku-unit-h1 {
  477. font-size: 28rpx;
  478. line-height: 40rpx;
  479. color: #333333;
  480. font-weight: bold;
  481. }
  482. .sku-unit-li {
  483. width: 100%;
  484. height: auto;
  485. .unit-li {
  486. padding: 0 24rpx;
  487. line-height: 48rpx;
  488. text-align: center;
  489. font-size: 24rpx;
  490. color: #666666;
  491. background: #f5f5f5;
  492. float: left;
  493. margin-right: 16rpx;
  494. margin-top: 12rpx;
  495. margin-bottom: 12rpx;
  496. border-radius: 24rpx;
  497. position: relative;
  498. box-sizing: border-box;
  499. border: 1px solid #f5f5f5;
  500. &.active {
  501. border-color: $color-system;
  502. background: #fff1eb;
  503. color: $color-system;
  504. .tips {
  505. background: #e15616;
  506. }
  507. }
  508. .tips {
  509. padding: 0 10rpx;
  510. line-height: 32rpx;
  511. text-align: center;
  512. font-size: 22rpx;
  513. color: #ffffff;
  514. background: #cccccc;
  515. float: left;
  516. border-radius: 16rpx;
  517. position: absolute;
  518. right: -12rpx;
  519. top: -15rpx;
  520. }
  521. }
  522. }
  523. }
  524. .sku-unit-nunbox {
  525. justify-content: space-between;
  526. align-items: center;
  527. width: 100%;
  528. height: auto;
  529. float: left;
  530. margin-top: 30rpx;
  531. .sku-unit-nunbox-t {
  532. width: 100%;
  533. height: 44rpx;
  534. position: relative;
  535. margin-bottom: 20rpx;
  536. .text {
  537. font-size: $font-size-24;
  538. line-height: 48rpx;
  539. color: #999999;
  540. }
  541. .sku-unit-nunbox-text {
  542. line-height: 44rpx;
  543. font-size: $font-size-28;
  544. float: left;
  545. font-weight: bold;
  546. }
  547. .sku-unit-nunbox-num{
  548. float: right;
  549. .number-box {
  550. display: flex;
  551. justify-content: center;
  552. align-items: center;
  553. border: 2rpx solid #ffe6dc;
  554. border-radius: 30rpx;
  555. height: 48rpx;
  556. margin-left: 20rpx;
  557. .iconfont {
  558. font-size: $font-size-24;
  559. padding: 0 18rpx;
  560. color: #999999;
  561. text-align: center;
  562. line-height: 48rpx;
  563. font-weight: bold;
  564. background: #fef6f3;
  565. &.icon-jianhao {
  566. border-radius: 30rpx 0 0 30rpx;
  567. }
  568. &.icon-jiahao {
  569. border-radius: 0 30rpx 30rpx 0;
  570. }
  571. }
  572. .btn-input {
  573. width: 62rpx;
  574. height: 48rpx;
  575. line-height: 48rpx;
  576. background: #ffffff;
  577. border-radius: 4rpx;
  578. text-align: center;
  579. font-size: $font-size-28;
  580. }
  581. }
  582. }
  583. }
  584. }
  585. }
  586. .tui-popup-btn{
  587. width: 100%;
  588. float: left;
  589. .tui-modal-flex {
  590. width: 100%;
  591. height: 84rpx;
  592. margin-top: 40rpx;
  593. display: flex;
  594. .tui-modal-button {
  595. flex: 1;
  596. line-height: 84rpx;
  597. font-size: $font-size-28;
  598. text-align: center;
  599. border-radius: 42rpx;
  600. padding: 0;
  601. margin: 0 15rpx;
  602. box-sizing: border-box;
  603. &.cancel {
  604. background: #ffe6dc;
  605. color: #e15616;
  606. }
  607. &.confirm {
  608. background: $btn-confirm;
  609. color: #ffffff;
  610. }
  611. }
  612. }
  613. }
  614. </style>