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
<?php
 
namespace app\branch\controller\setting;
 
use app\branch\controller\Controller;
use app\branch\model\settings\Setting as SettingModel;
use app\common\service\qrcode\MpLoginService;
/**
 * 消息通知
 */
class Message extends Controller
{
 
    /**
     * 修改信息
     */
    public function index()
    {
        if($this->request->isGet()){
            return $this->fetchData();
        }
        $model = new SettingModel;
        if ($model->edit('message', $this->postData(),$this->getBranchId())) {
            return $this->renderSuccess('操作成功');
        }
        return $this->renderError($model->getError() ?: '操作失败');
    }
 
    /**
     * 获取消息配置
     */
    public function fetchData()
    {
        $Qrcode = new MpLoginService(
            SettingModel::$app_id
        );
        $vars['qrcode'] = $Qrcode->getImage();
        $vars['values'] = SettingModel::getBranchItem( 'message', $this->getBranchId());
        return $this->renderSuccess('', compact('vars'));
    }
 
}