小程序二维码推广

master
tping 3 years ago
parent 4bd677bf83
commit f3dcbcf0b4

@ -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;
}
}

@ -20,6 +20,7 @@
<tr class="odd">
<th>ID</th>
<th>推广链接地址</th>
<th>推广链接短地址</th>
<th>添加人员</th>
<th>添加时间</th>
<th>二维码</th>
@ -32,6 +33,7 @@
<tr data-id="{$record.id}">
<td>{$record.id}</td>
<td>{$record.h5_link}</td>
<td>{$record.short_link}</td>
<td>{$record.admin_name}</td>
<td>{$record.create_time|date='Y-m-d H:i:s', ###}</td>
<td><img src="{$record.qrcode_img}" style="height: 100px;"/></td>

Loading…
Cancel
Save