cm-unit-cart-popup.vue 11 KB

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