qrcode.js 1.7 KB

1234567891011121314151617181920212223242526272829303132
  1. import request from '@/utils/request'
  2. // 获取不限制的小程序码
  3. export function getUnlimitedQRCode(data = {}) {
  4. // 从本地存储获取用户类型和用户ID
  5. const userType = uni.getStorageSync('userType') || 1;
  6. const userId = uni.getStorageSync('userId') || '';
  7. const version = data.version || '';
  8. // 打印日志,便于调试
  9. console.log('从本地存储获取用户信息:', { userType, userId, version });
  10. return request({
  11. url: '/core/InviteUser/getInviteQrCode',
  12. method: 'get',
  13. params: {
  14. // scene: data.scene, // 最大32个可见字符,只支持数字,大小写英文以及部分特殊字符
  15. // page: data.page, // 默认是主页,页面 page,例如 pages/index/index
  16. // check_path: data.check_path || true, // 默认是true,检查page 是否存在
  17. // env_version: data.env_version || 'release', // 要打开的小程序版本。正式版为 "release",体验版为 "trial",开发版为 "develop"
  18. // width: data.width || 430, // 二维码的宽度,单位 px,最小 280px,最大 1280px
  19. // auto_color: data.auto_color || false, // 自动配置线条颜色
  20. // line_color: data.line_color || { r: 0, g: 0, b: 0 }, // 使用 rgb 设置颜色
  21. // is_hyaline: data.is_hyaline || false, // 是否需要透明底色
  22. referrerType: userType, // 使用本地存储的 userType
  23. referrerId: userId, // 使用本地存储的 userId
  24. page:'pages/login',
  25. scene: data.scene || (version ? `${userType}:${userId}:${version}` : `${userType}:${userId}`), // 只有当版本号存在时才添加到scene
  26. },
  27. responseType: 'arraybuffer', // 设置响应类型为arraybuffer,因为返回的是图片二进制内容
  28. })
  29. }