<?php namespace app\models\routine; use crmeb\services\MiniProgramService; use think\db\exception\DataNotFoundException; use think\db\exception\DbException; use think\db\exception\ModelNotFoundException; use think\Exception; /** * TODO 小程序二维码Model * Class RoutineCode * @package app\models\routine */ class RoutineCode { /** * TODO 获取小程序二维码 * @param $thirdId * @param $thirdType * @param $page * @param $imgUrl * @param bool $mer_id * @return array|bool * @throws DataNotFoundException * @throws DbException * @throws Exception * @throws ModelNotFoundException */ public static function getShareCode($thirdId, $thirdType, $page, $imgUrl, $mer_id = false) { $res = RoutineQrcode::routineQrCodeForever($thirdId, $thirdType, $page, $imgUrl); $result = RoutineQrcode::get($res->id); $resCode = MiniProgramService::qrcodeService($mer_id)->appCodeUnlimit($result['third_id'], $page, 280); if ($resCode) { if ($res) return ['res' => $resCode, 'id' => $res->id]; else return false; } else return false; } /** * TODO 获取小程序页面带参数二维码不保存数据库 * @param string $page * @param string $pramam * @param int $width * @param bool $mer_id * @return mixed * @throws DataNotFoundException * @throws DbException * @throws Exception * @throws ModelNotFoundException */ public static function getPageCode($page = '', $pramam = "", $width = 280, $mer_id = false) { return MiniProgramService::qrcodeService($mer_id)->appCodeUnlimit($pramam, $page, $width); } }