小程序二维码推广

master
tping 4 years ago
parent cb343d7a8d
commit 8ebfe4a2a9

@ -17,29 +17,56 @@ class JumpController extends HomeController
public function getURLScheme() public function getURLScheme()
{ {
$id = I('request.id', 0);
$url = "https://api.weixin.qq.com/wxa/generatescheme?access_token=".$this->getAccessToken(); $url = "https://api.weixin.qq.com/wxa/generatescheme?access_token=".$this->getAccessToken();
$data = [ $data = [
'jump_wxa' => [ 'jump_wxa' => [
'path' => '/pages/share/share', 'path' => '/pages/index/index',
'query' => 'id=3' 'query' => "id={$id}"
], ],
'is_expire' => false, 'is_expire' => true,
"expire_time" => 1606737600 "expire_time" => time() + 86400
]; ];
$ret = curl_post($url, json_encode($data)); $ret = $this->curl_post($url, json_encode($data));
echo $ret; echo $ret;
} }
public function curl_post($url, $post_data = '', $timeout = 3000)
{
header("Content-type:text/html;charset=utf-8");
$ch = curl_init();
curl_setopt ($ch, CURLOPT_URL, $url);
curl_setopt ($ch, CURLOPT_POST, 1);
curl_setopt ($ch, CURLOPT_POSTFIELDS, $post_data);
curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt ($ch, CURLOPT_CONNECTTIMEOUT, $timeout);
curl_setopt($ch, CURLOPT_HEADER, false);
$file_contents = curl_exec($ch);
curl_close($ch);
return $file_contents;
}
public function jumpMp() { public function jumpMp() {
$id = I('request.id', 0);
$this->assign("id", $id);
$this->display(); $this->display();
} }
// MiniTop 二维码推广 // MiniTop 二维码推广
public function getImgs() public function getImgs()
{ {
$backgroundImg = 'http://'.$_SERVER['HTTP_HOST']."/Public/Qrcode/images/b.png";
$qrCodeImg = 'http://'.$_SERVER['HTTP_HOST']."/Public/Qrcode/images/qrcode.png";
$id = I('request.id', 0); $id = I('request.id', 0);
if (!$id || !is_numeric($id)) {
$this->ajaxReturn([
'status' => 1,
'background_img' => $backgroundImg,
'qrcode_img' => $qrCodeImg
]);
}
// 二维码 // 二维码
$qrcodePromotionList = M('qrcode_promotion_list', 'tab_')->where(['id' => $id])->find(); $qrcodePromotionList = M('qrcode_promotion_list', 'tab_')->where(['id' => $id])->find();

@ -119,10 +119,13 @@
$.ajax({ $.ajax({
dataType: 'json', dataType: 'json',
type: 'POST', type: 'POST',
url: 'http://10.0.10.185:8089/index.php?s=/Qrcode/Jump/getURLScheme', //url: 'http://10.0.10.185:8089/index.php?s=/Qrcode/Jump/getURLScheme',
data: [], url: 'https://mg.wmtxkj.cn/index.php?s=/Qrcode/Jump/getURLScheme',
data: {
'id': "{$id}",
},
success: function(data){ success: function(data){
alert(data.openlink); return ;
window.location.href = data.openlink; window.location.href = data.openlink;
}, },
}); });
@ -194,7 +197,7 @@
<body> <body>
<div class="page full"> <div class="page full">
<div id="public-web-container" class="hidden"> <div id="public-web-container" class="hidden">
<p class="">11111111正在打开 “填入你的小程序名称”...</p> <!-- replace --> <p class="">正在打开 “2”...</p> <!-- replace -->
<a id="public-web-jump-button" href="javascript:" class="weui-btn weui-btn_primary weui-btn_loading" onclick="jumpToMp()"> <a id="public-web-jump-button" href="javascript:" class="weui-btn weui-btn_primary weui-btn_loading" onclick="jumpToMp()">
<!--<span id="public-web-jump-button-loading" class="weui-primary-loading weui-primary-loading_transparent"><i class="weui-primary-loading__dot"></i></span> <!--<span id="public-web-jump-button-loading" class="weui-primary-loading weui-primary-loading_transparent"><i class="weui-primary-loading__dot"></i></span>
-->打开小程序 -->打开小程序

Loading…
Cancel
Save