goods.js 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122
  1. import sheep from '@/sheep';
  2. import third from '@/sheep/api/migration/third';
  3. import { formatImageUrlProtocol, getBase64Src } 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. background: formatImageUrlProtocol(sheep.$url.cdn(sheep.$store('app').platform.share.posterInfo.goods_bg)),
  10. list: [
  11. {
  12. name: 'nickname',
  13. type: 'text',
  14. val: userInfo.nickname,
  15. x: width * 0.22,
  16. y: width * 0.06,
  17. paintbrushProps: {
  18. fillStyle: '#333',
  19. font: {
  20. fontSize: 16,
  21. fontFamily: 'sans-serif',
  22. },
  23. },
  24. },
  25. {
  26. name: 'avatar',
  27. type: 'image',
  28. val: formatImageUrlProtocol(sheep.$url.cdn(userInfo.avatar)),
  29. x: width * 0.04,
  30. y: width * 0.04,
  31. width: width * 0.14,
  32. height: width * 0.14,
  33. d: width * 0.14,
  34. },
  35. {
  36. name: 'goodsImage',
  37. type: 'image',
  38. val: formatImageUrlProtocol(poster.shareInfo.poster.image),
  39. x: width * 0.03,
  40. y: width * 0.21,
  41. width: width * 0.94,
  42. height: width * 0.94,
  43. r: 10,
  44. },
  45. {
  46. name: 'goodsTitle',
  47. type: 'text',
  48. val: poster.shareInfo.poster.title,
  49. x: width * 0.04,
  50. y: width * 1.18,
  51. maxWidth: width * 0.91,
  52. line: 2,
  53. lineHeight: 5,
  54. paintbrushProps: {
  55. fillStyle: '#333',
  56. font: {
  57. fontSize: 14,
  58. },
  59. },
  60. },
  61. {
  62. name: 'goodsPrice',
  63. type: 'text',
  64. val: '¥' + poster.shareInfo.poster.price,
  65. x: width * 0.04,
  66. y: width * 1.3,
  67. paintbrushProps: {
  68. fillStyle: '#ff0000',
  69. font: {
  70. fontSize: 20,
  71. fontFamily: 'OPPOSANS',
  72. },
  73. },
  74. },
  75. {
  76. name: 'goodsOriginalPrice',
  77. type: 'text',
  78. val:
  79. poster.shareInfo.poster.original_price > 0
  80. ? '¥' + poster.shareInfo.poster.original_price
  81. : '',
  82. x: width * 0.3,
  83. y: width * 1.32,
  84. paintbrushProps: {
  85. fillStyle: '#999',
  86. font: {
  87. fontSize: 10,
  88. fontFamily: 'OPPOSANS',
  89. },
  90. },
  91. textDecoration: {
  92. line: 'line-through',
  93. style: 'solide',
  94. },
  95. },
  96. // #ifndef MP-WEIXIN
  97. {
  98. name: 'qrcode',
  99. type: 'qrcode',
  100. val: poster.shareInfo.link,
  101. x: width * 0.75,
  102. y: width * 1.3,
  103. size: width * 0.2,
  104. },
  105. // #endif
  106. // #ifdef MP-WEIXIN
  107. {
  108. name: 'wxacode',
  109. type: 'image',
  110. val: wxa_qrcode,
  111. x: width * 0.75,
  112. y: width * 1.3,
  113. width: width * 0.2,
  114. height: width * 0.2,
  115. },
  116. // #endif
  117. ],
  118. };
  119. };
  120. export default goods;