Version.php 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124
  1. <?php
  2. /*
  3. |--------------------------------------------------------------------------
  4. | tester 体验者设置
  5. |--------------------------------------------------------------------------
  6. */
  7. namespace Component\Src;
  8. use Dever;
  9. use Main\Lib\Wechat;
  10. class Version extends Core
  11. {
  12. public $table = 'version';
  13. public function handle($oauth, $info, $delete, $user, $wechat)
  14. {
  15. $template = Dever::db('component/template')->one($info['template_id']);
  16. $oauth['method'] = 'applet_commit';
  17. $oauth['template_id'] = $template['template'] - 1;
  18. $oauth['user_version'] = $info['name'];
  19. $oauth['user_desc'] = $info['desc'];
  20. $project = Dever::db('main/project')->one($info['project_id']);
  21. $user = Dever::db('component/user')->one($user);
  22. //$pageInfo = Dever::db('component/page')->state(array('option_template_id' => $template['id']));
  23. $pageInfo = Dever::db('component/page')->state();
  24. $page = array();
  25. if ($pageInfo) {
  26. $i = 0;
  27. foreach ($pageInfo as $k => $v) {
  28. $page[$i] = $v['pagepath'];
  29. $i++;
  30. }
  31. }
  32. $tabbar = Dever::db('component/tabbar')->state(array('option_template_id' => $template['id']));
  33. $tab = array();
  34. if ($tabbar) {
  35. $i = 0;
  36. foreach ($tabbar as $k => $v) {
  37. $tab[$i]['pagePath'] = $pageInfo[$v['page_id']]['pagepath'];
  38. if ($i == 0) {
  39. /*
  40. $key = array_search($tab[$i]['pagePath'], $page);
  41. if ($key && isset($page[$key])) {
  42. unset($page[$key]);
  43. }
  44. */
  45. array_unshift($page, $tab[$i]['pagePath']);
  46. }
  47. $tab[$i]['text'] = $v['name'];
  48. $tab[$i]['iconPath'] = $v['iconpath'];
  49. $tab[$i]['selectedIconPath'] = $v['selectediconpath'];
  50. $i++;
  51. }
  52. }
  53. /*
  54. $page = array
  55. (
  56. "pages/shop/index",
  57. "pages/shop-dl/index",
  58. "pages/index/index",
  59. "pages/thelecture/index",
  60. "pages/toAttend/index",
  61. "pages/index-dl/index",
  62. "pages/toAttend-dl/index",
  63. "pages/thelecture-dl/index",
  64. "pages/service-2/index",
  65. "pages/service-dl/index",
  66. "pages/article/index",
  67. "pages/cooperation-1/index",
  68. "pages/cooperation-2/index",
  69. "pages/service-1/index"
  70. );
  71. */
  72. if (!isset($template['act_id'])) {
  73. $template['act_id'] = 0;
  74. }
  75. $ext = array
  76. (
  77. 'extEnable' => true,
  78. 'extAppid' => $oauth['openid'],
  79. 'directCommit' => false,
  80. 'ext' => array
  81. (
  82. 'version' => $info['name'],
  83. 'desc' => $user['desc'],
  84. 'project' => $project['id'],
  85. 'act' => $template['act_id'],
  86. ),
  87. 'extPages' => array(),
  88. 'pages' => $page,
  89. 'window' => array
  90. (
  91. 'navigationBarTitleText' => $user['name'],
  92. ),
  93. 'tabBar' => array
  94. (
  95. 'color' => '#666666',
  96. 'selectedColor' => '#ff8903',
  97. 'backgroundColor' => '#FAFAFA',
  98. 'list' => $tab,
  99. ),
  100. );
  101. if (!$tab) {
  102. unset($ext['tabBar']);
  103. }
  104. if (!$page) {
  105. unset($ext['pages']);
  106. }
  107. $oauth['ext_json'] = json_encode($ext, JSON_UNESCAPED_UNICODE);
  108. //print_r($oauth);die;
  109. return $oauth;
  110. }
  111. }