groupon.js 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123
  1. import sheep from '@/sheep';
  2. import { formatImageUrlProtocol } from './index';
  3. import third from '@/sheep/api/migration/third';
  4. const groupon = async (poster) => {
  5. const width = poster.width;
  6. const userInfo = sheep.$store('user').userInfo;
  7. const wxa_qrcode = 'data:image/png;base64,' + (await third.wechat.getWxacode(poster.shareInfo.path, poster.shareInfo.query)).data;
  8. return [
  9. {
  10. type: 'image',
  11. src: formatImageUrlProtocol(sheep.$url.cdn(sheep.$store('app').platform.share.posterInfo.groupon_bg)),
  12. css: {
  13. width,
  14. position: 'fixed',
  15. 'object-fit': 'contain',
  16. top: '0',
  17. left: '0',
  18. zIndex: -1,
  19. },
  20. },
  21. {
  22. type: 'text',
  23. text: userInfo.nickname,
  24. css: {
  25. color: '#333',
  26. fontSize: 16,
  27. fontFamily: 'sans-serif',
  28. position: 'fixed',
  29. top: width * 0.06,
  30. left: width * 0.22,
  31. },
  32. },
  33. {
  34. type: 'image',
  35. src: formatImageUrlProtocol(sheep.$url.cdn(userInfo.avatar)),
  36. css: {
  37. position: 'fixed',
  38. left: width * 0.04,
  39. top: width * 0.04,
  40. width: width * 0.14,
  41. height: width * 0.14,
  42. },
  43. },
  44. {
  45. type: 'image',
  46. src: formatImageUrlProtocol(poster.shareInfo.poster.image),
  47. css: {
  48. position: 'fixed',
  49. left: width * 0.03,
  50. top: width * 0.21,
  51. width: width * 0.94,
  52. height: width * 0.94,
  53. borderRadius: 10,
  54. },
  55. },
  56. {
  57. type: 'text',
  58. text: poster.shareInfo.poster.title,
  59. css: {
  60. color: '#333',
  61. fontSize: 14,
  62. position: 'fixed',
  63. top: width * 1.18,
  64. left: width * 0.04,
  65. maxWidth: width * 0.91,
  66. lineHeight: 5,
  67. },
  68. },
  69. {
  70. type: 'text',
  71. text: '¥' + poster.shareInfo.poster.price,
  72. css: {
  73. color: '#ff0000',
  74. fontSize: 20,
  75. fontFamily: 'OPPOSANS',
  76. position: 'fixed',
  77. top: width * 1.3,
  78. left: width * 0.04,
  79. },
  80. },
  81. {
  82. type: 'text',
  83. text: '2人团',
  84. css: {
  85. color: '#ff0000',
  86. fontSize: 30,
  87. fontFamily: 'OPPOSANS',
  88. position: 'fixed',
  89. left: width * 0.3,
  90. top: width * 1.32,
  91. },
  92. },
  93. // #ifndef MP-WEIXIN
  94. {
  95. type: 'qrcode',
  96. text: poster.shareInfo.link,
  97. css: {
  98. position: 'fixed',
  99. left: width * 0.75,
  100. top: width * 1.3,
  101. width: width * 0.2,
  102. height: width * 0.2,
  103. },
  104. },
  105. // #endif
  106. // #ifdef MP-WEIXIN
  107. {
  108. type: 'image',
  109. src: wxa_qrcode,
  110. css: {
  111. position: 'fixed',
  112. left: width * 0.75,
  113. top: width * 1.3,
  114. width: width * 0.2,
  115. height: width * 0.2,
  116. },
  117. },
  118. // #endif
  119. ];
  120. };
  121. export default groupon;