二維碼活碼管理系統

二維碼活碼管理系統

圖片描述

什麼是活碼?

二維碼生成後,二維碼圖案不變,內容可隨時變動,極大提升營銷效率,配合美術設計二維碼能力大大提高.
而且能夠作到實時統計二維碼掃描數據,傳播效果一目瞭然;根據地域、網絡、設備等多維度分析數據,提高管理效率.php

二維碼的活碼的技術實現本質是什麼?

二維碼活碼團主要存儲一個固定的 php 路徑及碼的 id,掃描二維碼後,服務根據請求內容從數據庫中查找二維碼的信息,做跳轉並記錄訪問信息.html

系統技術

圖片描述

重點技術

1.使用插件繪製二維碼mysql

// https://github.com/jeromeetienne/jquery-qrcode
// js

function paint(url, ele) {      
    outputQRCod(url, 200, 200);           //轉換中文字符串
    function toUtf8(str) {
        var out, i, len, c;
        out = "";
        len = str.length;
        for (i = 0; i < len; i++) {
            c = str.charCodeAt(i);
            if ((c >= 0x0001) && (c <= 0x007F)) {
                out += str.charAt(i);
            } else if (c > 0x07FF) {
                out += String.fromCharCode(0xE0 | ((c >> 12) & 0x0F));
                out += String.fromCharCode(0x80 | ((c >> 6) & 0x3F));
                out += String.fromCharCode(0x80 | ((c >> 0) & 0x3F));
            } else {
                out += String.fromCharCode(0xC0 | ((c >> 6) & 0x1F));
                out += String.fromCharCode(0x80 | ((c >> 0) & 0x3F));
            }
        }
        return out;
    }

    //生成二維碼
    function outputQRCod(txt, width, height) {
        //先清空
        $(ele).empty();
        //中文格式轉換
        var str = toUtf8(txt);
        //生成二維碼
        $(ele).qrcode({
            render: "canvas", //canvas和table兩種渲染方式
            width: width,
            height: height,
            text: str
        });
    }
}

2.使用 php 跳轉頁面jquery

//php

header("Access-Control-Allow-Origin: *");
$id = isset($_GET["id"]) ? $_GET["id"] : '';
// 連主庫
$conn = mysqli_connect('w.rdc.sae.sina.com.cn' . ':' . '3306', 'aaa', 'bbb', 'ccc');
// Check connection
if ($conn->connect_error) {
    die("鏈接失敗: " . $conn->connect_error);
}
$sql = "SELECT * FROM `2code_code` WHERE id = '" . $id . "'";
$result = $conn->query($sql);
if (mysqli_num_rows($result) > 0) {
    while ($row = mysqli_fetch_assoc($result)) {
        if (!strpos($row["content"], "//")) {
            $k = "//" . $row["content"];
        } else {
            $k = $row["content"];
        }
        $v=$row["num"]+1;
$sql = "UPDATE `app_jxjweb`.`2code_code` SET `num` = '".$v."' WHERE `2code_code`.`id` = '".$id."'";
$result2 = $conn->query($sql);
        Header("HTTP/1.1 303 See Other");
        Header("Location: $k");
    }
} else {
    exit('錯誤路徑!');
}

效果演示:

點擊git

帳號: jxj2991
密碼: 666666github

完整代碼:

githubweb

相關文章
相關標籤/搜索