goods.js 2.8 KB

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