config = Dever::json_decode(Dever::decode($p, $this->key)); } # 第三方账户 $this->account = $this->getConfig('account', 1); # 小刊分类 $this->cate = $this->getConfig('cate', 1); # 渠道 $this->source = $this->getConfig('source', 1); # 类型 1为直接购买 2为购买兑换码 $this->type = $this->getConfig('type', 1); # 销售商 $this->seller = $this->getConfig('seller', 1); # 用户信息 $this->user = Dever::load('passport/user')->data(); } # 创建url public function createUrl() { # 第三方账户 $this->account = Dever::input('account', 1); # 分类 $this->cate = Dever::input('cate', 1); # 渠道 $this->source = Dever::input('source', 1); # 类型 1为直接购买 2为购买兑换码 $this->type = Dever::input('type', 1); # 销售商 $this->seller = Dever::input('seller', 1); $url = $this->url('home'); return $url; } private function getConfig($key, $value) { if (isset($this->config[$key]) && $this->config[$key]) { return $this->config[$key]; } return $value; } # 获取基本配置 public function config() { $cate = Dever::db('journal/cate')->one($this->cate); $cate['login_title'] = '登录后才可以使用' . $cate['name'] . '服务'; $cate['bglogo'] = 'background:url('.$cate['logo'].') no-repeat;background-size: 2.2667rem 2.2667rem;'; $url = urlencode($this->url('list')); $cate['login'] = 'location.href=\'' . Dever::url('request.auth?account='.$this->account.'&source='.$this->source.'&refer=' . $url, 'oauth') . '\''; $info = Dever::db('journal/info')->getOne($cate['journal_id']); if ($info && $info['pic_gd']) { $cate['cover'] = $info['pic_gd']; } return $cate; } # 生成url protected function url($uri, $param = array()) { if ($uri == 'list' && $this->type == 2) { $uri = 'list_code'; } $send['cate'] = $this->cate; $send['source'] = $this->source; $send['type'] = $this->type; $send['seller'] = $this->seller; $param['p'] = Dever::encode(Dever::json_encode($send), $this->key); $param = http_build_query($param); $url = Dever::url($uri . '?' . $param, 'service'); return $url; } protected function location($uri, $param = array()) { return Dever::location($this->url($uri, $param)); } protected function createOrder($prefix = 'JC') { $order = Dever::order($prefix); //$order = Dever::rand(2, 2) . Dever::rand(6, 0); $info = Dever::db('journal/order')->one(array('order_id' => $order)); if ($info) { return $this->createOrder($prefix); } return $order; } }