model = new \app\model\Conf(); } /** * 获取某个分组下所有的配置项 */ public function getGroupConf() { $group = $this->request->param('group'); $return = ConfServiceFacade::groupGet($group, true); return $this->success('获取成功', $return); } /** * 保存配置 */ public function saveGroupConf() { global $_W; // $data = \app\model\Conf::where(['group'=>'system.wechat'])->select()->toArray(); // if(!empty($data[0]['uniacid']) && $data[0]['uniacid'] != $_W['uniacid']){ // return $this->error('系统只支持单开'); // } $post = $this->request->post(); if (isset($post['laytpUploadFile'])) { unset($post['laytpUploadFile']); } $group = $post['group']; unset($post['group']); $formType = $post['form_type']; unset($post['form_type']); $allConf = []; foreach ($post as $key => $value) { if (is_array($value)) { $temp = []; foreach ($value['key'] as $arrK => $arrV) { if ($arrV) { $temp[$arrV] = $value['value'][$arrK]; } } $value = $temp; } $conf['group'] = $group; $conf['key'] = $key; $conf['value'] = $value; $conf['form_type'] = $formType[$key]; $conf['uniacid'] = $_W['uniacid']; $allConf[] = $conf; } ConfServiceFacade::groupSet($allConf); return $this->success('保存成功', $allConf); } /** * 删除某个分组下某个key的配置信息 * 这个不在配置页面进行调用,后续要做生成工具的时候统一管理所有的key */ public function del() { $group = $this->request->param('group'); $key = $this->request->param('key'); ConfServiceFacade::del($group, $key); return $this->success('删除成功'); } public function getSystemWords() { $Filter = new \ins\Words('*'); $words = $Filter->getWords(); return $this->success('获取成功',$words); } // 获得公众号链接 public function wechatLinkInfo() { global $_W; // print_r($_SERVER); $site = $_SERVER['HTTP_ORIGIN']; $link = $site . SURL . 'h5/?uniacid=' . $_W['uniacid']; return $this->success('获取成功',$link); } // 获得大数据链接 public function bigdataLinkInfo() { global $_W; $site = $_SERVER['HTTP_ORIGIN']; $link = $site . SURL . '/bigdata?uniacid=' . $_W['uniacid']; return $this->success('获取成功',$link); } // 获得公众号二维码 public function wechatQrcode() { global $_W; //获取二维码生成的地址 } // 获得小程序链接 public function miniappQrcode() { global $_W; $conf = ConfServiceFacade::groupGet('system.miniapp', true); if(!$conf['appid'] || !$conf['appsecret']){ return $this->error('操作失败'); } $app = MiniappServiceFacade::option(); $response = $app->app_code->get('pages/index/index', [ 'width' => 600, 'line_color' => [ 'r' => 105, 'g' => 166, 'b' => 134, ], ]); if ($response instanceof \EasyWeChat\Kernel\Http\StreamResponse) { $time = time(); $filename = $response->saveAs(IA_ROOT_WK.'/public/static/storage/presets/', $time.'appcode.png'); } return $this->success('获取成功',request()->domain() . STATIC_PATH . '/storage/presets/' . $time.'appcode.png'); } // 获得订阅消息 public function miniappNotification() { $conf = ConfServiceFacade::groupGet('system.notification', true); $tid = $this->request->param('tid'); $app = MiniappServiceFacade::option(); // print_r($app->subscribe_message->getTemplateKeywords($tid)); // return; switch($tid){ case 2039: $kidList = [1,4,10,11,12]; break; case 1185: $kidList = [2,3,7,16]; break; case 786: $kidList = [1,2,7,15,4]; break; case 10291: $kidList = [1,2,3]; break; } $sceneDesc = '订阅'; $res = $app->subscribe_message->addTemplate($tid, $kidList, $sceneDesc); return $this->success('获取成功',$res); } }