display.ctrl.php 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  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('wxapp');
  8. load()->model('account');
  9. $_W['page']['title'] = '小程序列表';
  10. $dos = array('display', 'switch', 'rank', 'home');
  11. $do = in_array($do, $dos) ? $do : 'display';
  12. if ($do == 'rank' || $do == 'switch') {
  13. $uniacid = intval($_GPC['uniacid']);
  14. if (!empty($uniacid)) {
  15. $wxapp_info = wxapp_fetch($uniacid);
  16. if (empty($wxapp_info)) {
  17. itoast('小程序不存在', referer(), 'error');
  18. }
  19. }
  20. }
  21. if ($do == 'home') {
  22. $last_uniacid = uni_account_last_switch();
  23. $url = url('wxapp/display');
  24. if (empty($last_uniacid)) {
  25. itoast('', $url, 'info');
  26. }
  27. if (!empty($last_uniacid) && $last_uniacid != $_W['uniacid']) {
  28. wxapp_switch($last_uniacid);
  29. }
  30. $permission = permission_account_user_role($_W['uid'], $last_uniacid);
  31. if (empty($permission)) {
  32. itoast('', $url, 'info');
  33. }
  34. $last_version = wxapp_fetch($last_uniacid);
  35. if (!empty($last_version)) {
  36. $url = url('wxapp/version/home', array('version_id' => $last_version['version']['id']));
  37. }
  38. itoast('', $url, 'info');
  39. } elseif ($do == 'display') {
  40. $account_info = permission_user_account_num();
  41. $pindex = max(1, intval($_GPC['page']));
  42. $psize = 20;
  43. $account_table = table('wxapp');
  44. $account_table->searchWithType(array(ACCOUNT_TYPE_APP_NORMAL));
  45. $keyword = trim($_GPC['keyword']);
  46. if (!empty($keyword)) {
  47. $account_table->searchWithKeyword($keyword);
  48. }
  49. $account_table->accountRankOrder();
  50. $account_table->searchWithPage($pindex, $psize);
  51. $wxapp_lists = $account_table->searchAccountList();
  52. $total = $account_table->getLastQueryTotal();
  53. if (!empty($wxapp_lists)) {
  54. foreach ($wxapp_lists as &$account) {
  55. $account = uni_fetch($account['uniacid']);
  56. $account['versions'] = wxapp_get_some_lastversions($account['uniacid']);
  57. if (!empty($account['versions'])) {
  58. foreach ($account['versions'] as $version) {
  59. if (!empty($version['current'])) {
  60. $account['current_version'] = $version;
  61. }
  62. }
  63. }
  64. }
  65. }
  66. $pager = pagination($total, $pindex, $psize);
  67. template('wxapp/account-display');
  68. } elseif ($do == 'switch') {
  69. $module_name = trim($_GPC['module']);
  70. $version_id = !empty($_GPC['version_id']) ? intval($_GPC['version_id']) : $wxapp_info['version']['id'];
  71. if (!empty($module_name) && !empty($version_id)) {
  72. $version_info = wxapp_version($version_id);
  73. $module_info = array();
  74. if (!empty($version_info['modules'])) {
  75. foreach ($version_info['modules'] as $key => $module_val) {
  76. if ($module_val['name'] == $module_name) {
  77. $module_info = $module_val;
  78. }
  79. }
  80. }
  81. if (empty($version_id) || empty($module_info)) {
  82. itoast('版本信息错误');
  83. }
  84. $url = url('home/welcome/ext/', array('m' => $module_name));
  85. if (!empty($module_info['account']['uniacid'])) {
  86. uni_account_switch($module_info['account']['uniacid'], $url);
  87. } else {
  88. $url .= '&version_id=' . $version_id;
  89. wxapp_switch($version_info['uniacid'], $url);
  90. }
  91. }
  92. wxapp_update_last_use_version($uniacid, $version_id);
  93. wxapp_switch($uniacid, url('wxapp/version/home', array('version_id' => $version_id)));
  94. exit;
  95. } elseif ($do == 'rank') {
  96. uni_account_rank_top($uniacid);
  97. itoast('更新成功', '', '');
  98. }