proMixins.js 3.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. // 统计数据
  2. // 统计类型 1:首页banner;2:直播模块;3:最新活动;4:热门文章;5:新品橱窗;6:活动列表
  3. import Vue from 'vue'
  4. const proMixins = {
  5. data() {
  6. return {
  7. btnType:'',
  8. skuProduct: {},
  9. addParams: {
  10. skuId: 0,
  11. productCount: 0,
  12. productId: 0,
  13. userId: 0,
  14. source: 1
  15. }
  16. }
  17. },
  18. methods: {
  19. buyProductCart() {
  20. //底部购物车按钮点击
  21. if (this.hasLogin) {
  22. // 友盟埋点商品详情购物车入口点击事件
  23. if (process.env.NODE_ENV != 'development') {
  24. this.$uma.trackEvent('Um_Event_ProductShoppingCart', {
  25. Um_Key_PageName: '去购物车',
  26. Um_Key_SourcePage: '商品详情购物车入口'
  27. })
  28. }
  29. this.$api.navigateTo('/pages/goods/cart')
  30. } else {
  31. this.$api.navigateTo('/pages/login/login?type=1')
  32. }
  33. },
  34. btnGetConfirm(type) {
  35. //加入购物车&&立即购买点击
  36. if (this.hasLogin) {
  37. this.btnType = type
  38. this.popupShow3 = true
  39. this.unitPopupType = 1
  40. } else {
  41. this.$api.navigateTo('/pages/login/login?type=1')
  42. }
  43. },
  44. handleSkuClick(sku) { //sku修改选择
  45. this.addParams.skuId = sku.skuId
  46. this.skuProduct.originalPrice = sku.originalPrice
  47. this.skuProduct.price = sku.price
  48. },
  49. handleBuyConfirm(data) {
  50. // 监听确定选择规格
  51. console.log('data', data)
  52. if (data.type == 'buy') {
  53. this.handleToConfirm({ productIds: this.product.productId, skuId: this.addParams.skuId, productCount: data.productCount })
  54. } else {
  55. this.addParams.productCount = data.productCount
  56. this.handleAddClubCart(this.addParams)
  57. }
  58. },
  59. handleToConfirm(data) {
  60. //跳转确认订单页面
  61. this.$api.navigateTo(`/pages/user/order/create-order?type=1&data=${JSON.stringify({ data: data })}`)
  62. },
  63. handleAddClubCart(params) {
  64. //增加购物车成功和toast弹窗提示成功
  65. this.ProductService.shoppingAddCart(params)
  66. .then(response => {
  67. this.specClass = 'hide'
  68. this.$util.msg('加入购物车成功', 1500, true, 'success')
  69. this.isAnimation = true
  70. setTimeout(() => {
  71. this.specClass = 'none'
  72. }, 200)
  73. setTimeout(() => {
  74. this.isAnimation = false
  75. }, 2000)
  76. this.bottomCartNumber = response.data
  77. })
  78. .catch(error => {
  79. console.log('error', error.msg)
  80. })
  81. }
  82. }
  83. }
  84. export default proMixins