user.js 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  1. import sheep from '@/sheep';
  2. import { formatImageUrlProtocol } from './index';
  3. async function getImagePath(imagePath) {
  4. return new Promise((resolve, reject) => {
  5. // #ifdef MP-WEIXIN
  6. console.log(imagePath);
  7. wx.getImageInfo({
  8. src: imagePath,
  9. success: (res) => {
  10. resolve(res.path);
  11. },
  12. fail: (err) => {
  13. reject(err);
  14. }
  15. });
  16. // #endif
  17. // #ifndef MP-WEIXIN
  18. const fullPath = window.location.origin + imagePath;
  19. resolve(fullPath);
  20. // #endif
  21. });
  22. }
  23. const user = async (poster) => {
  24. console.log("poster", poster)
  25. const width = poster.width;
  26. const userInfo = sheep.$store('user').userInfo;
  27. return {
  28. background: await getImagePath('/static/user-poster-bg.jpg'),
  29. // background: window.location.origin + '/static/user-poster-bg.jpg',
  30. list: [
  31. {
  32. name: 'nickname',
  33. type: 'text',
  34. val: userInfo.nickname,
  35. x: width / 2,
  36. y: width * 0.4,
  37. paintbrushProps: {
  38. textAlign: 'center',
  39. fillStyle: '#333',
  40. font: {
  41. fontSize: 14,
  42. fontFamily: 'sans-serif',
  43. },
  44. },
  45. },
  46. {
  47. name: 'linkId',
  48. type: 'text',
  49. val: "邀请码:" + poster.shareInfo.linkId,
  50. x: width / 2,
  51. y: width * 0.65,
  52. paintbrushProps: {
  53. textAlign: 'center',
  54. fillStyle: '#333',
  55. font: {
  56. fontSize: 20,
  57. fontFamily: 'sans-serif',
  58. },
  59. },
  60. },
  61. {
  62. name: 'avatar',
  63. type: 'image',
  64. val: poster.avatar,
  65. x: width * 0.4,
  66. y: width * 0.16,
  67. width: width * 0.2,
  68. height: width * 0.2,
  69. d: width * 0.2,
  70. },
  71. // #ifndef MP-WEIXIN
  72. {
  73. name: 'qrcode',
  74. type: 'qrcode',
  75. val: poster.shareInfo.link,
  76. x: width * 0.35,
  77. y: width * 0.74,
  78. size: width * 0.3,
  79. },
  80. // #endif
  81. // #ifdef MP-WEIXIN
  82. {
  83. name: 'wxacode',
  84. type: 'image',
  85. val: sheep.$api.third.wechat.getWxacode(poster.shareInfo.path),
  86. x: width * 0.35,
  87. y: width * 0.84,
  88. width: width * 0.3,
  89. height: width * 0.3,
  90. },
  91. // #endif
  92. ],
  93. };
  94. };
  95. export default user;