orderShare.js 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. // 返回数据
  2. const resultMessage = {}
  3. // 拼团分享格式
  4. const fightShareMessage = {
  5. title: '哈喽,赶快来参团吧!这件商品拼团买更便宜~',
  6. path: 'pages/tabBar/index/fight-share-entry',
  7. imageUrl: 'https://picsum.photos/200/200'
  8. }
  9. // 拼团分享
  10. function handleFightShare(shareData, option) {
  11. resultMessage.title = option.title
  12. resultMessage.path = option.path
  13. resultMessage.imageUrl = option.imageUrl
  14. return {
  15. type: 4,
  16. collageId: shareData.collageId,
  17. initiatorId: shareData.buyUserId
  18. }
  19. }
  20. // 订单分享混入对象
  21. const orderShare = {
  22. onShareAppMessage(e) {
  23. console.log(e)
  24. let shareData = null
  25. if (e.from === 'button') {
  26. // 拼单
  27. if (e.target.id === 'fightShare') {
  28. shareData = handleFightShare(e.target.dataset.share, fightShareMessage)
  29. }
  30. }
  31. console.log(shareData)
  32. // 加密参数
  33. const state_str = encodeURIComponent(this.$crypto.encrypt(shareData))
  34. return {
  35. title: resultMessage.title,
  36. path: `/pages/tabBar/index/index?state_str=${state_str}`,
  37. imageUrl: resultMessage.imageUrl
  38. }
  39. }
  40. }
  41. export default orderShare