siteid(); $this->wechat = new WechatModel($site_id); } /** * ************************************************************************微信公众号消息相关方法 开始****************************************************** */ /** * 关联公众号微信unserialize */ public function relateWeixin() { Log::write('微信公众号消息'); $this->wechat->app = $this->wechat->app(); $this->wechat->relateWeixin(); } /** * ************************************************************************微信公众号消息相关方法 结束****************************************************** */ /** * 关联公众号微信unserialize */ public function wechatArticle() { $id = input('id', ''); $index = input('i', 0); $material_model = new MaterialModel(); $info = $material_model->getMaterialInfo([ 'id' => $id ]); if (!empty($info[ 'data' ][ 'value' ]) && json_decode($info[ 'data' ][ 'value' ], true)) { $info[ 'data' ][ 'value' ] = json_decode($info[ 'data' ][ 'value' ], true); } $this->assign('info', $info[ 'data' ]); $this->assign('index', $index); $replace = [ 'WECHAT_CSS' => __ROOT__ . '/addon/wechat/admin/view/public/css', 'WECHAT_JS' => __ROOT__ . '/addon/wechat/admin/view/public/js', 'WECHAT_IMG' => __ROOT__ . '/addon/wechat/admin/view/public/img', ]; return $this->fetch('wechat/article', [], $replace); } /** * 获取授权信息 */ public function getAuthInfo() { $cache_key = input("cache_key"); $site_id = request()->siteid(); $wechat_model = new WechatModel($site_id); $res = $wechat_model->authCodeToOpenid(input()); if ($res["code"] >= 0) { Cache::set($cache_key, $res["data"]); $this->assign('result', '授权成功!'); return $this->fetch('auth/result'); } else { $this->assign('result', $res['message']); return $this->fetch('auth/result'); } } }