orderShare.js 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  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 scenencodeURIComponent(this.$crypto.encrypt(shareData))
  34. return {
  35. title: resultMessage.title,
  36. path: `/pages/tabBar/index/index?scenecenscene imageUrl: resultMessage.imageUrl
  37. }
  38. }
  39. }
  40. export default orderShare