ContactQrcodeController.class.php
1.68 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
<?php
/**
* Created by PhpStorm.
* User: liyifei2012it
* Date: 16/10/11
* Time: 11:54
*/
namespace Frontend\Controller\Index;
use Com\QRcode;
use Common\Common\Cache;
use Common\Common\User;
class ContactQrcodeController extends AbstractController
{
protected $_require_login = false;
/**
* 保存通讯录信息的二维码
* @author liyifei
*/
public function Index()
{
$uid = I('get.uid', '', 'trim');
$getMobile = I('get.mobile', '', 'trim');
$getEmail = I('get.email', '', 'trim');
// 用户信息(从缓存架构用户信息表中的数据获取用户信息,参数设为true越过缓存)
$userServ = new User();
$user = $userServ->getByUid($uid);
// 姓名
$username = $user['memUsername'];
// 移动电话
$mobile = empty($getMobile) ? $user['memMobile'] : $getMobile;
// 电子邮箱
$email = empty($getEmail) ? $user['memEmail'] : $getEmail;
// 头像
$face = $user['memFace'];
// 企业信息
$ep = Cache::instance()->get(
'Common.EnterpriseDetail',
'',
['expire' => cfg('ENTERPRISE_DETAIL_CACHE_EXPIRE')]
);
// 组织
$appName = $ep['epName'];
// url地址组装(固定格式)
$url = "BEGIN:VCARD
N:{$username}
ORG:{$appName}
TEL;CELL:{$mobile}
EMAIL;WORK:{$email}
END:VCARD";
// 生成二维码
$qrcode = QRcode::png($url, false, QR_ECLEVEL_L, 12, 1);
header('Content-Type: image/png');
imagepng($qrcode);
exit();
}
}