proMixins.js 3.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  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. tagStyle:{
  17. div:'line-height: 58rpx;margin-bottom: 10rpx;font-size: 28rpx;',
  18. h4:'line-height: 54rpx;font-size: 30rpx;color:#666666;padding: 0 20rpx;font-weight: normal;',
  19. h3:'line-height: 54rpx;font-size: 30rpx;color:#666666;padding: 0 20rpx;font-weight: normal;',
  20. h2:'line-height: 54rpx;font-size: 30rpx;color:#666666;padding: 0 20rpx;font-weight: normal;',
  21. p:'line-height: 54rpx;font-size: 30rpx;color:#666666;padding: 0 20rpx;',
  22. a:'line-height: 54rpx;font-size: 30rpx;color:#666666;',
  23. span:'line-height: 54rpx;font-size: 30rpx;color:#666666;',
  24. img:'width: 100%;height: auto;'
  25. }
  26. }
  27. },
  28. methods: {
  29. buyProductCart() {
  30. //底部购物车按钮点击
  31. if (this.hasLogin) {
  32. // 友盟埋点商品详情购物车入口点击事件
  33. if (process.env.NODE_ENV != 'development') {
  34. this.$uma.trackEvent('Um_Event_ProductShoppingCart', {
  35. Um_Key_PageName: '去购物车',
  36. Um_Key_SourcePage: '商品详情购物车入口'
  37. })
  38. }
  39. this.$api.navigateTo('/pages/goods/cart')
  40. } else {
  41. this.$api.navigateTo('/pages/login/login?type=1')
  42. }
  43. },
  44. btnGetConfirm(type) {
  45. //加入购物车&&立即购买点击
  46. if (this.hasLogin) {
  47. this.btnType = type
  48. this.popupShow3 = true
  49. this.unitPopupType = 1
  50. } else {
  51. this.$api.navigateTo('/pages/login/login?type=1')
  52. }
  53. },
  54. handleSkuClick(sku) { //sku修改选择
  55. this.addParams.skuId = sku.skuId
  56. this.skuProduct.originalPrice = sku.originalPrice
  57. this.skuProduct.price = sku.price
  58. },
  59. handleBuyConfirm(data) {
  60. // 监听确定选择规格
  61. console.log('data', data)
  62. if (data.type == 'buy') {
  63. this.handleToConfirm({ productIds: this.product.productId, skuId: this.addParams.skuId, productCount: data.productCount })
  64. } else {
  65. this.addParams.productCount = data.productCount
  66. this.handleAddClubCart(this.addParams)
  67. }
  68. },
  69. handleToConfirm(data) {
  70. //跳转确认订单页面
  71. this.$api.navigateTo(`/pages/user/order/create-order?type=1&data=${JSON.stringify({ data: data })}`)
  72. },
  73. handleAddClubCart(params) {
  74. //增加购物车成功和toast弹窗提示成功
  75. this.ProductService.shoppingAddCart(params)
  76. .then(response => {
  77. this.specClass = 'hide'
  78. this.$util.msg('加入购物车成功', 1500, true, 'success')
  79. this.isAnimation = true
  80. setTimeout(() => {
  81. this.specClass = 'none'
  82. }, 200)
  83. setTimeout(() => {
  84. this.isAnimation = false
  85. }, 2000)
  86. this.bottomCartNumber = response.data
  87. })
  88. .catch(error => {
  89. console.log('error', error.msg)
  90. })
  91. }
  92. }
  93. }
  94. export default proMixins