goods.js 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126
  1. import sheep from '@/sheep';
  2. import third from '@/sheep/api/migration/third';
  3. import { formatImageUrlProtocol } from './index';
  4. const goods = async (poster) => {
  5. const width = poster.width;
  6. const userInfo = sheep.$store('user').userInfo;
  7. const wxa_qrcode = (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.goods_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. },
  54. },
  55. {
  56. type: 'text',
  57. text: poster.shareInfo.poster.title,
  58. css: {
  59. position: 'fixed',
  60. left: width * 0.04,
  61. top: width * 1.18,
  62. color: '#333',
  63. fontSize: 14,
  64. lineHeight: 5,
  65. maxWidth: width * 0.91,
  66. },
  67. },
  68. {
  69. type: 'text',
  70. text: '¥' + poster.shareInfo.poster.price,
  71. css: {
  72. position: 'fixed',
  73. left: width * 0.04,
  74. top: width * 1.3,
  75. fontSize: 20,
  76. fontFamily: 'OPPOSANS',
  77. color: '#333',
  78. },
  79. },
  80. {
  81. type: 'text',
  82. text:
  83. poster.shareInfo.poster.original_price > 0
  84. ? '¥' + poster.shareInfo.poster.original_price
  85. : '',
  86. css: {
  87. position: 'fixed',
  88. left: width * 0.3,
  89. top: width * 1.32,
  90. color: '#999',
  91. fontSize: 10,
  92. fontFamily: 'OPPOSANS',
  93. textDecoration: 'line-through',
  94. },
  95. },
  96. // #ifndef MP-WEIXIN
  97. {
  98. type: 'qrcode',
  99. text: poster.shareInfo.link,
  100. css: {
  101. position: 'fixed',
  102. left: width * 0.75,
  103. top: width * 1.3,
  104. width: width * 0.2,
  105. height: width * 0.2,
  106. },
  107. },
  108. // #endif
  109. // #ifdef MP-WEIXIN
  110. {
  111. type: 'image',
  112. src: wxa_qrcode,
  113. css: {
  114. position: 'fixed',
  115. left: width * 0.75,
  116. top: width * 1.3,
  117. width: width * 0.2,
  118. height: width * 0.2,
  119. },
  120. },
  121. // #endif
  122. ];
  123. };
  124. export default goods;