123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145 |
- <?php
- /**
- * [WeEngine System] Copyright (c) 2014 WE7.CC
- * WeEngine is NOT a free software, it under the license terms, visited http://www.we7.cc/ for more details.
- */
- defined('IN_IA') or exit('Access Denied');
- load()->model('miniapp');
- load()->model('mc');
- $dos = array('nav', 'slide', 'commend', 'wxapp_web', 'wxappweb_pay', 'wxappweb_pay_result', 'package_app', 'go_paycenter', 'oauth', 'credit_info');
- $do = in_array($_GPC['do'], $dos) ? $_GPC['do'] : 'nav';
- $multiid = intval($_GPC['t']);
- if ($do == 'nav') {
- $navs = pdo_getall('site_nav', array(
- 'uniacid' => $_W['uniacid'],
- 'multiid' => $multiid,
- 'status' => 1,
- 'icon !=' => '',
- ), array('url', 'name', 'icon'), '', 'displayorder DESC');
- if (!empty($navs)) {
- foreach ($navs as $i => &$row) {
- $row['icon'] = tomedia($row['icon']);
- }
- }
- message(error(0, $navs), '', 'ajax');
- } elseif ($do == 'slide') {
- $slide = pdo_getall('site_slide', array(
- 'uniacid' => $_W['uniacid'],
- 'multiid' => $multiid,
- ), array('url', 'title', 'thumb'), '', 'displayorder DESC');
- if (!empty($slide)) {
- foreach ($slide as $i => &$row) {
- $row['thumb'] = tomedia($row['thumb']);
- }
- }
- message(error(0, $slide), '', 'ajax');
- } elseif ($do == 'commend') {
- //获取一级分类
- $category = pdo_getall('site_category', array(
- 'uniacid' => $_W['uniacid'],
- 'multiid' => $multiid,
- ), array('id', 'name', 'parentid'), '', 'displayorder DESC');
- //一级分类不能添加文章,推荐时获取到其子类
- if (!empty($category)) {
- foreach ($category as $id => &$category_row) {
- if (empty($category_row['parentid'])) {
- $condition['pcate'] = $category_row['id'];
- } else {
- $condition['ccate'] = $category_row['id'];
- }
- $category_row['article'] = pdo_getall('site_article', $condition, array('id', 'title', 'thumb'), '', 'displayorder DESC', array(8));
- if (!empty($category_row['article'])) {
- foreach ($category_row['article'] as &$row) {
- $row['thumb'] = tomedia($row['thumb']);
- }
- } else {
- unset($category[$id]);
- }
- }
- }
- message(error(0, $category), '', 'ajax');
- }
- if ($do == 'wxapp_web') {
- $version = trim($_GPC['v']);
- $version_info = miniapp_version_by_version($version);
- $url = $_GPC['url'];
- if (empty($url)) {
- //无需查询绑定域名 因为本do方法就是根据小程序域名访问的
- if (count($version_info['modules']) > 1) {
- //多模块打包入口
- $url = murl('wxapp/home/package_app', array('v'=>$version)); } else {
- if (!empty($version_info['modules'])) {
- foreach ($version_info['modules'] as $module) {
- if (!empty($module['account']) && intval($module['account']['uniacid']) > 0) {
- $_W['uniacid'] = $module['account']['uniacid'];
- $_W['account']['link_uniacid'] = $module['account']['uniacid'];
- }
- }
- }
- $url = murl('entry', array('eid'=>$version_info['entry_id']), true, true);
- }
- }
- if ($url) {
- setcookie(session_name(), $_W['session_id']);
- header('Location:' . $url);
- exit;
- }
- message('找不到模块入口', 'refresh', 'error');
- }
- if ($do == 'package_app') {
- $version = trim($_GPC['v']);
- $version_info = miniapp_version_by_version($version);
- $version_info['modules'] = array_map(function($module) {
- $module['url'] = murl('entry', array('eid'=>$module['defaultentry']), true, true);
- return $module;
- }, $version_info['modules']);
- $version_info['quickmenu']['menus'] = array_map(function($menu){
- $menu['url'] = murl('entry', array('eid'=>$menu['defaultentry']), true, true);
- return $menu;
- }, $version_info['quickmenu']['menus']);
- template('wxapp/wxapp');
- }
- if ($do == 'wxappweb_pay') {
- $site = WeUtility::createModuleWxapp('core');
- $site->doPagePay();
- }
- if ($do == 'wxappweb_pay_result') {
- $site = WeUtility::createModuleWxapp('core');
- $site->doPagePayResult();
- }
- if ($do == 'go_paycenter') {
- $plid = intval($_GPC['plid']);
- $params = pdo_get('core_paylog', array('plid' => $plid));
- $params['title'] = safe_gpc_string($_GPC['title']);
- template('common/paycenter');
- }
- if ($do == 'oauth') {
- $url = safe_gpc_url($_GPC['url'], false);
- $oauth_userinfo = mc_oauth_account_userinfo($url);
- if (is_error($oauth_userinfo)) {
- message($oauth_userinfo['message'], $url, 'info');
- }
- header('Location: ' . $url);
- }
- if ($do == 'credit_info') {
- $member_info = mc_fetch($_W['member']['uid'], array('credit2'));
- $credit2 = !empty($member_info['credit2']) ? $member_info['credit2'] : 0;
- message(error(0, $credit2), '', 'ajax');
- }
|