user.js 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  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. console.log(imagePath);
  8. common_vendor.wx$1.getImageInfo({
  9. src: imagePath,
  10. success: (res) => {
  11. resolve(res.path);
  12. },
  13. fail: (err) => {
  14. reject(err);
  15. }
  16. });
  17. });
  18. }
  19. const user = async (poster) => {
  20. const width = poster.width;
  21. const userInfo = sheep_index.sheep.$store("user").userInfo;
  22. return {
  23. background: await getImagePath("/static/user-poster-bg.jpg"),
  24. // background: window.location.origin + '/static/user-poster-bg.jpg',
  25. list: [
  26. {
  27. name: "nickname",
  28. type: "text",
  29. val: userInfo.nickname,
  30. x: width / 2,
  31. y: width * 0.4,
  32. paintbrushProps: {
  33. textAlign: "center",
  34. fillStyle: "#333",
  35. font: {
  36. fontSize: 14,
  37. fontFamily: "sans-serif"
  38. }
  39. }
  40. },
  41. {
  42. name: "avatar",
  43. type: "image",
  44. val: poster.avatar,
  45. x: width * 0.4,
  46. y: width * 0.16,
  47. width: width * 0.2,
  48. height: width * 0.2,
  49. d: width * 0.2
  50. },
  51. {
  52. name: "wxacode",
  53. type: "image",
  54. val: sheep_index.sheep.$api.third.wechat.getWxacode(poster.shareInfo.path),
  55. x: width * 0.35,
  56. y: width * 0.84,
  57. width: width * 0.3,
  58. height: width * 0.3
  59. }
  60. ]
  61. };
  62. };
  63. exports.user = user;