cm-unit-cart-popup.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464
  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.addParams.oldSkuId = this.skuProduct.skuId
  171. this.addParams.newSkuId = this.skuList[0].skuId
  172. this.isBtnDisabled = this.skuList[0].stock === 0
  173. this.productCount = this.skuList[0].minBuyNumber
  174. this.skuProduct.price = this.skuList[0].price
  175. this.addParams.clubId = clubInfo.clubId ? clubInfo.clubId : 0
  176. this.addParams.serviceProviderId = userInfo.serviceProviderId
  177. },
  178. PromotionsFormat(promo) {
  179. //促销活动类型数据处理
  180. if (promo != null) {
  181. if (promo.type == 1 && promo.mode == 1) {
  182. return true
  183. } else {
  184. return false
  185. }
  186. }
  187. return false
  188. },
  189. //popup弹窗数量增加按钮
  190. changeCountAdd() {
  191. if (this.productCount === this.handleStock) {
  192. this.isStock = true
  193. return
  194. }
  195. if (this.skuProduct.step == 2) {
  196. this.productCount += this.handleMinNumber
  197. } else {
  198. this.productCount++
  199. }
  200. },
  201. //popup弹窗数量减按钮
  202. changeCountSub() {
  203. if (this.productCount <= this.handleMinNumber) {
  204. this.productCount = this.handleMinNumber
  205. this.isQuantity = true
  206. this.$util.msg(`该商品最小起订量为${this.handleMinNumber}`, 2000)
  207. return
  208. } else {
  209. if (this.skuProduct.step == 2) {
  210. this.productCount -= this.handleMinNumber
  211. } else {
  212. this.productCount--
  213. }
  214. this.isQuantity = false
  215. }
  216. },
  217. changeNumber(e) {
  218. let _value = e.detail.value
  219. if (!this.$api.isNumber(_value)) {
  220. this.productCount = this.handleMinNumber
  221. } else if (_value < this.handleMinNumber) {
  222. this.$util.msg(`该商品最小起订量为${this.handleMinNumber}`, 2000)
  223. this.productCount = this.handleMinNumber
  224. } else if (_value % this.handleMinNumber != 0) {
  225. this.$util.msg('购买量必须为起订量的整数倍', 2000)
  226. this.productCount = this.handleMinNumber
  227. } else if (_value > this.handleStock) {
  228. this.productCount = this.handleStock
  229. } else {
  230. this.productCount = e.detail.value
  231. }
  232. },
  233. handleBuyConfirm() {
  234. this.addParams.productCount = this.productCount
  235. this.handleAddClubCart(this.addParams)
  236. },
  237. handleAddClubCart(params) {
  238. //增加购物车成功和toast弹窗提示成功
  239. this.SellerService.orderSellerCkeckSku(params)
  240. .then(response => {
  241. this.$parent.popupShow = false
  242. this.$util.msg('加入购物车成功', 1500, true, 'success')
  243. this.$parent.getClubProductNum()
  244. this.$emit('handleFuction')
  245. })
  246. .catch(error => {
  247. this.$util.msg(error.msg, 2000)
  248. })
  249. },
  250. handleChoisSku(sku, index) {
  251. // 选择SKU
  252. this.skuIndex = index
  253. this.productCount = this.addParams.productCount = this.handleMinNumber = sku.minBuyNumber
  254. this.addParams.newSkuId = sku.skuId
  255. this.handleStock = sku.stock
  256. this.skuProduct.price = sku.price
  257. this.skuProduct.originalPrice = sku.originalPrice
  258. this.isBtnDisabled = sku.stock === 0
  259. this.$emit('skuClick', sku)
  260. },
  261. hidePopup() {
  262. this.$parent.popupShow = false
  263. }
  264. }
  265. }
  266. </script>
  267. <style lang="scss">
  268. .tui-popup-box {
  269. padding: 40rpx 24rpx 0 24rpx;
  270. }
  271. .tui-shopping-main {
  272. width: 100%;
  273. .tui-sku-title {
  274. width: 100%;
  275. height: 136rpx;
  276. float: left;
  277. margin-bottom: 30rpx;
  278. .tui-sku-image {
  279. width: 138rpx;
  280. height: 138rpx;
  281. float: left;
  282. border-radius: 8rpx;
  283. margin-right: 30rpx;
  284. box-sizing: border-box;
  285. border: 1px dashed #e1e1e1;
  286. image {
  287. width: 134rpx;
  288. height: 134rpx;
  289. border-radius: 10rpx;
  290. }
  291. }
  292. .tui-sku-price {
  293. height: 136rpx;
  294. float: left;
  295. .sku-price-viw {
  296. width: 100%;
  297. height: 40rpx;
  298. margin-bottom: 24rpx;
  299. .sku-price-text {
  300. font-size: 28rpx;
  301. line-height: 40rpx;
  302. color: #f94b4b;
  303. font-weight: bold;
  304. .sku-price-l {
  305. float: left;
  306. font-weight: normal;
  307. }
  308. &.none {
  309. text-decoration: line-through;
  310. color: #999999;
  311. font-weight: normal;
  312. }
  313. }
  314. }
  315. .sku-price-vip {
  316. width: 100%;
  317. height: 40rpx;
  318. }
  319. }
  320. }
  321. .tui-sku-unit {
  322. width: 100%;
  323. height: auto;
  324. float: left;
  325. .sku-unit-h1 {
  326. font-size: 28rpx;
  327. line-height: 40rpx;
  328. color: #333333;
  329. font-weight: bold;
  330. }
  331. .sku-unit-li {
  332. width: 100%;
  333. height: auto;
  334. .unit-li {
  335. padding: 0 24rpx;
  336. line-height: 48rpx;
  337. text-align: center;
  338. font-size: 24rpx;
  339. color: #666666;
  340. background: #f5f5f5;
  341. float: left;
  342. margin-right: 16rpx;
  343. margin-top: 12rpx;
  344. margin-bottom: 12rpx;
  345. border-radius: 24rpx;
  346. position: relative;
  347. box-sizing: border-box;
  348. border: 1px solid #f5f5f5;
  349. &.active {
  350. border-color: $color-system;
  351. background: #fff1eb;
  352. color: $color-system;
  353. .tips {
  354. background: #e15616;
  355. }
  356. }
  357. .tips {
  358. padding: 0 10rpx;
  359. line-height: 32rpx;
  360. text-align: center;
  361. font-size: 22rpx;
  362. color: #ffffff;
  363. background: #cccccc;
  364. float: left;
  365. border-radius: 16rpx;
  366. position: absolute;
  367. right: -12rpx;
  368. top: -15rpx;
  369. }
  370. }
  371. }
  372. }
  373. .sku-unit-nunbox {
  374. justify-content: space-between;
  375. align-items: center;
  376. width: 100%;
  377. height: auto;
  378. float: left;
  379. margin-top: 30rpx;
  380. .sku-unit-nunbox-t {
  381. width: 100%;
  382. height: 44rpx;
  383. position: relative;
  384. margin-bottom: 20rpx;
  385. .text {
  386. font-size: $font-size-24;
  387. line-height: 48rpx;
  388. color: #999999;
  389. }
  390. .sku-unit-nunbox-text {
  391. line-height: 44rpx;
  392. font-size: $font-size-28;
  393. float: left;
  394. font-weight: bold;
  395. }
  396. .sku-unit-nunbox-num {
  397. float: right;
  398. .number-box {
  399. display: flex;
  400. justify-content: center;
  401. align-items: center;
  402. border: 2rpx solid #ffe6dc;
  403. border-radius: 30rpx;
  404. height: 48rpx;
  405. margin-left: 20rpx;
  406. .iconfont {
  407. font-size: $font-size-24;
  408. padding: 0 18rpx;
  409. color: #999999;
  410. text-align: center;
  411. line-height: 48rpx;
  412. font-weight: bold;
  413. background: #fef6f3;
  414. &.icon-jianhao {
  415. border-radius: 30rpx 0 0 30rpx;
  416. }
  417. &.icon-jiahao {
  418. border-radius: 0 30rpx 30rpx 0;
  419. }
  420. }
  421. .btn-input {
  422. width: 62rpx;
  423. height: 48rpx;
  424. line-height: 48rpx;
  425. background: #ffffff;
  426. border-radius: 4rpx;
  427. text-align: center;
  428. font-size: $font-size-28;
  429. }
  430. }
  431. }
  432. }
  433. }
  434. }
  435. .tui-popup-btn {
  436. width: 100%;
  437. float: left;
  438. .tui-modal-flex {
  439. width: 100%;
  440. height: 84rpx;
  441. margin-top: 40rpx;
  442. display: flex;
  443. .tui-modal-button {
  444. flex: 1;
  445. line-height: 84rpx;
  446. font-size: $font-size-28;
  447. text-align: center;
  448. border-radius: 42rpx;
  449. padding: 0;
  450. margin: 0 15rpx;
  451. box-sizing: border-box;
  452. &.confirm {
  453. background: $btn-confirm;
  454. color: #ffffff;
  455. &.disabled {
  456. background: linear-gradient(135deg, rgba(242, 143, 49, 0.5) 0%, rgba(225, 86, 22, 0.5) 100%);
  457. }
  458. }
  459. }
  460. }
  461. }
  462. </style>