cartMixins.js 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  1. // 统计数据
  2. // 统计类型 1:首页banner;2:直播模块;3:最新活动;4:热门文章;5:新品橱窗;6:活动列表
  3. import Vue from 'vue'
  4. const cartMixins = {
  5. data() {
  6. return {
  7. }
  8. },
  9. methods: {
  10. hanldlerToConfirm() {
  11. //跳转确认订单页面
  12. let productIdList = [],
  13. skuIds = ''
  14. this.goodsList.forEach(supper => {
  15. supper.cartList.forEach(pros => {
  16. if (pros.isChecked) {
  17. productIdList.push(pros.skuId)
  18. }
  19. })
  20. })
  21. if (productIdList == '') {
  22. this.$util.msg('请先选择结算商品~', 2000)
  23. return
  24. } else {
  25. //判断勾选的商品是否为充值商品或者为定金商品的一些处理逻辑
  26. const isHasDepositlds = productIdList.filter(item => this.depositIds.includes(item))
  27. const isHasRechargeIds = productIdList.filter(item => this.rechargeIds.includes(item))
  28. const isGoods = productIdList.every(item => {
  29. ;[...this.depositIds, ...this.rechargeIds].includes(item)
  30. })
  31. if (productIdList.length == 1 && isHasDepositlds.length === 1 && isHasRechargeIds.length === 0) {
  32. console.log('定金商品')
  33. productIdList.forEach(skuId => {
  34. skuIds += skuId + ','
  35. })
  36. } else if (productIdList.length == 1 && isHasRechargeIds.length === 1 && isHasDepositlds.length === 0) {
  37. console.log('充值余额商品')
  38. productIdList.forEach(skuId => {
  39. skuIds += skuId + ','
  40. })
  41. } else if (!isGoods && isHasRechargeIds.length === 0 && isHasDepositlds.length === 0) {
  42. console.log('正常商品')
  43. productIdList.forEach(skuId => {
  44. skuIds += skuId + ','
  45. })
  46. } else {
  47. this.$util.modal('提示', '缴纳订金商品或余额充值商品请单独下单!', '确定', '', false, () => {})
  48. return
  49. }
  50. let cartSkuIds = { skuIds: skuIds.substring(0, skuIds.lastIndexOf(',')) }
  51. this.$api.navigateTo(`/pages/seller/order/create-order?data=${JSON.stringify({ data: cartSkuIds })}`)
  52. }
  53. },
  54. handleBtnConfirm(data) {
  55. console.log('data', data)
  56. // 确认重选规格调用 apisMixins -> apiQueryShoppingCartList
  57. this.apiUserClubCheckSku(data)
  58. },
  59. updateShoppogNum(pros) {
  60. const params = {
  61. id: pros.id,
  62. productCount: pros.number,
  63. serviceProviderId: this.listQuery.serviceProviderId
  64. }
  65. // 更新购物车调用 apisMixins -> apiQueryShoppingCartList
  66. this.apiSellerAddProductNum(params)
  67. },
  68. handleDeleteCart() { //删除购物车商品
  69. let delCartIds = ''
  70. this.goodsList.forEach(delitem => {
  71. delitem.cartList.forEach(pros => {
  72. if (pros.isChecked) {
  73. delCartIds += pros.id + ','
  74. }
  75. })
  76. })
  77. this.failureList.forEach(failure => {
  78. if (failure.isChecked) {
  79. delCartIds += failure.id + ','
  80. }
  81. })
  82. if (delCartIds.length == 0) {
  83. this.$util.msg('请选择要删除的商品~', 2000)
  84. return
  85. }
  86. this.$util.modal('', '确定删除选中的商品吗?', '确定', '取消', true, () => {
  87. this.apiSellerDeleteCart({ cartIds: delCartIds , serviceProviderId: this.listQuery.serviceProviderId })
  88. })
  89. },
  90. handleDeletefailures() { // 一键删除所有失效商品
  91. let delCartIds = ''
  92. this.failureList.forEach(failure => {
  93. delCartIds += failure.id + ','
  94. })
  95. this.$util.modal('', '确定清空全部失效商品吗?', '确定', '取消', true, () => {
  96. this.apiSellerDeleteCart({ cartIds: delCartIds , serviceProviderId: this.listQuery.serviceProviderId })
  97. })
  98. },
  99. handleFuctionData(){
  100. this.initGetCartGoodsList()
  101. }
  102. }
  103. }
  104. export default cartMixins