人人商城

home.ctrl.php 4.2KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142
  1. <?php
  2. /**
  3. * [WeEngine System] Copyright (c) 2014 WE7.CC
  4. * WeEngine is NOT a free software, it under the license terms, visited http://www.we7.cc/ for more details.
  5. */
  6. defined('IN_IA') or exit('Access Denied');
  7. load()->model('miniapp');
  8. load()->model('mc');
  9. $dos = array('nav', 'slide', 'commend', 'wxapp_web', 'wxappweb_pay', 'wxappweb_pay_result', 'package_app', 'go_paycenter', 'oauth', 'credit_info');
  10. $do = in_array($_GPC['do'], $dos) ? $_GPC['do'] : 'nav';
  11. $multiid = intval($_GPC['t']);
  12. if ($do == 'nav') {
  13. $navs = pdo_getall('site_nav', array(
  14. 'uniacid' => $_W['uniacid'],
  15. 'multiid' => $multiid,
  16. 'status' => 1,
  17. 'icon !=' => '',
  18. ), array('url', 'name', 'icon'), '', 'displayorder DESC');
  19. if (!empty($navs)) {
  20. foreach ($navs as $i => &$row) {
  21. $row['icon'] = tomedia($row['icon']);
  22. }
  23. }
  24. message(error(0, $navs), '', 'ajax');
  25. } elseif ($do == 'slide') {
  26. $slide = pdo_getall('site_slide', array(
  27. 'uniacid' => $_W['uniacid'],
  28. 'multiid' => $multiid,
  29. ), array('url', 'title', 'thumb'), '', 'displayorder DESC');
  30. if (!empty($slide)) {
  31. foreach ($slide as $i => &$row) {
  32. $row['thumb'] = tomedia($row['thumb']);
  33. }
  34. }
  35. message(error(0, $slide), '', 'ajax');
  36. } elseif ($do == 'commend') {
  37. $category = pdo_getall('site_category', array(
  38. 'uniacid' => $_W['uniacid'],
  39. 'multiid' => $multiid,
  40. ), array('id', 'name', 'parentid'), '', 'displayorder DESC');
  41. if (!empty($category)) {
  42. foreach ($category as $id => &$category_row) {
  43. if (empty($category_row['parentid'])) {
  44. $condition['pcate'] = $category_row['id'];
  45. } else {
  46. $condition['ccate'] = $category_row['id'];
  47. }
  48. $category_row['article'] = pdo_getall('site_article', $condition, array('id', 'title', 'thumb'), '', 'displayorder DESC', array(8));
  49. if (!empty($category_row['article'])) {
  50. foreach ($category_row['article'] as &$row) {
  51. $row['thumb'] = tomedia($row['thumb']);
  52. }
  53. } else {
  54. unset($category[$id]);
  55. }
  56. }
  57. }
  58. message(error(0, $category), '', 'ajax');
  59. }
  60. if ($do == 'wxapp_web') {
  61. $version = trim($_GPC['v']);
  62. $version_info = miniapp_version_by_version($version);
  63. $url = $_GPC['url'];
  64. if (empty($url)) {
  65. if (count($version_info['modules']) > 1) {
  66. $url = murl('wxapp/home/package_app', array('v'=>$version)); } else {
  67. if (!empty($version_info['modules'])) {
  68. foreach ($version_info['modules'] as $module) {
  69. if (!empty($module['account']) && intval($module['account']['uniacid']) > 0) {
  70. $_W['uniacid'] = $module['account']['uniacid'];
  71. $_W['account']['link_uniacid'] = $module['account']['uniacid'];
  72. }
  73. }
  74. }
  75. $url = murl('entry', array('eid'=>$version_info['entry_id']), true, true);
  76. }
  77. }
  78. if ($url) {
  79. setcookie(session_name(), $_W['session_id']);
  80. header('Location:' . $url);
  81. exit;
  82. }
  83. message('找不到模块入口', 'refresh', 'error');
  84. }
  85. if ($do == 'package_app') {
  86. $version = trim($_GPC['v']);
  87. $version_info = miniapp_version_by_version($version);
  88. $version_info['modules'] = array_map(function($module) {
  89. $module['url'] = murl('entry', array('eid'=>$module['defaultentry']), true, true);
  90. return $module;
  91. }, $version_info['modules']);
  92. $version_info['quickmenu']['menus'] = array_map(function($menu){
  93. $menu['url'] = murl('entry', array('eid'=>$menu['defaultentry']), true, true);
  94. return $menu;
  95. }, $version_info['quickmenu']['menus']);
  96. template('wxapp/wxapp');
  97. }
  98. if ($do == 'wxappweb_pay') {
  99. $site = WeUtility::createModuleWxapp('core');
  100. $site->doPagePay();
  101. }
  102. if ($do == 'wxappweb_pay_result') {
  103. $site = WeUtility::createModuleWxapp('core');
  104. $site->doPagePayResult();
  105. }
  106. if ($do == 'go_paycenter') {
  107. $plid = intval($_GPC['plid']);
  108. $params = pdo_get('core_paylog', array('plid' => $plid));
  109. $params['title'] = safe_gpc_string($_GPC['title']);
  110. template('common/paycenter');
  111. }
  112. if ($do == 'oauth') {
  113. $url = safe_gpc_url($_GPC['url'], false);
  114. $oauth_userinfo = mc_oauth_account_userinfo($url);
  115. if (is_error($oauth_userinfo)) {
  116. message($oauth_userinfo['message'], $url, 'info');
  117. }
  118. header('Location: ' . $url);
  119. }
  120. if ($do == 'credit_info') {
  121. $member_info = mc_fetch($_W['member']['uid'], array('credit2'));
  122. $credit2 = !empty($member_info['credit2']) ? $member_info['credit2'] : 0;
  123. message(error(0, $credit2), '', 'ajax');
  124. }