goods.js 2.8 KB

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