index.js 749 B

1234567891011121314151617181920212223242526272829303132
  1. import user from './user';
  2. import goods from './goods';
  3. import groupon from './groupon';
  4. export function getPosterData(options) {
  5. switch (options.shareInfo.poster.type) {
  6. case 'user':
  7. return user(options);
  8. case 'goods':
  9. return goods(options);
  10. case 'groupon':
  11. return groupon(options);
  12. }
  13. }
  14. export function formatImageUrlProtocol(url) {
  15. // #ifdef H5
  16. // H5平台 https协议下需要转换
  17. if (window.location.protocol === 'https:' && url.indexOf('http:') === 0) {
  18. url = url.replace('http:', 'https:');
  19. }
  20. // #endif
  21. // #ifdef MP-WEIXIN
  22. // 小程序平台 需要强制转换为https协议
  23. if (url.indexOf('http:') === 0) {
  24. url = url.replace('http:', 'https:');
  25. }
  26. // #endif
  27. return url;
  28. }