cm-unit-popup.vue 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552
  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="product.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="hidePopup">取消</view>
  98. <view class="tui-modal-button confirm" @click="handleConfirm">确定</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. isBtnDisabled:false,
  128. vipFlag: 0, // 是否是超级会员 0否 1是
  129. skuIndex: 0,
  130. number: 0,
  131. buyRetailPrice: 0,
  132. ladderPriceList: [],
  133. isQuantity: false,
  134. skuList: [
  135. {
  136. unit: '135ml70ml', // 规格
  137. normalPrice: 1000, // 市场价
  138. price: 500, // 售价
  139. costPrice: 500, // 结算价
  140. stock: 100 // 库存
  141. },
  142. {
  143. unit: ' 精华70ml', // 规格
  144. normalPrice: 1000, // 市场价
  145. price: 500, // 售价
  146. costPrice: 500, // 结算价
  147. stock: 100 // 库存
  148. },
  149. {
  150. unit: '精华70ml', // 规格
  151. normalPrice: 1000, // 市场价
  152. price: 500, // 售价
  153. costPrice: 500, // 结算价
  154. stock: 100 // 库存
  155. },
  156. {
  157. unit: '【70ml】2瓶', // 规格
  158. normalPrice: 1000, // 市场价
  159. price: 500, // 售价
  160. costPrice: 500, // 结算价
  161. stock: 100 // 库存
  162. },
  163. {
  164. unit: '【50ml】3瓶', // 规格
  165. normalPrice: 1000, // 市场价
  166. price: 500, // 售价
  167. costPrice: 500, // 结算价
  168. stock: 100 // 库存
  169. },
  170. {
  171. unit: '【50ml】3瓶', // 规格
  172. normalPrice: 1000, // 市场价
  173. price: 500, // 售价
  174. costPrice: 500, // 结算价
  175. stock: 100 // 库存
  176. },
  177. {
  178. unit: '【50ml】3瓶', // 规格
  179. normalPrice: 1000, // 市场价
  180. price: 500, // 售价
  181. costPrice: 500, // 结算价
  182. stock: 100 // 库存
  183. },
  184. {
  185. unit: '【50ml】3瓶', // 规格
  186. normalPrice: 1000, // 市场价
  187. price: 500, // 售价
  188. costPrice: 500, // 结算价
  189. stock: 100 // 库存
  190. },
  191. {
  192. unit: '【50ml】3瓶', // 规格
  193. normalPrice: 1000, // 市场价
  194. price: 500, // 售价
  195. costPrice: 500, // 结算价
  196. stock: 100 // 库存
  197. },
  198. {
  199. unit: '【50ml】3瓶', // 规格
  200. normalPrice: 1000, // 市场价
  201. price: 500, // 售价
  202. costPrice: 500, // 结算价
  203. stock: 100 // 库存
  204. },
  205. {
  206. unit: '【50ml】3瓶', // 规格
  207. normalPrice: 1000, // 市场价
  208. price: 500, // 售价
  209. costPrice: 500, // 结算价
  210. stock: 100 // 库存
  211. },
  212. {
  213. unit: '【50ml】3瓶', // 规格
  214. normalPrice: 1000, // 市场价
  215. price: 500, // 售价
  216. costPrice: 500, // 结算价
  217. stock: 100 // 库存
  218. },
  219. {
  220. unit: '【50ml】3瓶', // 规格
  221. normalPrice: 1000, // 市场价
  222. price: 500, // 售价
  223. costPrice: 500, // 结算价
  224. stock: 100 // 库存
  225. },
  226. {
  227. unit: '【50ml】3瓶', // 规格
  228. normalPrice: 1000, // 市场价
  229. price: 500, // 售价
  230. costPrice: 500, // 结算价
  231. stock: 100 // 库存
  232. },
  233. {
  234. unit: '【50ml】3瓶', // 规格
  235. normalPrice: 1000, // 市场价
  236. price: 500, // 售价
  237. costPrice: 500, // 结算价
  238. stock: 100 // 库存
  239. },
  240. {
  241. unit: '【50ml】3瓶', // 规格
  242. normalPrice: 1000, // 市场价
  243. price: 500, // 售价
  244. costPrice: 500, // 结算价
  245. stock: 100 // 库存
  246. },
  247. {
  248. unit: '【50ml】3瓶', // 规格
  249. normalPrice: 1000, // 市场价
  250. price: 500, // 售价
  251. costPrice: 500, // 结算价
  252. stock: 100 // 库存
  253. },
  254. {
  255. unit: '【50ml】3瓶', // 规格
  256. normalPrice: 1000, // 市场价
  257. price: 500, // 售价
  258. costPrice: 500, // 结算价
  259. stock: 100 // 库存
  260. },
  261. {
  262. unit: '【50ml】3瓶', // 规格
  263. normalPrice: 1000, // 市场价
  264. price: 500, // 售价
  265. costPrice: 500, // 结算价
  266. stock: 100 // 库存
  267. },
  268. {
  269. unit: '【35ml】4瓶', // 规格
  270. normalPrice: 1000, // 市场价
  271. price: 500, // 售价
  272. costPrice: 500, // 结算价
  273. stock: 100 // 库存
  274. }
  275. ]
  276. }
  277. },
  278. filters: {
  279. NumFormat(value) {
  280. //处理金额
  281. return Number(value).toFixed(2)
  282. }
  283. },
  284. created() {
  285. this.number = this.product.minBuyNumber
  286. this.buyRetailPrice = this.product.price
  287. this.ladderPriceList = this.product.ladderPriceList ? this.product.ladderPriceList : null
  288. this.initData()
  289. },
  290. computed: {
  291. ...mapState(['hasLogin'])
  292. },
  293. methods: {
  294. async initData(data) {
  295. const userInfo = await this.$api.getStorage()
  296. this.vipFlag = userInfo.vipFlag ? userInfo.vipFlag : 0
  297. this.userIdentity = userInfo.userIdentity ? userInfo.userIdentity : 0
  298. //处理禁用按钮商品
  299. this.isBtnDisabled = this.isDisabledFlag(this.product)
  300. },
  301. isDisabledFlag(pros){
  302. // 非会员
  303. if (!this.vipFlag === 1) return true
  304. // 商品已下架 || 库存为0
  305. if (pros.validFlag == 3 || pros.stock == 0) return true
  306. // 商品价格不公开
  307. if (pros.priceFlag === 1) return true
  308. // 商品价格仅资质机构可见 && 机构为普通机构
  309. if (pros.priceFlag === 2 && this.userIdentity === 4 ) return true
  310. // 商品价格仅医美机构可见 && 机构为普通机构
  311. if (pros.priceFlag === 3 && this.userIdentity === 4 ) return true
  312. // 商品价格仅医美机构可见 && 机构为资质机构 && 不是医美机构
  313. if (pros.priceFlag === 3 && this.userIdentity === 2 && this.firstClubType != 1) return true
  314. //其他
  315. return false
  316. },
  317. PromotionsFormat(promo) {
  318. //促销活动类型数据处理
  319. if (promo != null) {
  320. if (promo.type == 1 && promo.mode == 1) {
  321. return true
  322. } else {
  323. return false
  324. }
  325. }
  326. return false
  327. },
  328. isShowVipFlag(pros) {
  329. // 未登录 || 非会员
  330. if (!this.hasLogin || !this.vipFlag === 1) return false
  331. // 商品所有机构可见
  332. if (pros.priceFlag === 0) return true
  333. // 商品价格仅资质机构可见
  334. if (pros.priceFlag === 2 && this.userIdentity === 2) return true
  335. // 商品价格仅医美机构可见
  336. if (pros.priceFlag === 3 && this.userIdentity === 2 && this.firstClubType == 1) return true
  337. // 其它
  338. return false
  339. },
  340. handleConfirm() {
  341. this.$emit('buyConfirm', data)
  342. this.$parent.popupShow2 = false
  343. },
  344. handleChoisSku(sku, index) {
  345. // 选择SKU
  346. this.skuIndex = index
  347. },
  348. hidePopup() {
  349. this.$parent.popupShow2 = false
  350. }
  351. }
  352. }
  353. </script>
  354. <style lang="scss">
  355. .tui-popup-box {
  356. padding: 40rpx 24rpx 0 24rpx;
  357. }
  358. .tui-shopping-main {
  359. width: 100%;
  360. .tui-sku-title {
  361. width: 100%;
  362. height: 136rpx;
  363. float: left;
  364. margin-bottom: 30rpx;
  365. .tui-sku-image {
  366. width: 138rpx;
  367. height: 138rpx;
  368. float: left;
  369. border-radius: 8rpx;
  370. margin-right: 30rpx;
  371. box-sizing: border-box;
  372. border: 1px dashed #e1e1e1;
  373. image {
  374. width: 134rpx;
  375. height: 134rpx;
  376. border-radius: 10rpx;
  377. }
  378. }
  379. .tui-sku-price {
  380. height: 136rpx;
  381. float: left;
  382. .sku-price-viw {
  383. width: 100%;
  384. height: 40rpx;
  385. margin-bottom: 24rpx;
  386. .sku-price-text {
  387. font-size: 28rpx;
  388. line-height: 40rpx;
  389. color: #f94b4b;
  390. font-weight: bold;
  391. .sku-price-l{
  392. float: left;
  393. font-weight: normal;
  394. }
  395. &.none {
  396. text-decoration: line-through;
  397. color: #999999;
  398. font-weight: normal;
  399. }
  400. }
  401. }
  402. .sku-price-vip {
  403. width: 100%;
  404. height: 40rpx;
  405. }
  406. }
  407. }
  408. .tui-sku-unit {
  409. width: 100%;
  410. height: auto;
  411. float: left;
  412. .sku-unit-h1 {
  413. font-size: 28rpx;
  414. line-height: 40rpx;
  415. color: #333333;
  416. font-weight: bold;
  417. }
  418. .sku-unit-li {
  419. width: 100%;
  420. height: auto;
  421. .unit-li {
  422. padding: 0 24rpx;
  423. line-height: 48rpx;
  424. text-align: center;
  425. font-size: 24rpx;
  426. color: #666666;
  427. background: #f5f5f5;
  428. float: left;
  429. margin-right: 16rpx;
  430. margin-top: 12rpx;
  431. margin-bottom: 12rpx;
  432. border-radius: 24rpx;
  433. position: relative;
  434. box-sizing: border-box;
  435. border: 1px solid #f5f5f5;
  436. &.active {
  437. border-color: $color-system;
  438. background: #fff1eb;
  439. color: $color-system;
  440. .tips {
  441. background: #e15616;
  442. }
  443. }
  444. .tips {
  445. padding: 0 10rpx;
  446. line-height: 32rpx;
  447. text-align: center;
  448. font-size: 22rpx;
  449. color: #ffffff;
  450. background: #cccccc;
  451. float: left;
  452. border-radius: 16rpx;
  453. position: absolute;
  454. right: -12rpx;
  455. top: -15rpx;
  456. }
  457. }
  458. }
  459. }
  460. .sku-unit-nunbox {
  461. justify-content: space-between;
  462. align-items: center;
  463. width: 100%;
  464. height: auto;
  465. float: left;
  466. margin-top: 30rpx;
  467. .sku-unit-nunbox-t {
  468. width: 100%;
  469. height: 44rpx;
  470. position: relative;
  471. margin-bottom: 20rpx;
  472. .text {
  473. font-size: $font-size-24;
  474. line-height: 48rpx;
  475. color: #999999;
  476. }
  477. .sku-unit-nunbox-text {
  478. line-height: 44rpx;
  479. font-size: $font-size-28;
  480. float: left;
  481. font-weight: bold;
  482. }
  483. .sku-unit-nunbox-num{
  484. float: right;
  485. .number-box {
  486. display: flex;
  487. justify-content: center;
  488. align-items: center;
  489. border: 2rpx solid #ffe6dc;
  490. border-radius: 30rpx;
  491. height: 48rpx;
  492. margin-left: 20rpx;
  493. .iconfont {
  494. font-size: $font-size-24;
  495. padding: 0 18rpx;
  496. color: #999999;
  497. text-align: center;
  498. line-height: 48rpx;
  499. font-weight: bold;
  500. background: #fef6f3;
  501. &.icon-jianhao {
  502. border-radius: 30rpx 0 0 30rpx;
  503. }
  504. &.icon-jiahao {
  505. border-radius: 0 30rpx 30rpx 0;
  506. }
  507. }
  508. .btn-input {
  509. width: 62rpx;
  510. height: 48rpx;
  511. line-height: 48rpx;
  512. background: #ffffff;
  513. border-radius: 4rpx;
  514. text-align: center;
  515. font-size: $font-size-28;
  516. }
  517. }
  518. }
  519. }
  520. }
  521. }
  522. .tui-popup-btn{
  523. width: 100%;
  524. float: left;
  525. .tui-modal-flex {
  526. width: 100%;
  527. height: 84rpx;
  528. margin-top: 40rpx;
  529. display: flex;
  530. .tui-modal-button {
  531. flex: 1;
  532. line-height: 84rpx;
  533. font-size: $font-size-28;
  534. text-align: center;
  535. border-radius: 42rpx;
  536. padding: 0;
  537. margin: 0 15rpx;
  538. box-sizing: border-box;
  539. &.cancel {
  540. background: #ffe6dc;
  541. color: #e15616;
  542. }
  543. &.confirm {
  544. background: $btn-confirm;
  545. color: #ffffff;
  546. }
  547. }
  548. }
  549. }
  550. </style>