Index.php
2.8 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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
<?php
namespace app\index\controller;
use addons\qrcode\Qrcode;
use app\common\controller\Frontend;
use think\Db;
use app\api\controller\Excel;
class Index extends Frontend
{
protected $noNeedLogin = '*';
protected $noNeedRight = '*';
protected $layout = '';
public function index()
{
//header("Location:https://lx.bqh.ynzhsk.cn/app/jg");
exit();
$where = [
"app_type" => "jianguan",
"status" => "1"
];
$version = Db::name("appversion")
->where($where)
->order("version desc")
->find();
if (!empty($version['images'])) {
$imgarr = explode(',', $version['images']);
$version['images'] = full_image($imgarr);
}
//生成二维码
// $url = isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] === 'on' ? "https" : "http";
// $url .= "://" . $_SERVER['HTTP_HOST'];
// $url .= $_SERVER['REQUEST_URI'];
//
// $url = $url . '/app/jg/index';
// $qrcode_img = addon_url('qrcode/index/build', ['text' => $url]);
// $version['qrcode_img'] = $qrcode_img;
$this->view->assign("version", $version);
return $this->view->fetch('indexjg');
}
public function test()
{
$number = 100000;
$min = 0;
$max = 1;
$total = 0;
for ($i = 0; $i < $number; $i++) {
$num = $min + mt_rand() / mt_getrandmax() * ($max - $min);
$res = sprintf("%.10f", $num); //控制小数后几位
if ($res <= 0.0000010207) {
echo '有' . $res . '</br>';
} else {
echo '没有' . $res . '</br>';
}
if ($res <= 0.000001) {
$total++;
}
}
echo $total;
}
public function apptoken()
{
$appid = 'wx5488f94eb1c0bded';
$secret = 'db6ac40041ecf6c7447620392ce59357';
$url = "https://api.weixin.qq.com/cgi-bin/token?grant_type=client_credential&appid=$appid&secret=$secret";
$res = json_decode(file_get_contents($url), true);
Db::name('weixin_apptoken')->where('id', '=', 1)->update(['token' => $res['access_token']]);
}
//变更模板消息状态
public function updateWxtemplate()
{
$code = input('get.code');
$openid = input('get.openid');
if (!$code || !$openid) {
$this->error('非法操作', '');
} else {
$res = Db::name('inspection_wxtemplatelog')->where('openid', '=', $openid)->where('code', '=', $code)->update(['status' => '1']);
if ($res) {
$this->success('告警接收成功', '');
} else {
$this->error('非法操作2', '');
}
}
}
}