goods.js 2.8 KB

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