index.js 1003 B

123456789101112131415161718192021222324252627282930313233343536373839
  1. import user from './user';
  2. import goods from './goods';
  3. import groupon from './groupon';
  4. import SocialApi from '@/sheep/api/member/social';
  5. export function getPosterData(options) {
  6. switch (options.shareInfo.poster.type) {
  7. case 'user':
  8. return user(options);
  9. case 'goods':
  10. return goods(options);
  11. case 'groupon':
  12. return groupon(options);
  13. }
  14. }
  15. export function formatImageUrlProtocol(url) {
  16. // #ifdef H5
  17. // H5平台 https协议下需要转换
  18. if (window.location.protocol === 'https:' && url.indexOf('http:') === 0) {
  19. url = url.replace('http:', 'https:');
  20. }
  21. // #endif
  22. // #ifdef MP-WEIXIN
  23. // 小程序平台 需要强制转换为https协议
  24. if (url.indexOf('http:') === 0) {
  25. url = url.replace('http:', 'https:');
  26. }
  27. // #endif
  28. return url;
  29. }
  30. // 获得微信小程序码 (Base64 image)
  31. export async function getWxaQrcode(path, query) {
  32. const res = await SocialApi.getWxaQrcode(path, query);
  33. return 'data:image/png;base64,' + res.data;
  34. }