Here can call a Jq-qrcode library, and then according to the parameters to the inside of the content can be, I was doing is a business card system, so can generate a VCF file on the PC side.
For specific project documents, see: Https://github.com/marhovey/QRcode;
Jq-qrcode Direct access: Https://github.com/jeromeetienne/jquery-qrcode;
1. Generate Business card QR code:
function createvcf () {
$ (". Qrbox"). CSS ({display: "block"});
var A,
c = $ ("#name"). html (). ReplaceAll ("", ""),
D = $ ("#title"). html (). ReplaceAll ("", ""),
E = $ ("#adr"). html (). ReplaceAll ("", ""),
F = $ ("#org"). html (). ReplaceAll ("", ""),
g = $ ("#cell"). html (). ReplaceAll ("", ""),
H = $ ("#home"). html (). ReplaceAll ("", ""),
i = $ ("#url"). html (). ReplaceAll ("", ""),
J = $ ("#email"). html (). ReplaceAll ("", "");
E=e.slice (0,e.search ("A = "Begin:vcard", A + = "\r\nn:" + C, D && (A + = "\r\ntitle:" + D), e && (A + = "\R\NADR; work:;; "+ E +";;;; "), F && (A + =" \r\norg: "+ f), G && (A + =" \r\ntel; Cell,voice: "+ g), H && (A + =" \r\ntel; Work,voice: "+ h), I && (a + =" \r\nurl; Work: "+ i", J && (A + = "\r\nemail;internet,home:" + j), A + = "\r\nend:vcard", $ ("#qrcode"). Empty (). QRCode ({
Render: "Image",
Eclevel: "0" = = $ ("#mode"). Val ()? "L": "H",
SIZE:300,
Background: "#fff",
Fill: $ ("#fill"). Val (),
Radius: $ ("#radius"). Val (),
Mode:1 * $ ("#mode"). Val (),
FontColor: $ ("#fontcolor"). Val (),
LABEL:C,
Text:a
})
}
String.prototype.replaceAll = function (A, b) {
Return This.replace (New RegExp (A.replace (/([\ (\) \[\]\{\}\^\$\+\-\*\?\.\ "\ ' \|\/\\])/g," \\$1 ")," IG "), B)
};
document.getElementById (' btn '). Onclick=function () {
CREATEVCF ();
}
2, generate the domain name QR code:
(function () {
' Use strict ';
var jq = window.jquery;
var guivaluepairs = [
[' Size ', ' px '],
[' MinVersion ', '],
[' quiet ', ' modules '],
[' radius ', '% '],
[' msize ', '% '],
[' mposx ', '% '],
[' mposy ', '% ']
];
function Updategui () {
Jq.each (Guivaluepairs, function (idx, pair) {
var $label = JQ (' label[for= ' + pair[0] + ' "] ');
$label. Text ($label. Text (). replace (/:.*/, ': ' + JQ (' # ' + pair[0]). val () + pair[1]);
});
}
function Updateqrcode () {
var options = {
Render: "Image",
Eclevel: "H",
Minversion:parseint ("1", 10),
Fill: "#333",
Background: "#fff",
Text:document. Url
Size
Size:parseint ("150", 10),
Radius:parseint ("0", 10) * 0.01,
Quiet:parseint ("1", 10),
Mode:parseint ("0", 10),
IMAGE:JQ (' #img-buffer ') [0]
};
JQ (' #erwm '). Empty (). QRCode (options);
}
function Update () {
Updategui ();
Updateqrcode ();
}
function Onimageinput () {
var input = JQ (' #image ') [0];
if (Input.files && input.files[0]) {
var reader = new FileReader ();
Reader.onload = function (event) {
JQ (' #img-buffer '). attr (' src ', event.target.result);
JQ (' #mode '). Val (' 4 ');
SetTimeout (update, 250);
};
Reader.readasdataurl (Input.files[0]);
}
}
function init () {
JQ (' #image '). On (' Change ', onimageinput);
JQ (window). Load (update);
Update ();
}
JQ (init);
}());
3. Generate the VCF file:
<?php
Header ("content-type:text/html; Charset=utf-8 ");
$name =$_post["name"];
$title =$_post["title"];
$adr =$_post["ADR"];
$org =$_post["org"];
$cell =$_post["Cell"];
$home =$_post["Home"];
$url =$_post["url"];
$email =$_post["email"];
$myfile =fopen ("INDEX.VCF", "w");
$txt = "begin:vcard\r\n". " N: ". $name." \r\norg: ". $org." \r\ntitle: ". $title." \r\nadr; Type=work:;; ". $adr. " \r\ntel; Type=cell,voice: ". $cell." \r\ntel; Type=work,voice: ". $home." \r\nemail; Type=pref,internet: ". $email." \r\nend:vcard ";
Fwrite ($myfile, $txt);
Fclose (myfile);
?>
jquery Two-dimensional code