RoutineCode.php 1.7 KB

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