index.php 9.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297
  1. <?php
  2. /**
  3. * cms首页
  4. *
  5. *
  6. *
  7. */
  8. use bonus\activity_bonus;
  9. use mcard\user_mcards;
  10. defined('InShopNC') or exit('Access Invalid!');
  11. require_once(BASE_ROOT_PATH . '/mobile/control/special.php');
  12. require_once(BASE_HELPER_PATH . '/goods_helper.php');
  13. require_once(BASE_HELPER_PATH . '/special_helper.php');
  14. require_once(BASE_HELPER_PATH . '/index_tab.php');
  15. require_once(BASE_HELPER_PATH . '/util_helper.php');
  16. require_once(BASE_HELPER_PATH . '/third_author/wxauthor.php');
  17. require_once(BASE_HELPER_PATH . '/third_author/wxauthor.php');
  18. require_once(BASE_HELPER_PATH . '/session_helper.php');
  19. require_once(BASE_HELPER_PATH . '/url_helper.php');
  20. require_once(BASE_HELPER_PATH . '/room/tpl_group_home.php');
  21. require_once(BASE_HELPER_PATH . '/room/tpl_chatwo_home.php');
  22. require_once(BASE_HELPER_PATH . '/mcard/mcard.php');
  23. require_once(BASE_HELPER_PATH . '/mtopcard/mtopcard.php');
  24. require_once(BASE_HELPER_PATH . '/calc_helper.php');
  25. class indexControl extends specialControl
  26. {
  27. const HomeSpecialID = 0;
  28. public function __construct()
  29. {
  30. parent::__construct();
  31. }
  32. public function mini_indexOp()
  33. {
  34. global $config;
  35. $setting = $config['client_setting'];
  36. if(empty($setting)) {
  37. $_GET['special_id'] = 0;
  38. }
  39. else
  40. {
  41. $version = session_helper::version_code();
  42. $running = $setting['running'];
  43. $spid = $setting['home'];
  44. if($version > $running) {
  45. $_GET['special_id'] = $spid;
  46. }
  47. else {
  48. $_GET['special_id'] = 0;
  49. }
  50. }
  51. return parent::indexOp();
  52. }
  53. public function wap_indexOp()
  54. {
  55. global $config;
  56. $setting = $config['client_setting'];
  57. if(empty($setting)) {
  58. $spid = 0;
  59. }
  60. else
  61. {
  62. $version = session_helper::version_code();
  63. $running = $setting['running'];
  64. $spid = $setting['home'];
  65. if($version <= $running) {
  66. $spid = 0;
  67. }
  68. }
  69. return self::outsuccess(['special_id' => $spid]);
  70. }
  71. public function tabsOp()
  72. {
  73. $client_tpe = session_helper::client_type();
  74. if($client_tpe == session_helper::device_mini || $client_tpe == session_helper::device_wap) {
  75. $tabs = [];
  76. $tabs[] = ['special_id' => 1039,'name' => '推荐'];
  77. $tabs[] = ['special_id' => 1122,'name' => '品牌'];
  78. $tabs[] = ['special_id' => 1025,'name' => '护肤'];
  79. $tabs[] = ['special_id' => 1035,'name' => '彩妆'];
  80. $tabs[] = ['special_id' => 1036,'name' => '洗护'];
  81. $tabs[] = ['special_id' => 886,'name' => '男士'];
  82. }
  83. else {
  84. $tabs = index_tab::instance()->tabs();
  85. }
  86. $daliy_bonus = activity_bonus::daliy_bonus_url();
  87. return self::outsuccess(['tabs' => $tabs,'daliy_bonus' =>$daliy_bonus]);
  88. }
  89. public function splashOp()
  90. {
  91. $sig = $_GET['sig'];
  92. $ret = $this->pub_special($this->splash_id());
  93. if(empty($ret['special_list'])) {
  94. return self::outsuccess(null);
  95. }
  96. $block = $ret['special_list'][0];
  97. if(empty($block) || empty($block['items'])) {
  98. return self::outsuccess(null);
  99. }
  100. $image = $block['items'][0]['image'];
  101. if(empty($sig) || $sig != md5($image)) {
  102. return self::outsuccess(['sig' => md5($image),'url' => $image]);
  103. } else {
  104. return self::outsuccess(null);
  105. }
  106. }
  107. private function splash_id()
  108. {
  109. global $config;
  110. $special_id = $config['splash_page']['special_id'];
  111. return $special_id;
  112. }
  113. public function inoherbOp()
  114. {
  115. return self::outsuccess(['direct_uri' => BASE_SITE_URL . '/hfive/inoherb/index.html?2'],"redirect");
  116. }
  117. /**
  118. * 会话详情页 talk_type:room/chatwo talk_id:room_id/user
  119. * 回话详情@ app打开
  120. * 群详情@ 微信扫码进入
  121. */
  122. public function room_indexOp()
  123. {
  124. $talk_type = trim($_GET['talk_type']);
  125. $talk_id = intval($_GET['talk_id']);
  126. $relay_id = intval($_GET['relay_id']);
  127. $open_talk = intval($_GET['open_talk']);
  128. if($talk_id <= 0) {
  129. return self::outerr(errcode::ErrParamter);
  130. }
  131. //微信内打开使用授权判断
  132. if(session_helper::need_wechat_author()) {
  133. $author = new thrid_author\wxauthor();
  134. $url = url_helper::room_detail_url($talk_type,$talk_id,$relay_id);
  135. $url = $author->enter($url);
  136. return self::outsuccess(['direct_uri' => $url],"redirect");
  137. }
  138. $is_app = intval(session_helper::isapp());
  139. $user = session_helper::memberid();
  140. $param = ["talk_type" => $talk_type, "talk_id" => $talk_id , "member_id" => $user,"room_name" => "","room_avatar" => "","relay_id" => $relay_id,
  141. "is_app" => $is_app,
  142. "open_talk" => $open_talk];
  143. if(!session_helper::logined())
  144. {
  145. if($talk_type == "room") {
  146. return self::outsuccess(['tpl' => null,"param" => $param],'talk/homepage_room');
  147. } elseif($talk_type == 'chatwo') {
  148. return self::outsuccess(['tpl' => null,"param" => $param],'talk/homepage_chatwo');
  149. } else {
  150. return self::outerr(errcode::ErrParamter);
  151. }
  152. }
  153. if($talk_type == "room")
  154. {
  155. try {
  156. $room_id = $talk_id;
  157. $tpl = new room\tpl_group_home($user,$talk_id,$relay_id);
  158. $param["room_name"] = $tpl->get_room_info()->name();
  159. $param["room_avatar"] = $tpl->get_room_info()->avatar();
  160. return self::outsuccess(['tpl' => $tpl,"param" => $param],'talk/homepage_room');
  161. } catch (Exception $ex) {
  162. Log::record("member_talk.room_detail error: room_id={$room_id} user={$user}",Log::ERR);
  163. return self::outerr(errcode::ErrParamter);
  164. }
  165. }
  166. elseif($talk_type == 'chatwo')
  167. {
  168. try {
  169. $other = $talk_id;
  170. $tpl = new room\tpl_chatwo_home($user,$other);
  171. return self::outsuccess(['tpl' => $tpl,"param"=>$param],'talk/homepage_chatwo');
  172. } catch (Exception $ex) {
  173. Log::record("member_talk.room_detail error: other={$other} user={$user}",Log::ERR);
  174. return self::outerr(errcode::ErrParamter);
  175. }
  176. }
  177. else
  178. {
  179. return self::outerr(errcode::ErrParamter);
  180. }
  181. }
  182. ///获取充值卡的数据接口.
  183. public function card_goodsOp()
  184. {
  185. $page_type = $_GET['page_type']; //oil or phone page.
  186. if(empty($page_type)) {
  187. return self::outerr(errcode::ErrParamter);
  188. }
  189. $calctor = new CalcPrice(session_helper::memberid());
  190. $goods = $this->card_goods($page_type,$calctor);
  191. $ret = [];
  192. if(session_helper::memberid() > 0)
  193. {
  194. $card_list = mtopcard\priority_cards(session_helper::memberid(),$page_type);
  195. $ret['cards'] = mtopcard\topcard_format($card_list);
  196. }
  197. else {
  198. $ret['cards'] = [];
  199. }
  200. $ret['tips'] = $calctor->calc_tips();
  201. foreach ($goods as $item)
  202. {
  203. [$tip,$show_invite] = $calctor->inviter_tips($item['goods_id']);
  204. $ret['goods_inviter_tips'][] = [
  205. 'goods_id' => $item['goods_id'],
  206. 'tip' => $tip,
  207. 'show_invite' => $show_invite];
  208. }
  209. $ret['inviter_tips'] = empty($ret['goods_inviter_tips']) ? '' : $ret['goods_inviter_tips'][0]['tip'];
  210. $ret['goods'] = $goods;
  211. $ret['member_mobile'] = session_helper::mobile();
  212. $ret['special_id'] = $this->paysuccess_special();
  213. return self::outsuccess($ret);
  214. }
  215. private function paysuccess_special()
  216. {
  217. global $config;
  218. return $config['special_pay_success'];
  219. }
  220. private function card_goods($card_type,$calctor)
  221. {
  222. global $config;
  223. $card_commids = $config['card_commonid'];
  224. if(empty($card_commids)) {
  225. return [];
  226. }
  227. $commonid = intval($card_commids[$card_type]);
  228. Log::record("card_type = {$card_type} commonid={$commonid}",Log::DEBUG);
  229. if($commonid > 0)
  230. {
  231. $mod_goods = Model('goods');
  232. $goods_list = $mod_goods->getGoodsOnlineList(['goods_commonid' => $commonid]);
  233. $helper = new goods_helper(new bonus\normal_calc());
  234. $goods_list = $helper->summary($goods_list, $related_goods,[$calctor,'calc_vgoods_price']);
  235. $summarys = &$goods_list['summary'];
  236. usort($summarys,[__CLASS__,'comp_goods']);
  237. return $summarys;
  238. }
  239. else {
  240. return [];
  241. }
  242. }
  243. public static function comp_goods($left,$right)
  244. {
  245. $t_l = intval($left['goods_spec']);
  246. $t_r = intval($right['goods_spec']);
  247. if($t_l > $t_r) {
  248. return 1;
  249. }
  250. elseif($t_l == $t_r)
  251. {
  252. return 0;
  253. }
  254. else {
  255. return -1;
  256. }
  257. }
  258. }