user.js 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. import sheep from '@/sheep';
  2. import { formatImageUrlProtocol, getWxaQrcode } from './index';
  3. const user = async (poster) => {
  4. const width = poster.width;
  5. const userInfo = sheep.$store('user').userInfo;
  6. const wxa_qrcode = await getWxaQrcode(poster.shareInfo.path, poster.shareInfo.query);
  7. return [
  8. {
  9. type: 'image',
  10. src: formatImageUrlProtocol(sheep.$url.cdn(sheep.$store('app').platform.share.posterInfo.user_bg)),
  11. css: {
  12. width,
  13. position: 'fixed',
  14. 'object-fit': 'contain',
  15. top: '0',
  16. left: '0',
  17. zIndex: -1,
  18. },
  19. },
  20. {
  21. type: 'text',
  22. text: userInfo.nickname,
  23. css: {
  24. color: '#333',
  25. fontSize: 14,
  26. textAlign: 'center',
  27. fontFamily: 'sans-serif',
  28. position: 'fixed',
  29. top: width * 0.4,
  30. left: width / 2,
  31. },
  32. },
  33. {
  34. type: 'image',
  35. src: formatImageUrlProtocol(sheep.$url.cdn(userInfo.avatar)),
  36. css: {
  37. position: 'fixed',
  38. left: width * 0.4,
  39. top: width * 0.16,
  40. width: width * 0.2,
  41. height: width * 0.2,
  42. },
  43. },
  44. // #ifndef MP-WEIXIN
  45. {
  46. type: 'qrcode',
  47. text: poster.shareInfo.link,
  48. css: {
  49. position: 'fixed',
  50. left: width * 0.35,
  51. top: width * 0.84,
  52. width: width * 0.3,
  53. height: width * 0.3,
  54. },
  55. },
  56. // #endif
  57. // #ifdef MP-WEIXIN
  58. {
  59. type: 'image',
  60. src: wxa_qrcode,
  61. css: {
  62. position: 'fixed',
  63. left: width * 0.35,
  64. top: width * 0.84,
  65. width: width * 0.3,
  66. height: width * 0.3,
  67. },
  68. },
  69. // #endif
  70. ];
  71. };
  72. export default user;