checkUser) { $this->data['uid'] = Dever::load('passport/applet')->check(); } else { $this->data['uid'] = Dever::load('passport/applet')->check(false); } if ($this->data['uid'] < 0) { $this->data['uid'] = 0; } //$this->data['uid'] = 1; # 获取基本配置 $this->data['setting'] = Dever::db('main/config')->one(); $this->data['system'] = Dever::input('system', 1); $source_type = Dever::input('source_type'); $this->app = false; if ($source_type == 'ios' || $source_type == 'android') { $this->app = true; } } # 图片处理 public function pic($data, $type = 't1') { //?imageView2/1/w/100/h/100/q/75 $config = array ( 'pic','pic_cover', 'content', 'share_pic' ); foreach ($config as $k => $v) { if (isset($data[$v]) && $data[$v]) { $data[$v] = $this->replacePic($data[$v], $type); } } return $data; } public function replacePic($pic, $type = 't1') { //$pic = Dever::pic($pic, $type); if (strstr($pic, 'http://')) { $pic = str_replace('http://', 'https://', $pic); } return $pic; } # 列表页里的数据 根据类型,解析内容 protected function content($data, $content = false) { $type = $id = false; if (isset($data['type']) && isset($data['data_id'])) { $type = $data['type']; $id = $data['data_id']; } if ($type && $id) { $table = Dever::config('base')->type_table[$type]; //$info = Dever::db($table)->getOne($id); $info = Dever::db($table)->one($id); if ($info) { return $this->getInfo($type, $info, $content); } else { return array(); } } return array(); } protected function getInfo($type, $info, $content = false) { $info = $this->pic($info); $info['type'] = $type; $info['data_id'] = $info['id']; if (isset($info['pdate']) && $info['pdate'] > 0) { } else { $info['pdate'] = time(); } $info['pdate_str'] = Dever::mdate($info['pdate'], 2); $info['pdate'] = date('Y-m-d H:i', $info['pdate']); /* if (isset($info['share_content'])) { $source = Dever::db('source/info')->one(1); $info['share_link'] = $source['code']; } */ if (isset($info['cate_id']) && $info['cate_id']) { $info['cate'] = Dever::db('content/cate')->one($info['cate_id']); } if (isset($info['num_view']) && $info['num_view'] > 100000) { $info['num_view'] = '10w+'; } if (isset($info['author_id']) && $info['author_id'] > 0) { $info['author'] = Dever::db('content/author')->one($info['author_id']); } elseif (isset($info['uid']) && $info['uid'] > 0) { $info['author'] = Dever::db('passport/user')->one($info['uid']); $info['author']['name'] = $info['author']['username']; } if (isset($info['num_add_view']) && isset($info['num_view'])) { $info['num_view'] = $info['num_add_view'] + $info['num_view']; unset($info['num_add_view']); } if (isset($info['num_add_up']) && isset($info['num_up'])) { $info['num_up'] = $info['num_add_up'] + $info['num_up']; unset($info['num_add_up']); } if (isset($info['num_add_user']) && isset($info['num_user'])) { $info['num_user'] = $info['num_add_user'] + $info['num_user']; unset($info['num_add_user']); } if (isset($info['num_add_ding']) && isset($info['num_ding'])) { $info['num_ding'] = $info['num_add_ding'] + $info['num_ding']; unset($info['num_add_ding']); } if (isset($info['name']) && $info['name']) { $info['name'] = Dever::cut($info['name'], 20, '...'); } return $info; } protected function getSourceUid($error = true) { return Dever::load('invite/api')->getSourceUid($this->data['uid'], $error); } protected function log() { $input = Dever::json_encode(Dever::input()); $url = Dever::url(); Dever::log($url . '||' . $input, 'request'); } }