cartMixins.js 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. // 统计数据
  2. // 统计类型 1:首页banner;2:直播模块;3:最新活动;4:热门文章;5:新品橱窗;6:活动列表
  3. import Vue from 'vue'
  4. const cartMixins = {
  5. data() {
  6. return {
  7. delSkuIds:''
  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. // 友盟埋点购物车去结算点击事件
  43. let cartSkuIds = { skuIds: skuIds.substring(0, skuIds.lastIndexOf(',')) }
  44. this.$api.navigateTo(
  45. `/pages/user/order/create-order?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. userId: this.userId,
  56. skuId: pros.skuId,
  57. productCount: pros.number,
  58. source: 2
  59. }
  60. // 更新购物车调用 apisMixins -> apiQueryShoppingCartList
  61. this.apiShoppingCartUpdate(params)
  62. },
  63. handleDeleteCart() { //删除购物车商品
  64. this.goodsList.forEach(delitem => {
  65. delitem.cartList.forEach(pros => {
  66. if (pros.isChecked) {
  67. this.delSkuIds += pros.skuId + ','
  68. }
  69. })
  70. })
  71. this.failureList.forEach(failure => {
  72. if (failure.isChecked) {
  73. this.delSkuIds += failure.skuId + ','
  74. }
  75. })
  76. if (this.delSkuIds.length === 0) {
  77. this.$util.msg('请选择要删除的商品~', 2000)
  78. return
  79. }
  80. this.modal = true
  81. this.contentModalText = '确定删除选中的商品吗?'
  82. },
  83. handleDeletefailures() { // 一键清楚所有失效商品
  84. this.failureList.forEach(failure => {
  85. this.delSkuIds += failure.skuId + ','
  86. })
  87. this.modal = true
  88. this.contentModalText = '确定清空全部失效商品吗?'
  89. }
  90. }
  91. }
  92. export default cartMixins