cartMixins.js 3.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  1. // 统计数据
  2. // 统计类型 1:首页banner;2:直播模块;3:最新活动;4:热门文章;5:新品橱窗;6:活动列表
  3. import Vue from 'vue'
  4. const cartMixins = {
  5. data() {
  6. return {
  7. delCartIds:''
  8. }
  9. },
  10. methods: {
  11. hanldlerToConfirm() {
  12. //跳转确认订单页面
  13. let skuIds = ''
  14. this.isNoConfim = false
  15. this.goodsList.forEach(supper => {
  16. supper.cartList.forEach(pros => {
  17. if (pros.isChecked) {
  18. // 获取勾选的商品ID拼接字符串逗号隔开,最后一个逗号去掉
  19. skuIds += pros.skuId + ','
  20. // 有商品的购买量没达到最小起订量
  21. if (pros.number < pros.min) {
  22. this.isNoConfim = true
  23. }
  24. }
  25. })
  26. })
  27. if (skuIds === '') {
  28. this.$util.msg('请先选择结算商品~', 2000)
  29. return
  30. }
  31. if (this.isNoConfim) {
  32. this.$util.modal(
  33. '',
  34. '有商品的购买量没达到最小起订量,请修改数量后再次提交结算',
  35. '去修改',
  36. '',
  37. false,
  38. () => {}
  39. )
  40. return
  41. }
  42. let cartSkuIds = { skuIds: skuIds.substring(0, skuIds.lastIndexOf(',')) }
  43. console.log('cartSkuIds',cartSkuIds)
  44. this.$api.navigateTo(
  45. `/pages/seller/order/order-confirm?type=2&data=${JSON.stringify({ data: cartSkuIds })}`
  46. )
  47. },
  48. handleBtnConfirm(data) {
  49. console.log('data', data)
  50. // 确认重选规格调用 apisMixins -> apiQueryShoppingCartList
  51. this.apiUserClubCheckSku(data)
  52. },
  53. updateShoppogNum(pros) {
  54. const params = {
  55. id: pros.id,
  56. productCount: pros.number,
  57. serviceProviderId: this.listQuery.serviceProviderId
  58. }
  59. // 更新购物车调用 apisMixins -> apiQueryShoppingCartList
  60. this.apiShoppingCartUpdate(params)
  61. },
  62. handleDeleteCart() { //删除购物车商品
  63. this.goodsList.forEach(delitem => {
  64. delitem.cartList.forEach(pros => {
  65. if (pros.isChecked) {
  66. this.delCartIds += pros.id + ','
  67. }
  68. })
  69. })
  70. this.failureList.forEach(failure => {
  71. if (failure.isChecked) {
  72. this.delCartIds += failure.id + ','
  73. }
  74. })
  75. if (this.delCartIds.length === 0) {
  76. this.$util.msg('请选择要删除的商品~', 2000)
  77. return
  78. }
  79. this.modal = true
  80. this.contentModalText = '确定删除选中的商品吗?'
  81. },
  82. handleDeletefailures() { // 一键清楚所有失效商品
  83. this.failureList.forEach(failure => {
  84. this.delCartIds += failure.id + ','
  85. })
  86. this.modal = true
  87. this.contentModalText = '确定清空全部失效商品吗?'
  88. }
  89. }
  90. }
  91. export default cartMixins