goods.js 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131
  1. "use strict";
  2. const common_vendor = require("../../../../../common/vendor.js");
  3. const sheep_index = require("../../../../index.js");
  4. require("./index.js");
  5. async function getImagePath(imagePath) {
  6. return new Promise((resolve, reject) => {
  7. common_vendor.wx$1.getImageInfo({
  8. src: imagePath,
  9. success: (res) => {
  10. resolve(res.path);
  11. },
  12. fail: (err) => {
  13. reject(err);
  14. }
  15. });
  16. });
  17. }
  18. const goods = async (poster) => {
  19. const width = poster.width;
  20. const userInfo = sheep_index.sheep.$store("user").userInfo;
  21. return {
  22. background: await getImagePath("/static/goods-poster-bg.jpg"),
  23. list: [
  24. {
  25. name: "nickname",
  26. type: "text",
  27. val: userInfo.nickname,
  28. x: width * 0.21,
  29. y: width * 0.06,
  30. paintbrushProps: {
  31. fillStyle: "#333",
  32. font: {
  33. fontSize: 16,
  34. fontFamily: "sans-serif"
  35. }
  36. }
  37. },
  38. {
  39. name: "avatar",
  40. type: "image",
  41. val: poster.avatar,
  42. x: width * 0.04,
  43. y: width * 0.04,
  44. width: width * 0.14,
  45. height: width * 0.14,
  46. d: width * 0.14
  47. },
  48. {
  49. name: "goodsBg",
  50. type: "rect",
  51. x: width * 0.03,
  52. y: width * 0.3,
  53. width: width * 0.94,
  54. height: width * 0.75,
  55. r: 5
  56. },
  57. {
  58. name: "goodsImage",
  59. type: "image",
  60. val: poster.shareInfo.poster.image,
  61. x: width * 0.03,
  62. y: width * 0.3,
  63. width: width * 0.94,
  64. height: width * 0.5,
  65. r: 5
  66. },
  67. {
  68. name: "goodsTitle",
  69. type: "text",
  70. val: poster.shareInfo.poster.title,
  71. x: width * 0.05,
  72. y: width * 0.83,
  73. maxWidth: width * 0.91,
  74. line: 5,
  75. lineHeight: 10,
  76. paintbrushProps: {
  77. fillStyle: "#333",
  78. font: {
  79. fontSize: 16
  80. }
  81. }
  82. },
  83. {
  84. name: "goodsIntroduction",
  85. type: "text",
  86. val: poster.shareInfo.poster.introduction,
  87. x: width * 0.05,
  88. y: width * 0.89,
  89. maxWidth: width * 0.9,
  90. height: width * 0.1,
  91. line: 3,
  92. lineHeight: 4,
  93. paintbrushProps: {
  94. fillStyle: "#333",
  95. font: {
  96. fontSize: 12,
  97. fontFamily: "OPPOSANS"
  98. }
  99. }
  100. },
  101. {
  102. name: "goodsOriginalPrice",
  103. type: "text",
  104. val: poster.shareInfo.poster.original_price > 0 ? "¥" + poster.shareInfo.poster.original_price : "",
  105. x: width * 0.3,
  106. y: width * 1.32,
  107. paintbrushProps: {
  108. fillStyle: "#999",
  109. font: {
  110. fontSize: 10,
  111. fontFamily: "OPPOSANS"
  112. }
  113. },
  114. textDecoration: {
  115. line: "line-through",
  116. style: "solide"
  117. }
  118. },
  119. {
  120. name: "wxacode",
  121. type: "image",
  122. val: sheep_index.sheep.$api.third.wechat.getWxacode(poster.shareInfo.path),
  123. x: width * 0.75,
  124. y: width * 1.3,
  125. width: width * 0.2,
  126. height: width * 0.2
  127. }
  128. ]
  129. };
  130. };
  131. exports.goods = goods;