|
|
|
@ -170,14 +170,21 @@ class QrCodePromotionController extends BaseController
|
|
|
|
|
'qp_id' => $params['id'],
|
|
|
|
|
'admin_id' => $loginer['id'],
|
|
|
|
|
'admin_name' => $loginer['account'],
|
|
|
|
|
'h5_link' => "",
|
|
|
|
|
'h5_link' => '',
|
|
|
|
|
'short_link' => '',
|
|
|
|
|
'create_time' => time(),
|
|
|
|
|
'status' => 0,
|
|
|
|
|
'qrcode_img' => $params['img'],
|
|
|
|
|
]);
|
|
|
|
|
if ($id > 0) {
|
|
|
|
|
$h5Link = ($isHttps? 'https://': 'http://').$_SERVER['HTTP_HOST']."index.php?s=/Qrcode/Jump/jumpMp/id/{$id}";
|
|
|
|
|
M('qrcode_promotion_list', 'tab_')->where(['id' => $id])->save(['h5_link' => $h5Link]);
|
|
|
|
|
$h5Link = ($isHttps? 'https://': 'http://').$_SERVER['HTTP_HOST']."/index.php?s=/Qrcode/Jump/jumpMp/id/{$id}";
|
|
|
|
|
$expireDate = date('Y-m-d', strtotime("+30 day"));
|
|
|
|
|
$shortLink = $this->getShortUrl($h5Link, $expireDate);
|
|
|
|
|
|
|
|
|
|
M('qrcode_promotion_list', 'tab_')->where(['id' => $id])->save([
|
|
|
|
|
'h5_link' => $h5Link,
|
|
|
|
|
'short_link' => $shortLink
|
|
|
|
|
]);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$this->ajaxReturn(['status' => 1, 'message' => '保存成功!']);
|
|
|
|
@ -222,4 +229,23 @@ class QrCodePromotionController extends BaseController
|
|
|
|
|
$this->display();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function getShortUrl($long_url, $expire_date)
|
|
|
|
|
{
|
|
|
|
|
$url = urlencode($long_url);
|
|
|
|
|
$key = "612a01db7889bec5e0d0d2d81f@df6cdda6eb39c505f08848f714b0433e";
|
|
|
|
|
$request_url = "http://api.3w.cn/api.htm?format=json&url={$url}&key={$key}&expireDate={$expire_date}&domain=0";
|
|
|
|
|
$result_str = file_get_contents($request_url);
|
|
|
|
|
|
|
|
|
|
$url = "";
|
|
|
|
|
if ($result_str) {
|
|
|
|
|
$result_arr = json_decode($result_str, true);
|
|
|
|
|
|
|
|
|
|
if ($result_arr && $result_arr['code'] == "0") {
|
|
|
|
|
$url = $result_arr['url'];
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return $url;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|