cm-unit-popup.vue 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522
  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">SVIP</view>
  44. <view class="price">{{product.svipPriceTag}}</view>
  45. </view>
  46. </template>
  47. </view>
  48. </view>
  49. </view>
  50. </view>
  51. <view class="tui-sku-unit">
  52. <view class="sku-unit-h1">规格:</view>
  53. <view class="sku-unit-li">
  54. <view
  55. class="unit-li"
  56. v-for="(sku, index) in skuList"
  57. @click="handleChoisSku(sku, index)"
  58. :key="index"
  59. :class="skuIndex === index ? 'active' : ''"
  60. >
  61. {{ sku.unit }} <text class="tips">缺货</text>
  62. </view>
  63. </view>
  64. </view>
  65. <view class="sku-unit-nunbox">
  66. <view class="sku-unit-nunbox" v-if="product.step === 2">
  67. <view class="text">*该商品只能以起订量的整数倍购买</view>
  68. </view>
  69. <view class="sku-unit-nunbox-t">
  70. <view class="sku-unit-nunbox-text">购买数量:</view>
  71. <view class="sku-unit-nunbox-num">
  72. <view class="number-box">
  73. <view
  74. class="iconfont icon-jianhao"
  75. @click="changeCountSub"
  76. ></view>
  77. <input
  78. class="btn-input"
  79. type="number"
  80. v-model="params.productCount"
  81. maxlength="4"
  82. @blur="changeNumber($event)"
  83. />
  84. <view
  85. class="iconfont icon-jiahao"
  86. @click="changeCountAdd"
  87. ></view>
  88. </view>
  89. </view>
  90. </view>
  91. </view>
  92. </view>
  93. <view class="tui-right-flex tui-popup-btn" :style="{ paddingBottom: isIphoneX ? '68rpx' : '34rpx' }">
  94. <view class="tui-modal-flex">
  95. <view class="tui-modal-button confirm" @click="handleConfirm">加入购物车</view>
  96. </view>
  97. </view>
  98. </view>
  99. </tui-bottom-popup>
  100. </template>
  101. <script>
  102. import { mapState, mapMutations } from 'vuex'
  103. export default {
  104. name: 'cm-unit-popup',
  105. props: {
  106. product: {
  107. type: Object
  108. },
  109. popupShow: {
  110. type: Boolean,
  111. default: false
  112. },
  113. type: {
  114. type: Number,
  115. default: 1
  116. }
  117. },
  118. data() {
  119. return {
  120. skuIndex: 0,
  121. userIdentity:0,
  122. params:{
  123. serviceProviderId:0,//协销Id
  124. productId:0,
  125. clubId:0,
  126. serviceProviderId:0,
  127. productCount:1,
  128. type:1
  129. },
  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. ladderPriceList:[
  143. {
  144. numRange:'1-10',
  145. buyPrice:500
  146. },
  147. {
  148. numRange:'10-100',
  149. buyPrice:5000
  150. },
  151. {
  152. numRange:'100-1000',
  153. buyPrice:50000
  154. },
  155. ]
  156. },
  157. {
  158. unit: ' 精华70ml', // 规格
  159. normalPrice: 1000, // 市场价
  160. price: 500, // 售价
  161. costPrice: 500, // 结算价
  162. stock: 100 ,// 库存
  163. ladderPriceList:null
  164. },
  165. {
  166. unit: '精华70ml', // 规格
  167. normalPrice: 1000, // 市场价
  168. price: 500, // 售价
  169. costPrice: 500, // 结算价
  170. stock: 100 ,// 库存
  171. ladderPriceList:null
  172. },
  173. {
  174. unit: '【70ml】2瓶', // 规格
  175. normalPrice: 1000, // 市场价
  176. price: 500, // 售价
  177. costPrice: 500, // 结算价
  178. stock: 100 ,// 库存
  179. ladderPriceList:[
  180. {
  181. numRange:'1-10',
  182. buyPrice:500
  183. },
  184. {
  185. numRange:'10-100',
  186. buyPrice:5000
  187. },
  188. {
  189. numRange:'100-1000',
  190. buyPrice:50000
  191. },
  192. ]
  193. },
  194. {
  195. unit: '【50ml】3瓶', // 规格
  196. normalPrice: 1000, // 市场价
  197. price: 500, // 售价
  198. costPrice: 500, // 结算价
  199. stock: 100 ,// 库存
  200. ladderPriceList:null
  201. },
  202. {
  203. unit: '【50ml】3瓶', // 规格
  204. normalPrice: 1000, // 市场价
  205. price: 500, // 售价
  206. costPrice: 500, // 结算价
  207. stock: 100 ,// 库存
  208. ladderPriceList:[
  209. {
  210. numRange:'1-10',
  211. buyPrice:500
  212. },
  213. {
  214. numRange:'10-100',
  215. buyPrice:5000
  216. },
  217. {
  218. numRange:'100-1000',
  219. buyPrice:50000
  220. },
  221. ]
  222. }
  223. ],
  224. }
  225. },
  226. filters: {
  227. NumFormat(value) {
  228. //处理金额
  229. return Number(value).toFixed(2)
  230. }
  231. },
  232. created() {
  233. this.initData()
  234. },
  235. computed: {
  236. ...mapState(['hasLogin'])
  237. },
  238. methods: {
  239. async initData(data) {
  240. const clubInfo = await this.$api.getComStorage('orderUserInfo')
  241. const userInfo = await this.$api.getStorage()
  242. this.userIdentity = userInfo.userIdentity
  243. this.params.clubId = clubInfo.clubId ? clubInfo.clubId : 0
  244. this.params.serviceProviderId = userInfo.serviceProviderId
  245. this.params.productId = this.product.productId
  246. this.params.productCount = this.product.minBuyNumber
  247. this.buyRetailPrice = this.product.price
  248. this.buyRetailPriceStep = this.handleData.step
  249. if (this.handleData.ladderPriceFlag == 1) {
  250. this.params.productCount = this.handleData.maxBuyNumber ? this.handleData.maxBuyNumber : 1
  251. } else {
  252. this.params.productCount = this.handleData.minBuyNumber
  253. }
  254. },
  255. PromotionsFormat(promo) {
  256. //促销活动类型数据处理
  257. if (promo != null) {
  258. if (promo.type == 1 && promo.mode == 1) {
  259. return true
  260. } else {
  261. return false
  262. }
  263. }
  264. return false
  265. },
  266. changeCountAdd() {
  267. //popup弹窗数量增加按钮
  268. if (this.buyRetailPriceStep == 2) {
  269. this.params.productCount += this.product.minBuyNumber
  270. } else {
  271. this.params.productCount++
  272. }
  273. },
  274. changeCountSub() {
  275. //popup弹窗数量减按钮
  276. if (this.params.productCount <= this.product.minBuyNumber) {
  277. this.params.productCount = this.product.minBuyNumber
  278. this.isQuantity = true
  279. this.$util.msg(`该商品最小起订量为${this.product.minBuyNumber}`, 2000)
  280. return
  281. } else {
  282. if (this.buyRetailPriceStep == 2) {
  283. this.params.productCount -= this.product.minBuyNumber
  284. } else {
  285. this.params.productCount--
  286. }
  287. this.isQuantity = false
  288. }
  289. },
  290. changeNumber(e) {
  291. let _value = e.detail.value
  292. if (!this.$api.isNumber(_value)) {
  293. this.params.productCount = this.product.minBuyNumber
  294. } else if (_value < this.product.minBuyNumber) {
  295. this.$util.msg(`该商品最小起订量为${this.product.minBuyNumber}`, 2000)
  296. this.params.productCount = this.product.minBuyNumber
  297. } else if (_value % this.product.minBuyNumber != 0) {
  298. this.$util.msg('购买量必须为起订量的整数倍', 2000)
  299. this.params.productCount = this.product.minBuyNumber
  300. } else {
  301. this.params.productCount = e.detail.value
  302. }
  303. },
  304. handleConfirm() {
  305. //增加购物车成功和toast弹窗提示成功
  306. this.SellerService.ShoppingCartAddCart(this.params).then(response => {
  307. this.$parent.popupShow = false
  308. this.$util.msg('加入购物车成功',1500,true,'success')
  309. this.$parent.getClubProductNum();
  310. }).catch(error =>{
  311. this.$util.msg(error.msg,2000);
  312. })
  313. },
  314. handleChoisSku(sku, index) {
  315. // 选择SKU
  316. this.skuIndex = index
  317. },
  318. hidePopup() {
  319. this.$parent.popupShow = false
  320. }
  321. }
  322. }
  323. </script>
  324. <style lang="scss">
  325. .tui-popup-box {
  326. padding: 40rpx 24rpx 0 24rpx;
  327. }
  328. .tui-shopping-main {
  329. width: 100%;
  330. .tui-sku-title {
  331. width: 100%;
  332. height: 136rpx;
  333. float: left;
  334. margin-bottom: 30rpx;
  335. .tui-sku-image {
  336. width: 138rpx;
  337. height: 138rpx;
  338. float: left;
  339. border-radius: 8rpx;
  340. margin-right: 30rpx;
  341. box-sizing: border-box;
  342. border: 1px dashed #e1e1e1;
  343. image {
  344. width: 134rpx;
  345. height: 134rpx;
  346. border-radius: 10rpx;
  347. }
  348. }
  349. .tui-sku-price {
  350. height: 136rpx;
  351. float: left;
  352. .sku-price-viw {
  353. width: 100%;
  354. height: 40rpx;
  355. margin-bottom: 24rpx;
  356. .sku-price-text {
  357. font-size: 28rpx;
  358. line-height: 40rpx;
  359. color: #f94b4b;
  360. font-weight: bold;
  361. .sku-price-l{
  362. float: left;
  363. font-weight: normal;
  364. }
  365. &.none {
  366. text-decoration: line-through;
  367. color: #999999;
  368. font-weight: normal;
  369. }
  370. }
  371. }
  372. .sku-price-vip {
  373. width: 100%;
  374. height: 40rpx;
  375. }
  376. }
  377. }
  378. .tui-sku-unit {
  379. width: 100%;
  380. height: auto;
  381. float: left;
  382. .sku-unit-h1 {
  383. font-size: 28rpx;
  384. line-height: 40rpx;
  385. color: #333333;
  386. font-weight: bold;
  387. }
  388. .sku-unit-li {
  389. width: 100%;
  390. height: auto;
  391. .unit-li {
  392. padding: 0 24rpx;
  393. line-height: 48rpx;
  394. text-align: center;
  395. font-size: 24rpx;
  396. color: #666666;
  397. background: #f5f5f5;
  398. float: left;
  399. margin-right: 16rpx;
  400. margin-top: 12rpx;
  401. margin-bottom: 12rpx;
  402. border-radius: 24rpx;
  403. position: relative;
  404. box-sizing: border-box;
  405. border: 1px solid #f5f5f5;
  406. &.active {
  407. border-color: $color-system;
  408. background: #fff1eb;
  409. color: $color-system;
  410. .tips {
  411. background: #e15616;
  412. }
  413. }
  414. .tips {
  415. padding: 0 10rpx;
  416. line-height: 32rpx;
  417. text-align: center;
  418. font-size: 22rpx;
  419. color: #ffffff;
  420. background: #cccccc;
  421. float: left;
  422. border-radius: 16rpx;
  423. position: absolute;
  424. right: -12rpx;
  425. top: -15rpx;
  426. }
  427. }
  428. }
  429. }
  430. .sku-unit-nunbox {
  431. justify-content: space-between;
  432. align-items: center;
  433. width: 100%;
  434. height: auto;
  435. float: left;
  436. margin-top: 30rpx;
  437. .sku-unit-nunbox-t {
  438. width: 100%;
  439. height: 44rpx;
  440. position: relative;
  441. margin-bottom: 20rpx;
  442. .text {
  443. font-size: $font-size-24;
  444. line-height: 48rpx;
  445. color: #999999;
  446. }
  447. .sku-unit-nunbox-text {
  448. line-height: 44rpx;
  449. font-size: $font-size-28;
  450. float: left;
  451. font-weight: bold;
  452. }
  453. .sku-unit-nunbox-num{
  454. float: right;
  455. .number-box {
  456. display: flex;
  457. justify-content: center;
  458. align-items: center;
  459. border: 2rpx solid #ffe6dc;
  460. border-radius: 30rpx;
  461. height: 48rpx;
  462. margin-left: 20rpx;
  463. .iconfont {
  464. font-size: $font-size-24;
  465. padding: 0 18rpx;
  466. color: #999999;
  467. text-align: center;
  468. line-height: 48rpx;
  469. font-weight: bold;
  470. background: #fef6f3;
  471. &.icon-jianhao {
  472. border-radius: 30rpx 0 0 30rpx;
  473. }
  474. &.icon-jiahao {
  475. border-radius: 0 30rpx 30rpx 0;
  476. }
  477. }
  478. .btn-input {
  479. width: 62rpx;
  480. height: 48rpx;
  481. line-height: 48rpx;
  482. background: #ffffff;
  483. border-radius: 4rpx;
  484. text-align: center;
  485. font-size: $font-size-28;
  486. }
  487. }
  488. }
  489. }
  490. }
  491. }
  492. .tui-popup-btn{
  493. width: 100%;
  494. float: left;
  495. .tui-modal-flex {
  496. width: 100%;
  497. height: 84rpx;
  498. margin-top: 40rpx;
  499. display: flex;
  500. .tui-modal-button {
  501. flex: 1;
  502. line-height: 84rpx;
  503. font-size: $font-size-28;
  504. text-align: center;
  505. border-radius: 42rpx;
  506. padding: 0;
  507. margin: 0 15rpx;
  508. box-sizing: border-box;
  509. &.cancel {
  510. background: #ffe6dc;
  511. color: #e15616;
  512. }
  513. &.confirm {
  514. background: $btn-confirm;
  515. color: #ffffff;
  516. }
  517. }
  518. }
  519. }
  520. </style>