|
|
|
@ -15,8 +15,10 @@ namespace app\api\controller; |
|
|
|
|
use app\api\model\{Goods as GoodsModel, Store as StoreModel}; |
|
|
|
|
use app\api\model\Region; |
|
|
|
|
use app\api\service\{Goods as GoodsService, User as UserService}; |
|
|
|
|
use app\common\library\wechat\ShortLink; |
|
|
|
|
use app\common\model\GoodsImage as GoodsImageModel; |
|
|
|
|
use app\common\model\UploadFile as UploadFileModel; |
|
|
|
|
use app\common\model\wxapp\Setting as WxappSettingModel; |
|
|
|
|
use app\common\service\qrcode\Goods as GoodsPoster; |
|
|
|
|
use cores\exception\BaseException; |
|
|
|
|
use think\db\exception\DbException; |
|
|
|
@ -383,5 +385,22 @@ class Goods extends Controller |
|
|
|
|
return $this->renderSuccess(['imageUrl' => $Qrcode->getImage()]); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public function shortUrl(): Json |
|
|
|
|
{ |
|
|
|
|
$page_url = $this->request->post('page_url'); |
|
|
|
|
if (empty($page_url)) { |
|
|
|
|
return $this->renderError('缺少参数page_url'); |
|
|
|
|
} |
|
|
|
|
$page_title = $this->request->post('page_title'); |
|
|
|
|
if (empty($page_title)) { |
|
|
|
|
return $this->renderError('缺少参数page_title'); |
|
|
|
|
} |
|
|
|
|
$store_id = GoodsModel::$storeId; |
|
|
|
|
$wxConfig = WxappSettingModel::getConfigBasic($store_id); |
|
|
|
|
// 请求api获取短连接 |
|
|
|
|
$link_obj = new ShortLink($wxConfig['app_id'], $wxConfig['app_secret']); |
|
|
|
|
$url = $link_obj->shortUrl($page_url, $page_title); |
|
|
|
|
return $this->renderSuccess(['url' => $url]); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|