Sms.php
1.4 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
<?php
namespace app\notify\controller;
use app\common\controller\Frontend;
use think\Db;
class Sms extends Frontend
{
protected $noNeedLogin = [];
protected $noNeedRight = '*';
protected $layout = '';
public function _initialize()
{
parent::_initialize();
$this->model = new \app\admin\model\reservoir\Sms;
}
public function seting()
{
$list = $this->model::all();
$this->view->assign('list',$list);
return $this->view->fetch();
}
public function sendmsg($ids=null)
{
if ($this->request->isPost()) {
$params = $this->request->post();
$mobile = $params['mobile'];
$code = $params['code'];
$data = $params['data'];
$res = \app\common\library\Sms::notice($mobile, $data, $code);
dump($res);
}
$sms = $this->model::get($ids);
if (!$sms) {
$this->error('短信模板不存在');
}
preg_match_all('/\${.*?}/', $sms->message, $matches);
$smsvar = $matches[0];
$values = [];
foreach ($smsvar as $key=>$item) {
$values[] = str_replace(['${', '}'], '', $item);
}
$this->view->assign([
'smsvar'=> $values,
'sms' => $sms
]);
return $this->view->fetch();
}
}