RoutineCode.php 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. <?php
  2. namespace app\models\routine;
  3. use crmeb\services\MiniProgramService;
  4. /**
  5. * TODO 小程序二维码Model
  6. * Class RoutineCode
  7. * @package app\models\routine
  8. */
  9. class RoutineCode
  10. {
  11. /**
  12. * TODO 获取小程序二维码
  13. * @param $thirdId
  14. * @param $thirdType
  15. * @param $page
  16. * @param $imgUrl
  17. * @return array|bool
  18. * @throws \think\Exception
  19. * @throws \think\db\exception\DataNotFoundException
  20. * @throws \think\db\exception\ModelNotFoundException
  21. * @throws \think\exception\DbException
  22. */
  23. public static function getShareCode($thirdId, $thirdType, $page, $imgUrl)
  24. {
  25. $res = RoutineQrcode::routineQrCodeForever($thirdId, $thirdType, $page, $imgUrl);
  26. $resCode = MiniProgramService::qrcodeService()->appCodeUnlimit($res->id, $page, 280);
  27. if ($resCode) {
  28. if ($res) return ['res' => $resCode, 'id' => $res->id];
  29. else return false;
  30. } else return false;
  31. }
  32. /**
  33. * TODO 获取小程序页面带参数二维码不保存数据库
  34. * @param string $page
  35. * @param string $pramam
  36. * @param int $width
  37. * @return mixed
  38. */
  39. public static function getPageCode($page = '', $pramam = "?uid=1&product=1", $width = 280)
  40. {
  41. return MiniProgramService::qrcodeService()->appCodeUnlimit($pramam, $page, $width);
  42. }
  43. }