cartMixins.js 3.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  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. console.log('cartSkuIds',cartSkuIds)
  45. this.$api.navigateTo(
  46. `/pages/user/order/create-order?type=2&data=${JSON.stringify({ data: cartSkuIds })}`
  47. )
  48. },
  49. handleBtnConfirm(data) {
  50. console.log('data', data)
  51. // 确认重选规格调用 apisMixins -> apiQueryShoppingCartList
  52. this.apiUserClubCheckSku(data)
  53. },
  54. updateShoppogNum(pros) {
  55. const params = {
  56. userId: this.userId,
  57. skuId: pros.skuId,
  58. productCount: pros.number,
  59. source: 2
  60. }
  61. // 更新购物车调用 apisMixins -> apiQueryShoppingCartList
  62. this.apiShoppingCartUpdate(params)
  63. },
  64. handleDeleteCart() { //删除购物车商品
  65. this.goodsList.forEach(delitem => {
  66. delitem.cartList.forEach(pros => {
  67. if (pros.isChecked) {
  68. this.delSkuIds += pros.skuId + ','
  69. }
  70. })
  71. })
  72. this.failureList.forEach(failure => {
  73. if (failure.isChecked) {
  74. this.delSkuIds += failure.skuId + ','
  75. }
  76. })
  77. if (this.delSkuIds.length === 0) {
  78. this.$util.msg('请选择要删除的商品~', 2000)
  79. return
  80. }
  81. this.modal = true
  82. this.contentModalText = '确定删除选中的商品吗?'
  83. },
  84. handleDeletefailures() { // 一键清楚所有失效商品
  85. this.failureList.forEach(failure => {
  86. this.delSkuIds += failure.skuId + ','
  87. })
  88. this.modal = true
  89. this.contentModalText = '确定清空全部失效商品吗?'
  90. }
  91. }
  92. }
  93. export default cartMixins